Documentation ¶
Index ¶
- type Server
- func (s *Server) CallTool(ctx context.Context, params mcp.ToolsCallParams, ...) (mcp.ToolResult, error)
- func (s Server) Close()
- func (s *Server) CompletesPrompt(_ context.Context, params mcp.CompletionCompleteParams, ...) (mcp.CompletionResult, error)
- func (s *Server) CompletesResourceTemplate(_ context.Context, params mcp.CompletionCompleteParams, ...) (mcp.CompletionResult, error)
- func (s *Server) GetPrompt(_ context.Context, params mcp.PromptsGetParams, _ mcp.RequestClientFunc) (mcp.PromptResult, error)
- func (s Server) Info() mcp.Info
- func (s *Server) ListPrompts(context.Context, mcp.PromptsListParams, mcp.RequestClientFunc) (mcp.PromptList, error)
- func (s *Server) ListResourceTemplates(_ context.Context, _ mcp.ResourcesTemplatesListParams, _ mcp.RequestClientFunc) ([]mcp.ResourceTemplate, error)
- func (s *Server) ListResources(_ context.Context, params mcp.ResourcesListParams, _ mcp.RequestClientFunc) (mcp.ResourceList, error)
- func (s *Server) ListTools(context.Context, mcp.ToolsListParams, mcp.RequestClientFunc) (mcp.ToolList, error)
- func (s *Server) LogStreams() <-chan mcp.LogParams
- func (s *Server) ProgressReports() <-chan mcp.ProgressParams
- func (s *Server) ReadResource(_ context.Context, params mcp.ResourcesReadParams, _ mcp.RequestClientFunc) (mcp.Resource, error)
- func (s Server) RequireRootsListClient() bool
- func (s Server) RequireSamplingClient() bool
- func (s *Server) ResourceSubscribedUpdates() <-chan string
- func (s *Server) SetLogLevel(level mcp.LogLevel)
- func (s *Server) SubscribeResource(params mcp.ResourcesSubscribeParams)
- func (s *Server) UnsubscribeResource(params mcp.ResourcesSubscribeParams)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶ added in v0.2.0
type Server struct {
// contains filtered or unexported fields
}
Server implements a comprehensive test server that exercises all features of the MCP protocol. It provides implementations of prompts, tools, resources, and sampling capabilities primarily for testing MCP client implementations.
Server maintains subscriptions for resource updates and supports progress tracking and multi-level logging through dedicated channels. While not intended for production use, it serves as both a reference implementation and testing tool for MCP protocol features.
func NewServer ¶ added in v0.2.0
func NewServer() *Server
NewServer creates a new test server that implements all MCP protocol features. It initializes internal state and starts background tasks for simulating resource updates.
The server starts with debug-level logging and supports concurrent resource subscriptions through thread-safe operations. Resource updates are simulated via background goroutines to facilitate testing of client subscription handling.
Callers must call Close when finished to properly cleanup background tasks and release resources.
func (*Server) CallTool ¶ added in v0.2.0
func (s *Server) CallTool( ctx context.Context, params mcp.ToolsCallParams, requestClient mcp.RequestClientFunc, ) (mcp.ToolResult, error)
CallTool implements mcp.ToolServer interface.
func (Server) Close ¶ added in v0.2.0
func (s Server) Close()
Close closes the SSEServer and stops all background tasks.
func (*Server) CompletesPrompt ¶ added in v0.2.0
func (s *Server) CompletesPrompt( _ context.Context, params mcp.CompletionCompleteParams, _ mcp.RequestClientFunc, ) (mcp.CompletionResult, error)
CompletesPrompt implements mcp.PromptServer interface.
func (*Server) CompletesResourceTemplate ¶ added in v0.2.0
func (s *Server) CompletesResourceTemplate( _ context.Context, params mcp.CompletionCompleteParams, _ mcp.RequestClientFunc, ) (mcp.CompletionResult, error)
CompletesResourceTemplate implements mcp.ResourceServer interface.
func (*Server) GetPrompt ¶ added in v0.2.0
func (s *Server) GetPrompt( _ context.Context, params mcp.PromptsGetParams, _ mcp.RequestClientFunc, ) (mcp.PromptResult, error)
GetPrompt implements mcp.PromptServer interface.
func (*Server) ListPrompts ¶ added in v0.2.0
func (s *Server) ListPrompts(context.Context, mcp.PromptsListParams, mcp.RequestClientFunc) (mcp.PromptList, error)
ListPrompts implements mcp.PromptServer interface.
func (*Server) ListResourceTemplates ¶ added in v0.2.0
func (s *Server) ListResourceTemplates( _ context.Context, _ mcp.ResourcesTemplatesListParams, _ mcp.RequestClientFunc, ) ([]mcp.ResourceTemplate, error)
ListResourceTemplates implements mcp.ResourceServer interface.
func (*Server) ListResources ¶ added in v0.2.0
func (s *Server) ListResources( _ context.Context, params mcp.ResourcesListParams, _ mcp.RequestClientFunc, ) (mcp.ResourceList, error)
ListResources implements mcp.ResourceServer interface.
func (*Server) ListTools ¶ added in v0.2.0
func (s *Server) ListTools(context.Context, mcp.ToolsListParams, mcp.RequestClientFunc) (mcp.ToolList, error)
ListTools implements mcp.ToolServer interface.
func (*Server) LogStreams ¶ added in v0.2.0
LogStreams implements mcp.LogHandler interface.
func (*Server) ProgressReports ¶ added in v0.2.0
func (s *Server) ProgressReports() <-chan mcp.ProgressParams
ProgressReports implements mcp.ProgressReporter interface.
func (*Server) ReadResource ¶ added in v0.2.0
func (s *Server) ReadResource( _ context.Context, params mcp.ResourcesReadParams, _ mcp.RequestClientFunc, ) (mcp.Resource, error)
ReadResource implements mcp.ResourceServer interface.
func (Server) RequireRootsListClient ¶ added in v0.2.0
RequireRootsListClient implements mcp.Server interface.
func (Server) RequireSamplingClient ¶ added in v0.2.0
RequireSamplingClient implements mcp.Server interface.
func (*Server) ResourceSubscribedUpdates ¶ added in v0.2.0
ResourceSubscribedUpdates implements mcp.ResourceSubscribedUpdater interface.
func (*Server) SetLogLevel ¶ added in v0.2.0
SetLogLevel implements mcp.LogHandler interface.
func (*Server) SubscribeResource ¶ added in v0.2.0
func (s *Server) SubscribeResource(params mcp.ResourcesSubscribeParams)
SubscribeResource implements mcp.ResourceServer interface.
func (*Server) UnsubscribeResource ¶ added in v0.2.0
func (s *Server) UnsubscribeResource(params mcp.ResourcesSubscribeParams)
UnsubscribeResource implements mcp.ResourceServer interface.