Documentation
¶
Overview ¶
Package mcp implements the Model Context Protocol server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContentBlock ¶
ContentBlock represents a content block in tool results.
type JSONRPCError ¶
JSONRPCError represents a JSON-RPC 2.0 error.
type JSONRPCRequest ¶
type JSONRPCRequest struct {
JSONRPC string `json:"jsonrpc"`
ID json.RawMessage `json:"id,omitempty"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
JSONRPCRequest represents a JSON-RPC 2.0 request.
type JSONRPCResponse ¶
type JSONRPCResponse struct {
JSONRPC string `json:"jsonrpc"`
ID json.RawMessage `json:"id,omitempty"`
Result interface{} `json:"result,omitempty"`
Error *JSONRPCError `json:"error,omitempty"`
}
JSONRPCResponse represents a JSON-RPC 2.0 response.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server handles MCP protocol communication.
func NewServer ¶
func NewServer(config ServerConfig, logger *slog.Logger, tools ...Tool) *Server
NewServer creates a new MCP server.
func (*Server) ServeStdio ¶
ServeStdio runs the MCP server over stdin/stdout (JSON-RPC over stdio).
type ServerConfig ¶
ServerConfig holds server metadata.
type Tool ¶
type Tool interface {
Definition() ToolDefinition
Execute(ctx context.Context, args json.RawMessage) ToolCallResult
}
Tool is the interface that all MCP tools must implement.
type ToolCallResult ¶
type ToolCallResult struct {
Content []ContentBlock `json:"content"`
IsError bool `json:"isError,omitempty"`
}
ToolCallResult is the result of executing a tool.
type ToolDefinition ¶
type ToolDefinition struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema interface{} `json:"inputSchema"`
}
ToolDefinition describes an MCP tool.