Documentation
¶
Index ¶
- Constants
- type CallToolResult
- type Content
- type Error
- type InitializeResult
- type JSONRPCRequest
- type JSONRPCResponse
- type ListResourceTemplatesResult
- type ListResourcesResult
- type ListToolsResult
- type LoggingCapability
- type PromptsCapability
- type ReadResourceResult
- type Resource
- type ResourceContent
- type ResourceTemplate
- type ResourcesCapability
- type Server
- type ServerCapabilities
- type ServerInfo
- type Tool
- type ToolMeta
- type ToolMetaUI
- type ToolsCapability
Constants ¶
const ( CodeParseError = -32700 CodeInvalidRequest = -32600 CodeMethodNotFound = -32601 CodeInvalidParams = -32602 CodeInternalError = -32603 )
MCP Spec Codes
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallToolResult ¶
type CallToolResult struct {
Content []Content `json:"content"`
IsError bool `json:"isError,omitempty"`
}
CallToolResult is the result for tools/call.
type Error ¶
type Error struct {
Code int `json:"code"`
Message string `json:"message"`
Data any `json:"data,omitempty"`
}
Error represents a JSON-RPC error.
type InitializeResult ¶
type InitializeResult struct {
ProtocolVersion string `json:"protocolVersion"`
Capabilities ServerCapabilities `json:"capabilities"`
ServerInfo ServerInfo `json:"serverInfo"`
}
InitializeResult is the result for the initialize method.
type JSONRPCRequest ¶
type JSONRPCRequest struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method"`
Params map[string]any `json:"params,omitempty"`
ID any `json:"id"`
}
JSONRPCRequest represents a standard MCP JSON-RPC request.
type JSONRPCResponse ¶
type JSONRPCResponse struct {
JSONRPC string `json:"jsonrpc"`
Result any `json:"result,omitempty"`
Error *Error `json:"error,omitempty"`
ID any `json:"id"`
}
JSONRPCResponse represents a standard MCP JSON-RPC response.
type ListResourceTemplatesResult ¶
type ListResourceTemplatesResult struct {
ResourceTemplates []ResourceTemplate `json:"resourceTemplates"`
}
ListResourceTemplatesResult is the result for resources/templates/list.
type ListResourcesResult ¶
type ListResourcesResult struct {
Resources []Resource `json:"resources"`
}
ListResourcesResult is the result for resources/list.
type ListToolsResult ¶
type ListToolsResult struct {
Tools []Tool `json:"tools"`
}
ListToolsResult is the result for tools/list.
type LoggingCapability ¶
type LoggingCapability struct{}
LoggingCapability represents logging support.
type PromptsCapability ¶
type PromptsCapability struct {
ListChanged bool `json:"listChanged,omitempty"`
}
PromptsCapability represents prompts support.
type ReadResourceResult ¶
type ReadResourceResult struct {
Contents []ResourceContent `json:"contents"`
}
ReadResourceResult is the result for resources/read.
type Resource ¶
type Resource struct {
URI string `json:"uri"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
MimeType string `json:"mimeType,omitempty"`
}
Resource represents an MCP Resource definition.
type ResourceContent ¶
type ResourceContent struct {
URI string `json:"uri"`
MimeType string `json:"mimeType,omitempty"`
Text string `json:"text,omitempty"`
Blob string `json:"blob,omitempty"`
}
ResourceContent represents the content of a read resource.
type ResourceTemplate ¶
type ResourceTemplate struct {
URITemplate string `json:"uriTemplate"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
MimeType string `json:"mimeType,omitempty"`
}
ResourceTemplate represents an MCP Resource Template definition.
type ResourcesCapability ¶
type ResourcesCapability struct {
Subscribe bool `json:"subscribe,omitempty"`
ListChanged bool `json:"listChanged,omitempty"`
}
ResourcesCapability represents resources support.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server handles Model Context Protocol (MCP) communication over HTTP/SSE.
func NewServer ¶
func NewServer(deps *registry.Dependencies) *Server
NewServer creates a new MCP server instance.
func (*Server) HandleMessages ¶
func (s *Server) HandleMessages(w http.ResponseWriter, r *http.Request)
HandleMessages receives JSON-RPC messages from the agent.
type ServerCapabilities ¶
type ServerCapabilities struct {
Logging *LoggingCapability `json:"logging,omitempty"`
Prompts *PromptsCapability `json:"prompts,omitempty"`
Resources *ResourcesCapability `json:"resources,omitempty"`
Tools *ToolsCapability `json:"tools,omitempty"`
}
ServerCapabilities represents capabilities of the server.
type ServerInfo ¶
ServerInfo represents basic info about this server.
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
InputSchema map[string]any `json:"inputSchema"`
Meta *ToolMeta `json:"_meta,omitempty"`
}
Tool represents an MCP Tool definition.
type ToolMeta ¶
type ToolMeta struct {
UI *ToolMetaUI `json:"ui,omitempty"`
}
ToolMeta represents the metadata wrapper for a tool.
type ToolMetaUI ¶
type ToolMetaUI struct {
ResourceURI string `json:"resourceUri"`
}
ToolMetaUI represents the UI metadata for a tool.
type ToolsCapability ¶
type ToolsCapability struct {
ListChanged bool `json:"listChanged,omitempty"`
}
ToolsCapability represents tools support.