Documentation
¶
Overview ¶
Package server provides MCP (Model Control Protocol) server implementations.
Index ¶
- func NewTestServer(server *MCPServer) *httptest.Server
- func ServeStdio(server *MCPServer) error
- type MCPServer
- func (s *MCPServer) AddNotificationHandler(handler NotificationHandlerFunc)
- func (s *MCPServer) AddPrompt(name string, handler PromptHandlerFunc)
- func (s *MCPServer) AddResource(uri string, handler ResourceHandlerFunc)
- func (s *MCPServer) AddResourceTemplate(uriTemplate string, handler ResourceTemplateHandlerFunc)
- func (s *MCPServer) AddTool(tool mcp.Tool, handler ToolHandlerFunc)
- func (s *MCPServer) HandleMessage(ctx context.Context, message json.RawMessage) mcp.JSONRPCMessage
- type NotificationHandlerFunc
- type PromptHandlerFunc
- type ResourceHandlerFunc
- type ResourceTemplateHandlerFunc
- type SSEServer
- type ServerOption
- type StdioServer
- type ToolHandlerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTestServer ¶ added in v0.2.0
NewTestServer creates a test server for testing purposes
func ServeStdio ¶
ServeStdio is a convenience function that creates and starts a StdioServer with os.Stdin and os.Stdout
Types ¶
type MCPServer ¶
type MCPServer struct {
// contains filtered or unexported fields
}
func NewMCPServer ¶ added in v0.5.0
func NewMCPServer( name, version string, opts ...ServerOption, ) *MCPServer
func (*MCPServer) AddNotificationHandler ¶ added in v0.5.0
func (s *MCPServer) AddNotificationHandler( handler NotificationHandlerFunc, )
func (*MCPServer) AddPrompt ¶ added in v0.5.0
func (s *MCPServer) AddPrompt(name string, handler PromptHandlerFunc)
func (*MCPServer) AddResource ¶ added in v0.5.0
func (s *MCPServer) AddResource(uri string, handler ResourceHandlerFunc)
func (*MCPServer) AddResourceTemplate ¶ added in v0.5.0
func (s *MCPServer) AddResourceTemplate( uriTemplate string, handler ResourceTemplateHandlerFunc, )
func (*MCPServer) AddTool ¶ added in v0.5.0
func (s *MCPServer) AddTool(tool mcp.Tool, handler ToolHandlerFunc)
func (*MCPServer) HandleMessage ¶ added in v0.5.0
func (s *MCPServer) HandleMessage( ctx context.Context, message json.RawMessage, ) mcp.JSONRPCMessage
type NotificationHandlerFunc ¶ added in v0.5.0
type NotificationHandlerFunc func(notification mcp.JSONRPCNotification)
NotificationHandlerFunc handles incoming notifications.
type PromptHandlerFunc ¶ added in v0.5.0
type PromptHandlerFunc func(arguments map[string]string) (*mcp.GetPromptResult, error)
PromptHandlerFunc handles prompt requests with given arguments.
type ResourceHandlerFunc ¶ added in v0.5.0
type ResourceHandlerFunc func() ([]interface{}, error)
ResourceHandlerFunc is a function that returns resource contents.
type ResourceTemplateHandlerFunc ¶ added in v0.5.0
type ResourceTemplateHandlerFunc func() (mcp.ResourceTemplate, error)
ResourceTemplateHandlerFunc is a function that returns a resource template.
type SSEServer ¶ added in v0.2.0
type SSEServer struct {
// contains filtered or unexported fields
}
SSEServer implements a Server-Sent Events (SSE) based MCP server. It provides real-time communication capabilities over HTTP using the SSE protocol.
func NewSSEServer ¶ added in v0.2.0
func (*SSEServer) SendEventToSession ¶ added in v0.2.0
SendEventToSession sends an event to a specific session
type ServerOption ¶ added in v0.5.0
type ServerOption func(*MCPServer)
ServerOption is a function that configures an MCPServer.
func WithLogging ¶ added in v0.5.0
func WithLogging() ServerOption
func WithPromptCapabilities ¶ added in v0.5.0
func WithPromptCapabilities(listChanged bool) ServerOption
func WithResourceCapabilities ¶ added in v0.5.0
func WithResourceCapabilities(subscribe, listChanged bool) ServerOption
type StdioServer ¶
type StdioServer struct {
// contains filtered or unexported fields
}
StdioServer wraps a MCPServer and handles stdio communication StdioServer wraps a MCPServer and handles stdio communication. It provides a simple way to create command-line MCP servers that communicate via standard input/output streams.
func NewStdioServer ¶ added in v0.5.5
func NewStdioServer(server *MCPServer) *StdioServer
NewStdioServer creates a new stdio server wrapper around an MCPServer
func (*StdioServer) Listen ¶ added in v0.5.5
Listen starts listening for messages on the provided input and writes responses to the provided output
func (*StdioServer) SetErrorLogger ¶ added in v0.5.5
func (s *StdioServer) SetErrorLogger(logger *log.Logger)
SetErrorLogger allows configuring where errors are logged
type ToolHandlerFunc ¶ added in v0.5.0
type ToolHandlerFunc func(arguments map[string]interface{}) (*mcp.CallToolResult, error)
ToolHandlerFunc handles tool calls with given arguments.