FUNCTIONS / @SPFN/MCP — MODEL CONTEXT PROTOCOL

Your app,
callable.

@spfn/mcp exposes your application's tools, resources, and prompts through an OAuth-protected MCP endpoint. The official SDK owns the protocol; your application owns identity, policy, context, and business logic.

Read the reference Get started $ pnpm add @spfn/mcp @spfn/core
01
The boundary

Protocol below.
Your policy above.

MCP negotiation, JSON-RPC, Streamable HTTP, schema validation, and legacy compatibility belong to the official SDK. Token validation, authorization, catalog filtering, billing, and application state stay in application code. The adapter connects those layers without exporting transport internals into your routes.

MCP client
official SDK
validateToken
application tools
FIG 01 — TRANSPORT IS INFRASTRUCTURE · AUTHORIZATION REMAINS APPLICATION POLICY
02
The mount

One router.
Three transport methods.

createMcpRoute() registers POST, GET, and DELETE at /mcp, then mounts through the same defineRouter(...).packages() composition used across SPFN. Every request resolves validated auth and request metadata before a handler sees application context.

Bearer token
resolveContext
listTools
typed handler
FIG 02 — REQUEST-SCOPED TRANSPORT · EXPLICIT APPLICATION-OWNED STATE
03
What's inside

The protocol adapter,
kept narrow.

Expose the capability.