Documentation
¶
Index ¶
- Constants
- type CallToolParams
- type CallToolResult
- type ClientCaps
- type ClientInfo
- type InitializeParams
- type InitializeResult
- type InputSchema
- type JSONRPCError
- type JSONRPCRequest
- type JSONRPCResponse
- type ListToolsResult
- type PingResult
- type Property
- type Server
- type ServerCaps
- type ServerInfo
- type ToolContent
- type ToolDefinition
- type ToolHandler
- type ToolsCap
Constants ¶
View Source
const ( ErrCodeParse = -32700 ErrCodeInvalidRequest = -32600 ErrCodeMethodNotFound = -32601 ErrCodeInvalidParams = -32602 ErrCodeInternal = -32603 )
JSON-RPC error codes
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallToolParams ¶
type CallToolResult ¶
type CallToolResult struct {
Content []ToolContent `json:"content"`
IsError bool `json:"isError,omitempty"`
}
type ClientCaps ¶
type ClientCaps struct{}
type ClientInfo ¶
type InitializeParams ¶
type InitializeParams struct {
ProtocolVersion string `json:"protocolVersion"`
Capabilities ClientCaps `json:"capabilities"`
ClientInfo ClientInfo `json:"clientInfo"`
}
type InitializeResult ¶
type InitializeResult struct {
ProtocolVersion string `json:"protocolVersion"`
Capabilities ServerCaps `json:"capabilities"`
ServerInfo ServerInfo `json:"serverInfo"`
Instructions string `json:"instructions,omitempty"`
}
type InputSchema ¶
type JSONRPCError ¶
type JSONRPCRequest ¶
type JSONRPCRequest struct {
JSONRPC string `json:"jsonrpc"`
ID json.RawMessage `json:"id,omitempty"` // can be string, number, or null
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
type JSONRPCResponse ¶
type JSONRPCResponse struct {
JSONRPC string `json:"jsonrpc"`
ID json.RawMessage `json:"id,omitempty"`
Result any `json:"result,omitempty"`
Error *JSONRPCError `json:"error,omitempty"`
}
type ListToolsResult ¶
type ListToolsResult struct {
Tools []ToolDefinition `json:"tools"`
}
type PingResult ¶
type PingResult struct{}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an MCP server that handles JSON-RPC requests.
func (*Server) HandleRequest ¶
func (s *Server) HandleRequest(raw []byte) *JSONRPCResponse
HandleRequest processes a single JSON-RPC request and returns a response.
type ServerCaps ¶
type ServerCaps struct {
Tools *ToolsCap `json:"tools,omitempty"`
}
type ServerInfo ¶
type ToolContent ¶
type ToolDefinition ¶
type ToolDefinition struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema InputSchema `json:"inputSchema"`
}
type ToolHandler ¶
type ToolHandler func(args map[string]any) (*CallToolResult, error)
ToolHandler is a function that handles a tool call.
Click to show internal directories.
Click to hide internal directories.