googleapis/mcp-toolbox · error · jsonrpc.Error
INTERNAL_ERROR
INTERNAL_ERROR
Error message
unable to retrieve enableDraftSpecs from context
What it means
ProcessMethod reads the enableDraftSpecs flag from the request context via util.EnableDraftSpecsFromContext; if the value was never injected into the context (it should be set by the HTTP handler middleware before dispatch), it returns an INTERNAL_ERROR. This indicates an internal wiring bug rather than a client mistake.
Source
Thrown at internal/server/mcp/mcp.go:62
// NotificationHandler process notifications request. It MUST NOT send a response.
// Currently Toolbox does not process any notifications.
func NotificationHandler(ctx context.Context, body []byte) error {
var notification jsonrpc.JSONRPCNotification
if err := json.Unmarshal(body, ¬ification); err != nil {
return fmt.Errorf("invalid notification request: %w", err)
}
// Since we do not enforce notifications, we do not need to check the
// `Mcp-Method` header here
return nil
}
// ProcessMethod returns a response for the request.
// This is the Operation phase of the lifecycle for MCP client-server connections.
func ProcessMethod(ctx context.Context, mcpVersion string, id jsonrpc.RequestId, method string, g group.Group, primitiveMgr *primitives.PrimitiveManager, body []byte, header http.Header) (any, error) {
enableDraft, ok := util.EnableDraftSpecsFromContext(ctx)
if !ok {
err := fmt.Errorf("unable to retrieve enableDraftSpecs from context")
return jsonrpc.NewError(id, jsonrpc.INTERNAL_ERROR, err.Error(), nil), err
}
switch mcpVersion {
case mcputil.VERSION_20260728:
return v20260728.ProcessMethod(ctx, id, method, g, primitiveMgr, body, header)
case mcputil.VERSION_20251125:
return v20251125.ProcessMethod(ctx, id, method, g, primitiveMgr, body, header)
case mcputil.VERSION_20250618:
return v20250618.ProcessMethod(ctx, id, method, g, primitiveMgr, body, header)
case mcputil.VERSION_20250326:
return v20250326.ProcessMethod(ctx, id, method, g, primitiveMgr, body, header)
case "", mcputil.VERSION_20241105:
return v20241105.ProcessMethod(ctx, id, method, g, primitiveMgr, body, header)
default:
return jsonrpc.NewUnsupportedProtocolVersionError(id, mcpVersion, enableDraft)
}
}
View on GitHub (pinned to 8cc6e09de2)
Solutions
- Ensure requests go through the standard server handler that injects the enableDraftSpecs value into the context (util.WithEnableDraftSpecs or equivalent).
- If calling ProcessMethod directly, add the flag to the context first: ctx = util.WithEnableDraftSpecs(ctx, true|false).
- Update the toolbox binary/server wiring if you patched or forked internal handlers.
- Report/inspect upstream if a stock server path reproduces this — it signals missing middleware in that path.
Example fix
// before: direct call with a plain context res, err := mcp.ProcessMethod(ctx, ver, id, method, g, pmgr, body, hdr) // after: inject the draft-specs flag expected by ProcessMethod ctx = util.WithEnableDraftSpecs(ctx, false) res, err := mcp.ProcessMethod(ctx, ver, id, method, g, pmgr, body, hdr)
Defensive patterns
Strategy: try-catch
Validate before calling
_, ok := util.EnableDraftSpecsFromContext(ctx)
if !ok {
ctx = util.WithEnableDraftSpecs(ctx, false)
} Try / catch
res, err := mcp.ProcessMethod(ctx, ver, id, method, g, pmgr, body, hdr)
if err != nil && strings.Contains(err.Error(), "enableDraftSpecs") {
ctx = util.WithEnableDraftSpecs(ctx, false)
res, err = mcp.ProcessMethod(ctx, ver, id, method, g, pmgr, body, hdr)
} Prevention
- Route all MCP traffic through the stock HTTP handler that injects context values
- In tests, always build contexts with util.WithEnableDraftSpecs before calling ProcessMethod
- Treat INTERNAL_ERROR responses as server wiring bugs and check middleware setup first
When it happens
Trigger: Calling ProcessMethod directly (tests, custom embeddings) with a bare context.Context that lacks the enableDraftSpecs value; a server code path that builds the context without running the middleware that stores the flag.
Common situations: Custom forks or wrappers around the MCP server that bypass the standard httpHandler; unit/integration tests constructing requests manually; upgrades where middleware registration was dropped.
Related errors
- INTERNAL_ERROR
- INTERNAL_ERROR
- INTERNAL_ERROR
- INTERNAL_ERROR
- MCP Auth cannot be enabled together with the legacy HTTP API
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/1ca65de9afe205f1.
Report an issue: GitHub.