mcptest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 11 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 connects an in-process MCP client to an mcpkit.Server and compares tool results with --format json golden files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorText

func ErrorText(t testing.TB, res *mcp.CallToolResult) string

ErrorText returns the message of a tool error, and fails the test for any other result.

func FileURI

func FileURI(path string) string

FileURI returns the file URI of a local path: /home/a is file:///home/a and C:\src is file:///C:/src.

func Indent

func Indent(t testing.TB, envelope []byte) []byte

Indent formats a compact envelope the way --format json writes it.

func Items

func Items(t testing.TB, doc []byte, pointer string) []json.RawMessage

Items returns the array at an RFC 6901 JSON pointer, such as "/data/tools/0/entries".

func PageOf

func PageOf(t testing.TB, envelope []byte) *render.Page

PageOf returns the page field of an envelope, or nil when the result wasn't split.

func Text

func Text(t testing.TB, res *mcp.CallToolResult) []byte

Text returns the text of a result that isn't a tool error.

Types

type Client

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

Client is an MCP client session connected to a server in the same process.

func Connect

func Connect(t testing.TB, s *mcpkit.Server, roots ...string) *Client

Connect serves s over the SDK's in-memory transport and connects a client to it. With roots, the client supports roots and lists those directories. Both ends close when the test ends.

func (*Client) Call

func (c *Client) Call(t testing.TB, tool string, args any) *mcp.CallToolResult

Call calls a tool. A protocol error fails the test; a tool error is returned in the result.

func (*Client) Golden

func (c *Client) Golden(t testing.TB, tool string, args any, path string)

Golden calls a tool and compares its result, indented, with the --format json output in the golden file at path. The result must fit in one page. Golden files belong to the CLI tests, so this never rewrites them.

func (*Client) Pages

func (c *Client) Pages(t testing.TB, tool string, args any) [][]byte

Pages calls a tool and follows next_cursor until the last page, returning every page.

func (*Client) ServerInfo

func (c *Client) ServerInfo() *mcp.Implementation

ServerInfo returns the name and version the server sent at initialization.

func (*Client) Tools

func (c *Client) Tools(t testing.TB) []*mcp.Tool

Tools lists the server's tools.

Jump to

Keyboard shortcuts

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