Help us shape the future of Go! Take the 2026 Go Developer Survey

conformance

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package conformance holds what the official MCP conformance suite (github.com/modelcontextprotocol/conformance) needs from a server under test and nothing a released binary should carry: the suite's named fixture tools, resources and prompts, a loopback-only Streamable HTTP host, and a recovering middleware so one broken handler cannot cost the evidence for every scenario after it.

Nothing here is platform-specific. A server imports this package only from files behind its own `conformance` build tag, which is what keeps the HTTP listener out of the product build.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotLoopback = errors.New("conformance host refuses to bind: loopback only")

ErrNotLoopback reports a listen address that is not loopback.

Functions

func RecoverMiddleware

func RecoverMiddleware(logger *slog.Logger) mcp.Middleware

RecoverMiddleware turns a panicking handler into a JSON-RPC error instead of a dead process.

It belongs on the conformance host and not on a production server. Here the whole point is to finish the run and produce results, so one broken handler must not cost the evidence for every scenario after it: a run whose failures might mean "the server is not there" proves nothing. A production session makes the opposite trade, because a panic there means the engine's state is unknown.

func RequireLoopback

func RequireLoopback(addr string) error

RequireLoopback refuses any address that is not loopback.

The host has no authentication and no authorization: it is a test fixture that serves the full tool manifest of a desktop-automation server. Binding it to a routable interface would publish that manifest, and the ability to call it, to the network. The check is here rather than in a CLI so no future caller can route around it.

func Serve

func Serve(ctx context.Context, server *mcp.Server, addr, path string, logger *slog.Logger) error

Serve exposes server over Streamable HTTP at addr+path until ctx ends.

The bound URL is printed to stdout, which is the runner's contract: with an ephemeral port the address is only known here and the suite needs it for --url. Logs go to the logger (stderr by convention) so stdout stays clean.

The transport is stateless: protocol 2026-07-28 removed protocol-level sessions, and the suite's stateless scenarios exercise exactly that. DNS-rebinding protection is left at its default (on); the suite has a scenario for it because a localhost server without HTTPS or auth is the case that needs it.

Types

type AuditDestination

type AuditDestination struct{ Logger *slog.Logger }

AuditDestination writes the hash-chained audit entries to the logger, so a conformance run leaves the same transparency trail a real session would and the entries land in the workflow log next to the suite's output.

func (*AuditDestination) Close

func (*AuditDestination) Close() error

func (*AuditDestination) Flush

func (*AuditDestination) Flush() error

func (*AuditDestination) Write

func (s *AuditDestination) Write(e audit.AuditEntry) error

type Fixtures

type Fixtures struct {
	Tools     []*mcp.Tool
	Prompts   []*mcp.Prompt
	Resources []*mcp.Resource
}

Fixtures reports what was registered, so the rug-pull baselines can be pinned over the manifest the server will actually serve.

func RegisterFixtures

func RegisterFixtures(server *mcp.Server, enabled bool) Fixtures

RegisterFixtures adds the suite's fixtures when enabled, and reports what it added. With enabled false it registers nothing — that is the product pass, where the suite measures the manifest this server really ships.

type Probe

type Probe struct{}

Probe satisfies signals.SystemProbe without a desktop engine.

The conformance host drives no real desktop, so the default policy's signals have nothing to read. Every method returns a zero value, which makes run-context report a non-interactive session and therefore fail. Under the default policy that is a warning and nothing more: the middleware is exercised on every request, and no request is refused.

func (*Probe) DeviceIdentity

func (*Probe) DeviceIdentity() signals.DeviceIdentity

func (*Probe) DomainSKU

func (*Probe) DomainSKU() (signals.DomainSKU, error)

func (*Probe) IsAdmin

func (*Probe) IsAdmin() bool

func (*Probe) RunContext

func (*Probe) RunContext() signals.RunContext

func (*Probe) RunShell

func (*Probe) RunShell(context.Context, string) (string, error)

Jump to

Keyboard shortcuts

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