everything

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddArgs added in v0.3.1

type AddArgs struct {
	A float64 `json:"a"`
	B float64 `json:"b"`
}

AddArgs is the arguments for the add tool.

type EchoArgs added in v0.3.1

type EchoArgs struct {
	Message string `json:"message"`
}

EchoArgs is the arguments for the echo tool.

type LongRunningOperationArgs added in v0.3.1

type LongRunningOperationArgs struct {
	Duration float64 `json:"duration"`
	Steps    float64 `json:"steps"`
}

LongRunningOperationArgs is the arguments for the longRunningOperation tool.

type SampleLLMArgs added in v0.3.1

type SampleLLMArgs struct {
	Prompt    string  `json:"prompt"`
	MaxTokens float64 `json:"maxTokens"`
}

SampleLLMArgs is the arguments for the sampleLLM tool.

type Server

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

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

func (s *Server) CallTool(
	_ context.Context,
	params mcp.CallToolParams,
	progressReporter mcp.ProgressReporter,
	requestClient mcp.RequestClientFunc,
) (mcp.CallToolResult, error)

CallTool implements mcp.ToolServer interface.

func (Server) Close

func (s Server) Close()

Close closes the SSEServer and stops all background tasks.

func (*Server) CompletesPrompt

func (s *Server) CompletesPrompt(
	_ context.Context,
	params mcp.CompletesCompletionParams,
	_ mcp.RequestClientFunc,
) (mcp.CompletionResult, error)

CompletesPrompt implements mcp.PromptServer interface.

func (*Server) CompletesResourceTemplate

func (s *Server) CompletesResourceTemplate(
	_ context.Context,
	params mcp.CompletesCompletionParams,
	_ mcp.RequestClientFunc,
) (mcp.CompletionResult, error)

CompletesResourceTemplate implements mcp.ResourceServer interface.

func (*Server) GetPrompt

func (s *Server) GetPrompt(
	_ context.Context,
	params mcp.GetPromptParams,
	_ mcp.ProgressReporter,
	_ mcp.RequestClientFunc,
) (mcp.GetPromptResult, error)

GetPrompt implements mcp.PromptServer interface.

func (Server) Info

func (s Server) Info() mcp.Info

Info implements mcp.Server interface.

func (*Server) ListPrompts

func (s *Server) ListPrompts(
	context.Context,
	mcp.ListPromptsParams,
	mcp.ProgressReporter,
	mcp.RequestClientFunc,
) (mcp.ListPromptResult, error)

ListPrompts implements mcp.PromptServer interface.

func (*Server) ListResourceTemplates

func (s *Server) ListResourceTemplates(
	_ context.Context,
	_ mcp.ListResourceTemplatesParams,
	_ mcp.ProgressReporter,
	_ mcp.RequestClientFunc,
) (mcp.ListResourceTemplatesResult, error)

ListResourceTemplates implements mcp.ResourceServer interface.

func (*Server) ListResources

func (s *Server) ListResources(
	_ context.Context,
	params mcp.ListResourcesParams,
	_ mcp.ProgressReporter,
	_ mcp.RequestClientFunc,
) (mcp.ListResourcesResult, error)

ListResources implements mcp.ResourceServer interface.

func (*Server) ListTools

func (s *Server) ListTools(
	context.Context,
	mcp.ListToolsParams,
	mcp.ProgressReporter,
	mcp.RequestClientFunc,
) (mcp.ListToolsResult, error)

ListTools implements mcp.ToolServer interface.

func (*Server) LogStreams

func (s *Server) LogStreams() iter.Seq[mcp.LogParams]

LogStreams implements mcp.LogHandler interface.

func (*Server) ReadResource

func (s *Server) ReadResource(
	_ context.Context,
	params mcp.ReadResourceParams,
	_ mcp.ProgressReporter,
	_ mcp.RequestClientFunc,
) (mcp.ReadResourceResult, error)

ReadResource implements mcp.ResourceServer interface.

func (Server) RequireRootsListClient

func (s Server) RequireRootsListClient() bool

RequireRootsListClient implements mcp.Server interface.

func (Server) RequireSamplingClient

func (s Server) RequireSamplingClient() bool

RequireSamplingClient implements mcp.Server interface.

func (*Server) SetLogLevel

func (s *Server) SetLogLevel(level mcp.LogLevel)

SetLogLevel implements mcp.LogHandler interface.

func (*Server) SubscribeResource

func (s *Server) SubscribeResource(params mcp.SubscribeResourceParams)

SubscribeResource implements mcp.ResourceSubscriptionHandler interface.

func (*Server) SubscribedResourceUpdates

func (s *Server) SubscribedResourceUpdates() iter.Seq[string]

SubscribedResourceUpdates implements mcp.ResourceSubscriptionHandler interface.

func (*Server) UnsubscribeResource added in v0.3.1

func (s *Server) UnsubscribeResource(params mcp.UnsubscribeResourceParams)

UnsubscribeResource implements mcp.ResourceSubscriptionHandler interface.

Jump to

Keyboard shortcuts

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