Expand description
MCP — INBOUND, embeddable: a plain streamable-HTTP MCP server with generic
per-request hooks (SPEC §7C.1, ADR 0039). Port of golang/mcphandler.go.
Behind the serve feature.
Toolkit::serve owns a listener and exposes one static tool list.
Toolkit::mcp_handler returns an McpHandler a host mounts on its own
router (hyper directly — it implements hyper::service::Service — or any
framework through McpHandler::handle), behind its own TLS, CORS and
OAuth. Every policy is a hook; toolnexus has no notion of tenant, user, role
or storage.
The transport is JSON-RPC over HTTP written by hand (no rmcp server types in the public API): tools resolve per request, and a confirm elicitation rides the SAME POST’s SSE response (protocol 2025-06-18).
MCP 2026-07-28 (SPEC §7C.2, ADR 0040) is opt-in: list "2026-07-28" in
McpHandlerConfig::protocol_versions. That stateless wire (server/discover,
header validation, MRTR, the skills extension) lives in v2026; bearer-token
protection in McpServerAuth. Bring your own authorization server; the
auto-approving dev authorization server the suite uses is test tooling
(tests/common_dev_auth), not part of the library.
Structs§
- McpAuth
Error - An
authenticatefailure with an explicit HTTP status and challenge (McpServerAuthreturns it).status0 ⇒ 401. A non-emptywww_authenticatehook result wins overchallenge.reasonnever reaches the wire. - McpAuth
Metadata - The RFC 9728 metadata handler returned by
McpServerAuth::metadata. Mount it with hyper (hyper::service::Service) or callMcpAuthMetadata::handle. - McpCall
Event - Surfaced once per inbound
tools/call. - McpDecision
- What
before_callreturns. The default allows. - McpHandler
- The embeddable MCP server returned by
Toolkit::mcp_handler. Cheap to clone. Mount it with hyper (hyper::service::Service) or callMcpHandler::handlefrom any framework. - McpHandler
Config - Configures
Toolkit::mcp_handler. Every field is optional. - McpPrincipal
- The verified caller.
McpServerAuth::authenticatemakes it the identity:rc.identity_as::<McpPrincipal>(). - McpPrompt
- One
prompts/listentry. - McpPrompt
Argument - One prompt argument.
- McpPrompt
Message - One text message of a
prompts/getresult.role:user|assistant. - McpPrompt
Result - The
prompts/getresult. - McpRequest
Context - The request being served: HTTP parts, the authenticated identity, the
session id and the JSON-RPC
params._meta. Every hook receives it; a tool reads it withmcp_request_context. - McpResource
- One
resources/listentry. - McpResource
Content - One
resources/readentry: settext, orblob(base64). - McpServer
Auth - Protects an
McpHandlerwith bearer tokens. - McpServer
Info - Advertised at
initialize. Emptytitle/instructionsare omitted. - McpSkill
- One skill published through the skills extension (SEP-2640).
filesare paths relative to the skill directory (/-separated) and MUST includeSKILL.md.frontmatterNone⇒{name}.load_mcp_skillsbuilds these. - McpSkill
File - One text file of a skill.
Enums§
- McpDecision
Kind - The outcome of a
before_callgate.
Constants§
- MCP_
HANDLER_ IMPLEMENTED_ VERSIONS - The MCP protocol versions whose wire
McpHandlerimplements (ADR 0039). Configured versions outside this list are dropped.2026-07-28is opt-in only (never a default) and is served by the stateless wire of SPEC §7C.2;initializenever negotiates it. - MCP_
PROTOCOL_ 2026 - The MCP 2026-07-28 protocol version (SPEC §2.1).
- MCP_
SKILLS_ EXTENSION - The SEP-2640 skills extension id advertised by
server/discover.
Traits§
- McpSession
Ids - Issues and checks
Mcp-Session-Idvalues. The default is an in-memory set; a host plugs its own (signed ids, a DB) so any replica validates any session.
Functions§
- load_
mcp_ skills - Read every skill under
dir(any depth,**/SKILL.md, symlinks not followed) forMcpHandlerConfig::list_skills. The frontmatter is{name, description}parsed as in §3; a skill without a name is skipped. Files are every regular UTF-8 file under the skill directory (binary files are skipped — the wire carries text), paths/-separated, sorted by code point; skills sorted by name. - mcp_
request_ context - The
McpRequestContextof the served call a tool is running in.
Type Aliases§
- Authenticate
Fn authenticate: an error ⇒ HTTP 401 (seeMcpAuthFailure).- Before
Call Fn before_call(ctx, tool, args); an error is a deny carrying its message.- BoxFuture
- A boxed, sendable future returned by the async hooks.
- GetPrompt
Fn - List
Prompts Fn - List
Resources Fn - List
Skills Fn list_skills: the skills published through the SEP-2640 skills extension.- List
Tools Fn - McpAuth
Failure - An
authenticatefailure. Any error ⇒ a plain HTTP 401; anMcpAuthError(downcast) ⇒ its status, its challenge asWWW-Authenticateand the body{"error":"unauthorized"}(both wires)."msg".into()builds a plain one. - McpBody
- The response body type.
- McpIdentity
- What
authenticateproduces; reachable everywhere viaMcpRequestContext::identity. - OnMcp
Call Fn - Read
Resource Fn - Server
Info Fn - Verify
Token Fn verify(ctx, token, audience): replaces the default RS256/JWKS verifier (opaque tokens, introspection). Any error ⇒ 401invalid_token.- WwwAuthenticate
Fn www_authenticate(ctx, err): theWWW-Authenticatevalue (“” ⇒ omitted).