Documentation
¶
Overview ¶
Package testutil provides shared helpers for tool-handler tests.
The canonical pattern: a test stands up an MCP server with the tool under test registered, connects an in-memory client to it via mcp.NewInMemoryTransports (net.Pipe-backed), and drives the handler through the SDK's CallTool API. This exercises the full schema-validate → handler → response shape end-to-end without spawning the binary or hitting stdio. CLAUDE.md "Where things go" names this as the standard test pattern for Phase 1+ tools.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeStructured ¶
DecodeStructured re-encodes the SDK's CallToolResult.StructuredContent (a map[string]any after the JSON-RPC roundtrip) into the test's expected typed value. Tool tests use this to assert tool output shapes without hand-walking the map.
Types ¶
type Harness ¶
type Harness struct {
Client *mcp.ClientSession
// contains filtered or unexported fields
}
Harness pairs a connected client and server session for tool-handler tests. Close() tears both down; tests should defer it.