server

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: MIT Imports: 14 Imported by: 958

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTestServer added in v0.2.0

func NewTestServer(server *MCPServer) *httptest.Server

NewTestServer creates a test server for testing purposes

func ServeStdio

func ServeStdio(server *MCPServer) error

ServeStdio creates a stdio server wrapper around an existing MCPServer

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)

type PromptHandlerFunc added in v0.5.0

type PromptHandlerFunc func(arguments map[string]string) (*mcp.GetPromptResult, error)

type ResourceHandlerFunc added in v0.5.0

type ResourceHandlerFunc func() ([]interface{}, error)

type ResourceTemplateHandlerFunc added in v0.5.0

type ResourceTemplateHandlerFunc func() (mcp.ResourceTemplate, error)

type SSEServer added in v0.2.0

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

func NewSSEServer added in v0.2.0

func NewSSEServer(server *MCPServer, baseURL string) *SSEServer

func (*SSEServer) SendEventToSession added in v0.2.0

func (s *SSEServer) SendEventToSession(
	sessionID string,
	event interface{},
) error

SendEventToSession sends an event to a specific session

func (*SSEServer) Shutdown added in v0.2.0

func (s *SSEServer) Shutdown(ctx context.Context) error

func (*SSEServer) Start added in v0.2.0

func (s *SSEServer) Start(addr string) error

type ServerOption added in v0.5.0

type ServerOption func(*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

func WithToolCapabilities added in v0.5.0

func WithToolCapabilities(listChanged bool) ServerOption

type StdioServer

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

StdioServer wraps a MCPServer and handles stdio communication

type ToolHandlerFunc added in v0.5.0

type ToolHandlerFunc func(arguments map[string]interface{}) (*mcp.CallToolResult, error)

Jump to

Keyboard shortcuts

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