mcptest

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mcptest is an MCP server over the Streamable HTTP transport that a test owns, on the loopback address, for the RepoPrompt reviewer route's tests (itd-6): no test reaches a real RepoPrompt or the network. It answers initialize, the initialized notification, tools/list, tools/call and the session's closing DELETE, and records what it was sent.

Index

Constants

View Source
const SessionID = "session-1"

SessionID is the session id the server assigns.

View Source
const Version = "2025-06-18"

Version is the protocol revision the server answers initialize with.

Variables

This section is empty.

Functions

func Start

func Start(t testing.TB, s *Server) string

Start serves s on the loopback address until the test ends and returns its MCP endpoint.

func TextResult

func TextResult(text string) any

TextResult is a tools/call result carrying text.

Types

type Call

type Call struct {
	Name      string
	Arguments map[string]any
}

Call is one tools/call the server took.

type Server

type Server struct {
	// Tools are the tools tools/list offers, each with the names of the
	// properties its input schema declares.
	Tools map[string][]string
	// Answer is the tools/call result; nil answers with the message echoed.
	Answer func(args map[string]any) any
	// Stream answers every request as an event stream rather than a JSON
	// body, with a notification and a keep-alive comment before the response.
	Stream bool
	// RPCError answers the named method with a JSON-RPC error.
	RPCError string
	// Delay holds the tools/call answer this long.
	Delay time.Duration
	// NoTools leaves the tools capability out of initialize.
	NoTools bool
	// ProtocolVersion is the revision initialize answers with; Version when
	// empty.
	ProtocolVersion string
	// Session is the session id initialize assigns; SessionID when empty.
	Session string
	// contains filtered or unexported fields
}

Server is the fake. Its zero value offers no tools.

func (*Server) Calls

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

Calls are the tools/call requests the server took.

func (*Server) Deleted

func (s *Server) Deleted() bool

Deleted reports whether the client closed the session it was assigned.

func (*Server) Headers

func (s *Server) Headers() []http.Header

Headers are the headers of each POST, in order.

func (*Server) Methods

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

Methods are the methods the server was sent, in order.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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