testing

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallRecord

type CallRecord struct {
	ToolName  string
	Arguments map[string]any
	Timestamp time.Time
}

CallRecord tracks a tool call

type MockServer

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

MockServer implements a mock MCP server for testing

func NewMockServer

func NewMockServer(config MockServerConfig) *MockServer

NewMockServer creates a new mock MCP server

func (*MockServer) ClearCallHistory

func (ms *MockServer) ClearCallHistory()

ClearCallHistory clears the call history

func (*MockServer) GetCallCount

func (ms *MockServer) GetCallCount(toolName string) int

GetCallCount returns the number of calls to a specific tool

func (*MockServer) GetCallHistory

func (ms *MockServer) GetCallHistory() []CallRecord

GetCallHistory returns the call history

func (*MockServer) SimulateDisconnect

func (ms *MockServer) SimulateDisconnect()

SimulateDisconnect simulates server disconnection

func (*MockServer) SimulateReconnect

func (ms *MockServer) SimulateReconnect()

SimulateReconnect simulates server reconnection

func (*MockServer) Start

func (ms *MockServer) Start(ctx context.Context, transport mcp.Transport) error

Start starts the mock server with the given transport

type MockServerConfig

type MockServerConfig struct {
	ServerName    string
	Version       string
	Tools         []MockTool
	SimulateDelay time.Duration
	FailOnCall    bool
}

MockServerConfig holds configuration for a mock server

type MockTool

type MockTool struct {
	Name        string
	Description string
	InputSchema map[string]any
	Handler     func(ctx context.Context, args map[string]any) (*mcp.CallToolResult, error)
}

MockTool represents a configurable mock tool

func CreateCalculatorTool

func CreateCalculatorTool() MockTool

CreateCalculatorTool creates a tool that performs simple calculations

func CreateDelayTool

func CreateDelayTool(delay time.Duration) MockTool

CreateDelayTool creates a tool that responds after a delay

func CreateEchoTool

func CreateEchoTool(name string) MockTool

CreateEchoTool creates a simple echo tool that returns its input

func CreateToolWithDotsInName

func CreateToolWithDotsInName() MockTool

CreateToolWithDotsInName creates a tool with dots in its name

Jump to

Keyboard shortcuts

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