Documentation
¶
Overview ¶
Package mcptest connects an in-process MCP client to an mcpkit.Server and compares tool results with --format json golden files.
Index ¶
- func ErrorText(t testing.TB, res *mcp.CallToolResult) string
- func FileURI(path string) string
- func Indent(t testing.TB, envelope []byte) []byte
- func Items(t testing.TB, doc []byte, pointer string) []json.RawMessage
- func PageOf(t testing.TB, envelope []byte) *render.Page
- func Text(t testing.TB, res *mcp.CallToolResult) []byte
- type Client
- func (c *Client) Call(t testing.TB, tool string, args any) *mcp.CallToolResult
- func (c *Client) Golden(t testing.TB, tool string, args any, path string)
- func (c *Client) Pages(t testing.TB, tool string, args any) [][]byte
- func (c *Client) ServerInfo() *mcp.Implementation
- func (c *Client) Tools(t testing.TB) []*mcp.Tool
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 ¶
FileURI returns the file URI of a local path: /home/a is file:///home/a and C:\src is file:///C:/src.
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 ¶
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 ¶
Call calls a tool. A protocol error fails the test; a tool error is returned in the result.
func (*Client) Golden ¶
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 ¶
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.