Documentation
¶
Overview ¶
Package mcpscripted provides an MCP server whose tool results a scenario scripts, so a policy that reads tool results can be tested on every shape a server may send. The SDK-backed server in services/mcp answers only well-formed results; this one also answers JSON-RPC errors, non-2xx statuses, bodies that are not JSON-RPC, and server-sent events with progress notifications before the result.
It is reached at http://testbench:3021/<partition>/mcp and records every request, so a scenario can assert whether a call reached the server: GET /<partition>/test/requests returns {"count": n, "requests": [{"method", "tool", "arguments"}, ...]}, oldest first.
Every tool name is accepted. A tools/call's arguments script the reply:
- text: the text of the result (default "ok"). It can carry jev:<key>=<value> markers, so the Jev answers follow the result a policy screens.
- repeat: how many times text is repeated, for a large result (default 1). The repeated text may be at most MaxResultBytes.
- shape: what the server sends (default "text"): text a result with one text block structured a result with the text in structuredContent and no content blocks resource a result with the text in an embedded resource image a result with one image block and no text rpc-error HTTP 200 with a JSON-RPC error whose message is the text http-error HTTP 500 with the text as a plain-text body not-jsonrpc HTTP 200 with the text as a plain-text body events server-sent events: a text result, after two progress notifications when the request carries params._meta.progressToken
Index ¶
Constants ¶
const ( ShapeText = "text" ShapeStructured = "structured" ShapeResource = "resource" ShapeImage = "image" ShapeRPCError = "rpc-error" ShapeHTTPError = "http-error" ShapeNotJSONRPC = "not-jsonrpc" ShapeEvents = "events" )
Shapes a tools/call's "shape" argument selects.
const MaxResultBytes = 1 << 20
MaxResultBytes bounds the text a call's arguments can ask for, after repeat, so one request cannot exhaust the shared testbench process.
const Path = "/mcp"
Path is the MCP endpoint path, after the partition.
const Port = 3021
Port is the container port used by the testbench.
const SessionID = "mcp-scripted-session"
SessionID is the Mcp-Session-Id the server returns from initialize.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Request ¶
type Request struct {
Method string `json:"method"`
Tool string `json:"tool,omitempty"`
Arguments json.RawMessage `json:"arguments,omitempty"`
}
Request is one recorded request to the MCP endpoint.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements testbench.Service and testbench.Partitioned.
func (*Service) PartitionKey ¶
PartitionKey returns the partitioning strategy used by this stateful service.