package tools

import (
	"context"
	"time"

	"github.com/modelcontextprotocol/go-sdk/mcp"
)

// GetCurrentTimeInput defines the input parameters for the get_current_time tool
type GetCurrentTimeInput struct {
	// No input parameters needed for basic time query
}

// GetCurrentTimeOutput defines the output structure for the get_current_time tool
type GetCurrentTimeOutput struct {
	Time     string `json:"time" jsonschema:"Current system time in RFC3339 format"`
	Timezone string `json:"timezone" jsonschema:"System timezone"`
	Unix     int64  `json:"unix" jsonschema:"Unix timestamp in seconds"`
}

// GetCurrentTime implements the get_current_time tool handler
// It returns the current system time with timezone information
func GetCurrentTime(ctx context.Context, req *mcp.CallToolRequest, input GetCurrentTimeInput) (
	*mcp.CallToolResult,
	GetCurrentTimeOutput,
	error,
) {
	// Get current time
	now := time.Now()

	// Create output structure
	output := GetCurrentTimeOutput{
		Time:     now.Format(time.RFC3339),
		Timezone: now.Location().String(),
		Unix:     now.Unix(),
	}

	// Return successful result with output
	return &mcp.CallToolResult{}, output, nil
}