mcp

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodInitialize    = "initialize"
	MethodInitialized   = "notifications/initialized"
	MethodToolsList     = "tools/list"
	MethodToolsCall     = "tools/call"
	MethodSearchTools   = "search_tools"
	MethodResourcesList = "resources/list"
	MethodResourcesRead = "resources/read"
	MethodPromptsList   = "prompts/list"
	MethodPromptsGet    = "prompts/get"
	MethodPing          = "ping"
	MethodShutdown      = "shutdown"
)
View Source
const (
	ErrCodeParseError     = -32700
	ErrCodeInvalidRequest = -32600
	ErrCodeMethodNotFound = -32601
	ErrCodeInvalidParams  = -32602
	ErrCodeInternalError  = -32603
	ErrCodeServerError    = -32000
)
View Source
const JSONRPCVersion = "2.0"

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregatedManifest

type AggregatedManifest struct {
	Tools     []Tool
	Resources []Resource
	Prompts   []Prompt
}

type ClientCapabilities

type ClientCapabilities struct {
	Roots    *RootsCapability          `json:"roots,omitempty"`
	Sampling *ClientSamplingCapability `json:"sampling,omitempty"`
}

type ClientInfo

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

type ClientSamplingCapability

type ClientSamplingCapability struct{}

type ContentBlock

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

type Error

type Error struct {
	Code    int             `json:"code"`
	Message string          `json:"message"`
	Data    json.RawMessage `json:"data,omitempty"`
}

func NewError

func NewError(code int, message string) *Error

func (*Error) Error

func (e *Error) Error() string

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(p *pool.StdioPool, logger *slog.Logger) *Handler

func NewHandlerWithToolStore

func NewHandlerWithToolStore(p *pool.StdioPool, logger *slog.Logger, store toolstore.Cache) *Handler

func (*Handler) HandleRequest

func (h *Handler) HandleRequest(ctx context.Context, req *Request) (*Response, error)

func (*Handler) ResetManifest

func (h *Handler) ResetManifest()

type HealthcheckCapability

type HealthcheckCapability struct{}

type InitializeParams

type InitializeParams struct {
	ProtocolVersion string             `json:"protocolVersion"`
	Capabilities    ClientCapabilities `json:"capabilities"`
	ClientInfo      ClientInfo         `json:"clientInfo"`
}

type InitializeResult

type InitializeResult struct {
	ProtocolVersion string             `json:"protocolVersion"`
	Capabilities    ServerCapabilities `json:"capabilities"`
	ServerInfo      ServerInfo         `json:"serverInfo"`
}

type MCPServerInstance

type MCPServerInstance struct {
	// contains filtered or unexported fields
}

func NewMCPServerInstance

func NewMCPServerInstance(logger *slog.Logger) *MCPServerInstance

func (*MCPServerInstance) GetServer

func (m *MCPServerInstance) GetServer() *server.MCPServer

func (*MCPServerInstance) ServeSSE

func (m *MCPServerInstance) ServeSSE(addr string) error

func (*MCPServerInstance) ServeStdio

func (m *MCPServerInstance) ServeStdio() error

func (*MCPServerInstance) ServeStreamableHTTP

func (m *MCPServerInstance) ServeStreamableHTTP(addr string) error

func (*MCPServerInstance) SetStdioPool

func (m *MCPServerInstance) SetStdioPool(p *pool.StdioPool)

func (*MCPServerInstance) SetupGatewayTools

func (m *MCPServerInstance) SetupGatewayTools()

type ParamInfo

type ParamInfo struct {
	Name        string
	Type        string
	IsRequired  bool
	Description string
}

type Prompt

type Prompt struct {
	Name        string           `json:"name"`
	Description string           `json:"description,omitempty"`
	Arguments   []PromptArgument `json:"arguments,omitempty"`
}

type PromptArgument

type PromptArgument struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Required    bool   `json:"required,omitempty"`
}

type PromptsCapability

type PromptsCapability struct {
	ListChanged bool `json:"listChanged,omitempty"`
}

type PromptsListParams

type PromptsListParams struct {
	Cursor string `json:"cursor,omitempty"`
}

type PromptsListResult

type PromptsListResult struct {
	Prompts    []Prompt `json:"prompts"`
	NextCursor string   `json:"nextCursor,omitempty"`
}

type Request

type Request struct {
	JSONRPC string          `json:"jsonrpc"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
	ID      interface{}     `json:"id"`
}

func (*Request) IsNotification

func (r *Request) IsNotification() bool

type Resource

type Resource struct {
	URI         string `json:"uri"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	MimeType    string `json:"mimeType,omitempty"`
}

type ResourcesCapability

type ResourcesCapability struct {
	Subscribe   bool `json:"subscribe,omitempty"`
	ListChanged bool `json:"listChanged,omitempty"`
}

type ResourcesListParams

type ResourcesListParams struct {
	Cursor string `json:"cursor,omitempty"`
}

type ResourcesListResult

type ResourcesListResult struct {
	Resources  []Resource `json:"resources"`
	NextCursor string     `json:"nextCursor,omitempty"`
}

type Response

type Response struct {
	JSONRPC string          `json:"jsonrpc"`
	Result  json.RawMessage `json:"result,omitempty"`
	Error   *Error          `json:"error,omitempty"`
	ID      interface{}     `json:"id"`
}

type RootsCapability

type RootsCapability struct {
	ListChanged bool `json:"listChanged,omitempty"`
}

type ServerCapabilities

type ServerCapabilities struct {
	Tools     *ToolsCapability          `json:"tools,omitempty"`
	Resources *ResourcesCapability      `json:"resources,omitempty"`
	Prompts   *PromptsCapability        `json:"prompts,omitempty"`
	Sampling  *ServerSamplingCapability `json:"sampling,omitempty"`
	Health    *HealthcheckCapability    `json:"healthcheck,omitempty"`
}

type ServerInfo

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

type ServerSamplingCapability

type ServerSamplingCapability struct{}

type Tool

type Tool struct {
	Name        string          `json:"name"`
	Description string          `json:"description"`
	InputSchema json.RawMessage `json:"inputSchema"`
}

type ToolCache

type ToolCache struct {
	// contains filtered or unexported fields
}

type ToolsCallParams

type ToolsCallParams struct {
	Name      string          `json:"name"`
	Arguments json.RawMessage `json:"arguments,omitempty"`
}

type ToolsCallResult

type ToolsCallResult struct {
	Content []ContentBlock `json:"content"`
	IsError bool           `json:"isError,omitempty"`
}

type ToolsCapability

type ToolsCapability struct {
	ListChanged bool `json:"listChanged,omitempty"`
}

type ToolsListParams

type ToolsListParams struct {
	Cursor string `json:"cursor,omitempty"`
}

type ToolsListResult

type ToolsListResult struct {
	Tools      []Tool `json:"tools"`
	NextCursor string `json:"nextCursor,omitempty"`
}

Jump to

Keyboard shortcuts

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