Documentation
¶
Overview ¶
Package mcpfixture provides deterministic official-MCP-SDK fixtures for runtime and OAuth integration tests.
Index ¶
Constants ¶
const ( // ModernProtocolVersion is the latest MCP revision exercised by the fixture. ModernProtocolVersion = "2026-07-28" // LegacyProtocolVersion is the legacy revision used after negotiation fallback. LegacyProtocolVersion = "2025-11-25" // ToolListTTLMs is the deterministic cache hint returned by modern tools/list. ToolListTTLMs = 60_000 )
const ( // AuthorizationCode is the deterministic authorization code returned by the fixture. AuthorizationCode = "mcpfixture-authorization-code" // AccessToken is the deterministic access token returned by the fixture. // #nosec G101 -- deterministic test-fixture value, never a credential. AccessToken = "mcpfixture-access-token" // RefreshToken is the deterministic refresh token returned by the fixture. // #nosec G101 -- deterministic test-fixture value, never a credential. RefreshToken = "mcpfixture-refresh-token" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fixture ¶
type Fixture struct {
// contains filtered or unexported fields
}
Fixture exposes one deterministic official Go SDK MCP server profile.
func MustNew ¶
MustNew constructs a fixture and panics only for a programmer-supplied invalid profile.
func (*Fixture) RunStdio ¶
func (f *Fixture) RunStdio(ctx context.Context, input io.ReadCloser, output io.WriteCloser) error
RunStdio serves newline-delimited MCP JSON over input and output until ctx ends.
func (*Fixture) StreamableHTTPHandler ¶
StreamableHTTPHandler returns a stateless, JSON-response Streamable HTTP handler.
type OAuthConfig ¶
type OAuthConfig struct {
MCPPath string
Scopes []string
StepUpScope string
CallbackIssuer string
AuthorizationResponseIssParameterSupported bool
ClientIDMetadataDocumentSupported bool
}
OAuthConfig configures the optional local OAuth surface around an MCP fixture.
type OAuthEndpoints ¶
type OAuthEndpoints struct {
MCPURL string
ProtectedResourceURL string
IssuerURL string
AuthorizationURL string
TokenURL string
RegistrationURL string
ClientMetadataURL string
}
OAuthEndpoints identifies the local, dynamically generated OAuth endpoints.
type OAuthHTTPServer ¶
type OAuthHTTPServer struct {
Server *httptest.Server
Endpoints OAuthEndpoints
// contains filtered or unexported fields
}
OAuthHTTPServer combines a fixture MCP endpoint and a local OAuth authority.
func StartOAuthHTTP ¶
func StartOAuthHTTP(t testing.TB, fixture *Fixture, config OAuthConfig) *OAuthHTTPServer
StartOAuthHTTP starts a fixture with protected-resource metadata, authorization, token, dynamic-registration, client-metadata, refresh, mix-up, and step-up surfaces.
func (*OAuthHTTPServer) Requests ¶
func (s *OAuthHTTPServer) Requests() OAuthRequests
Requests returns independent snapshots of every received OAuth boundary request.
type OAuthRequests ¶
type OAuthRequests struct {
MCPHeaders []http.Header
Authorization []url.Values
Token []url.Values
Registration []map[string]any
}
OAuthRequests records observable OAuth boundary inputs without emitting them to logs.
type Profile ¶
type Profile string
Profile selects an MCP interoperability behavior exposed by a Fixture.
const ( // ProfileModern2026 implements the 2026-07-28 stateless server/discover flow. ProfileModern2026 Profile = "modern-2026" // ProfileLegacy2025 rejects server/discover so clients negotiate through initialize. ProfileLegacy2025 Profile = "legacy-2025" // ProfileInputRequired returns an MRTR input-required tool result. ProfileInputRequired Profile = "input-required" )