mcp

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
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 Content

type Content struct {
	Type string `json:"type"`
	Text string `json:"text,omitempty"`
}

Content represents a piece of content in a tool result.

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.

func (*Server) HandleSSE

func (s *Server) HandleSSE(w http.ResponseWriter, r *http.Request)

HandleSSE establishes the Server-Sent Events connection.

func (*Server) SendMessage

func (s *Server) SendMessage(sessionID string, msg any) error

SendMessage pushes a message to a specific agent session.

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

type ServerInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL