Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.6.0
type Prompt ¶
type Prompt interface {
// Prompt returns the MCP prompt definition.
Prompt() *mcp.Prompt
// Handler processes prompt requests and returns results.
Handler(ctx context.Context, request *mcp.GetPromptRequest) (*mcp.GetPromptResult, error)
}
Prompt represents a prompt that can be registered with the MCP server. It provides methods to define the prompt metadata and handle prompt requests.
type ResourceTemplate ¶
type ResourceTemplate interface {
// ResourceTemplate returns the MCP resource template definition.
ResourceTemplate() *mcp.ResourceTemplate
// Handler processes resource read requests and returns resource contents.
Handler(ctx context.Context, request *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error)
}
ResourceTemplate represents a resource template that can be registered with the MCP server. It provides methods to define the resource template metadata and handle resource requests.
type Server ¶
type Server interface {
// Serve starts the server with the provided context and handles MCP requests
// until the context is canceled or an error occurs.
Serve(ctx context.Context) error
}
Server represents the interface for the MCP server functionality. It defines the method to start the server and handle MCP requests.
func NewServer ¶
func NewServer( logger *slog.Logger, version string, transport string, transportSSEAddress string, tools []Tool, prompts []Prompt, resourceTemplates []ResourceTemplate, ) Server
NewServer creates a new MCP server with the provided configuration. It registers the provided tools, prompts, and resource templates with the server.
Parameters:
- logger: The structured logger to use for logging.
- transport: The transport type to use ("stdio" or "sse").
- transportSSEAddress: The address to listen on when using SSE transport.
- tools: The list of tools to register with the server.
- prompts: The list of prompts to register with the server.
- resourceTemplates: The list of resource templates to register with the server.
Returns a Server that can be used to start handling MCP requests.
type Tool ¶
type Tool interface {
// Tool returns the MCP tool definition.
Tool() *mcp.Tool
// Register adds the tool to the server using its specific generic types.
Register(s *mcp.Server)
}
Tool represents a callable tool that can be registered with the MCP server. It provides methods to define the tool metadata and register it in mcp server.