testserver

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package testserver provides reusable HTTP MCP component fixtures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Name      string
	Arguments json.RawMessage
}

Call records one tools/call request received by the component.

type Options

type Options struct {
	Tools             []Tool
	Prompts           []Prompt
	Resources         []Resource
	ResourceTemplates []ResourceTemplate
	PageSize          int
	Headers           map[string]string
	Subscribe         func(context.Context, *mcp.SubscribeRequest) error
	Unsubscribe       func(context.Context, *mcp.UnsubscribeRequest) error
	Stateful          bool
}

Options configures a fixture server.

type Prompt

type Prompt struct {
	Definition *mcp.Prompt
	Handler    mcp.PromptHandler
}

Prompt pairs an MCP prompt definition with its handler.

type PromptGet

type PromptGet struct {
	Name      string
	Arguments map[string]string
}

PromptGet records one prompts/get request received by the component.

type Resource

type Resource struct {
	Definition *mcp.Resource
	Handler    mcp.ResourceHandler
}

Resource pairs an MCP resource definition with its handler.

type ResourceTemplate

type ResourceTemplate struct {
	Definition *mcp.ResourceTemplate
	Handler    mcp.ResourceHandler
}

ResourceTemplate pairs an MCP resource-template definition with its handler.

type Server

type Server struct {
	URL string
	// contains filtered or unexported fields
}

Server is a stateless Streamable HTTP MCP component fixture.

func New

func New(tb testing.TB, opts Options) *Server

New starts a current-protocol component fixture.

func (*Server) Calls

func (s *Server) Calls() []Call

Calls returns a copy of recorded tool calls.

func (*Server) Close

func (s *Server) Close()

Close stops the fixture server.

func (*Server) Deletes

func (s *Server) Deletes() int

Deletes returns the number of downstream session-termination requests.

func (*Server) Discoveries

func (s *Server) Discoveries() int

Discoveries returns the number of downstream client sessions negotiated.

func (*Server) PromptGets

func (s *Server) PromptGets() []PromptGet

PromptGets returns a copy of recorded prompt requests.

func (*Server) Reads

func (s *Server) Reads() []string

Reads returns a copy of recorded resource URIs.

func (*Server) Subscribes

func (s *Server) Subscribes() []string

Subscribes returns a copy of recorded resource subscription URIs.

func (*Server) Unsubscribes

func (s *Server) Unsubscribes() []string

Unsubscribes returns a copy of recorded resource unsubscription URIs.

type Tool

type Tool struct {
	Definition *mcp.Tool
	Handler    mcp.ToolHandler
}

Tool pairs an MCP tool definition with its raw handler.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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