Documentation
¶
Overview ¶
Package mcpvet is a contract-testing and drift-detection tool for Model Context Protocol (MCP) servers: it snapshots a server's tool surface into a lockfile so CI fails when tools, descriptions, or input schemas silently change, and it fuzzes each tool with inputs generated from that tool's own JSON Schema — valid, boundary, and hostile — to find handlers that panic, hang, or accept what their schema forbids.
Schemas are handled as decoded JSON (`map[string]any`) rather than a typed model, so mcpvet works against any server's schema, not only the drafts a particular SDK understands.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Case ¶
type Case struct {
Name string // e.g. "valid", "missing:city", "hostile:oversize:name"
Args map[string]any // the tool arguments
Valid bool // true if the schema should accept these args
}
Case is one generated tool input plus what mcpvet expects the server to do with it.
func GenerateCases ¶
GenerateCases produces valid, boundary, and hostile inputs for a tool from its input schema. Valid cases exercise the happy path; boundary cases probe min/max edges; hostile cases (type confusion, oversized strings, missing required fields, unexpected extra fields) probe input handling. Every hostile/missing case that the server *accepts* is a finding.
type Drift ¶
type Drift struct {
Tool string `json:"tool"`
Kind string `json:"kind"` // added, removed, description_changed, schema_changed, required_changed
Detail string `json:"detail"`
}
Drift is one difference between a stored lock and the live server.
type Finding ¶
type Finding struct {
Tool string `json:"tool"`
Case string `json:"case"`
Kind string `json:"kind"` // crash, hang, accepted_invalid, protocol_error
Detail string `json:"detail"`
Breaking bool `json:"breaking"`
}
Finding is one problem mcpvet found while exercising a server.
type Lock ¶
type Lock struct {
Version int `json:"version"`
Server ServerInfo `json:"server"`
Tools []ToolLock `json:"tools"`
}
Lock is the snapshot of a server's tool surface — the "package-lock" for an agent's tools. Descriptions are hashed as well as schemas: a silently rewritten description is a prompt-injection vector even when the schema is unchanged.
func BuildLock ¶
func BuildLock(server ServerInfo, tools []ToolSurface) Lock
BuildLock snapshots the given tools.
type Options ¶
type Options struct {
// Command and Args launch a stdio MCP server (e.g. "npx", "-y", "some-mcp").
Command string
Args []string
// Timeout bounds each individual tool call; a call that exceeds it is a
// "hang" finding.
Timeout time.Duration
// Fuzz enables generated-input testing. Without it, mcpvet only snapshots
// and diffs the tool surface (safe against servers with side effects).
Fuzz bool
// SkipTools are tool names never to call (destructive tools).
SkipTools []string
}
Options configure a vet run.
type Report ¶
type Report struct {
Server ServerInfo `json:"server"`
ToolCount int `json:"tool_count"`
CaseCount int `json:"case_count"`
Findings []Finding `json:"findings"`
Drifts []Drift `json:"drifts,omitempty"`
Lock Lock `json:"-"`
}
Report is the outcome of a vet run.
type ServerInfo ¶
ServerInfo identifies the server that produced the lock.
type ToolLock ¶
type ToolLock struct {
Name string `json:"name"`
DescriptionHash string `json:"description_sha256"`
DescriptionLen int `json:"description_len"`
SchemaHash string `json:"input_schema_sha256"`
SchemaShape string `json:"input_schema_shape"`
Required string `json:"required,omitempty"`
}
ToolLock is one tool's locked surface.
type ToolSurface ¶
ToolSurface is the part of an MCP tool mcpvet inspects.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
mcpvet
command
Command mcpvet is contract testing and drift detection for MCP servers.
|
Command mcpvet is contract testing and drift detection for MCP servers. |
|
internal
|
|
|
testserver
command
Command testserver is a deliberately flawed MCP server used by mcpvet's own tests and demo: one well-behaved tool, one that accepts input its schema forbids, one that hangs, and one whose description changes when the MCPVET_DEMO_DRIFT environment variable is set.
|
Command testserver is a deliberately flawed MCP server used by mcpvet's own tests and demo: one well-behaved tool, one that accepts input its schema forbids, one that hangs, and one whose description changes when the MCPVET_DEMO_DRIFT environment variable is set. |