Documentation
¶
Overview ¶
Package mcp provides MCP handlers for time and date utilities. It enables AI assistants to perform time-related operations through standardized MCP tools.
Index ¶
- Constants
- Variables
- func CompareTime(ctx context.Context, request mcp.CallToolRequest) (r *mcp.CallToolResult, err error)
- func ConvertTime(ctx context.Context, request mcp.CallToolRequest) (r *mcp.CallToolResult, err error)
- func CurrentTime(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error)
- func GetTransports() []string
- func RegisterHandlers(s *server.MCPServer)
- func RelativeTime(ctx context.Context, request mcp.CallToolRequest) (r *mcp.CallToolResult, err error)
- func TimeAdd(ctx context.Context, request mcp.CallToolRequest) (r *mcp.CallToolResult, err error)
- type Server
Constants ¶
const ( // TransportSTDIO uses standard input/output for communication. TransportSTDIO transport = iota // TransportStream uses an HTTP stream for communication. TransportStream )
Variables ¶
var TransportNames = map[transport]string{ TransportSTDIO: "stdio", TransportStream: "stream", }
TransportNames maps transport types to their string representations.
Functions ¶
func CompareTime ¶
func CompareTime(ctx context.Context, request mcp.CallToolRequest) (r *mcp.CallToolResult, err error)
CompareTime is the handler for the 'compare_time' MCP tool. It compares two times and returns -1, 0, or 1.
func ConvertTime ¶
func ConvertTime(ctx context.Context, request mcp.CallToolRequest) (r *mcp.CallToolResult, err error)
ConvertTime is the handler for the 'convert_timezone' MCP tool. It converts a time from one timezone to another.
func CurrentTime ¶
func CurrentTime(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error)
CurrentTime is the handler for the 'current_time' MCP tool. It returns the current time, optionally formatted and in a specific timezone.
func GetTransports ¶
func GetTransports() []string
GetTransports returns a slice of available transport names.
func RegisterHandlers ¶
RegisterHandlers registers the time and date MCP tools with the provided MCP server.
Parameters:
- s: The MCP server instance to register tools with.
Returns an error if tool registration fails (though current implementation always returns nil).
func RelativeTime ¶
func RelativeTime(ctx context.Context, request mcp.CallToolRequest) (r *mcp.CallToolResult, err error)
RelativeTime is the handler for the 'relative_time' MCP tool. It parses a natural language time expression relative to a given time.
func TimeAdd ¶
func TimeAdd(ctx context.Context, request mcp.CallToolRequest) (r *mcp.CallToolResult, err error)
TimeAdd is the handler for the 'add_time' MCP tool. It adds a duration to a given time.
Types ¶
type Server ¶
Server wraps the core MCP server and registers the time-specific handlers.
func NewServer ¶
NewServer creates a new MCP server with the time tools registered. It initializes the underlying MCP server and registers all the tool handlers.
func (Server) StartStdio ¶
StartStdio starts the server listening on standard input/output. It blocks until the context is canceled or an error occurs.