Skip to main content

Module mcp

Module mcp 

Source
Expand description

Outbound @mcp/<server> transport dispatch.

Every @mcp/<server>.<tool>(...) call lowers (in codegen) to one host import — submilli:mcp.call(server, tool, argsJson) -> unknown. The host converts the transport’s bounded JSON tree directly to guest objects; normal runtime casts validate declared tool return types.

This module provides that host fn. It runs the mcp.<server> capability check (one per server, with the tool in the filter context) before dispatch (a denial throws before any network bytes leave), then calls the embedder-provided McpTransport — the actual JSON-RPC tools/call, auth injection, and refresh-on-401 live in the embedder (submilli-server), keeping this crate free of its async/HTTP dependencies.

Structs§

McpOutcome
Completed transport work, retained even when the tool result is an error.
McpResponse
A JSON tree admitted before it crosses the transport/runtime boundary. Private ownership keeps both guest conversion and recursive destruction bounded.

Enums§

McpCallError
Why an outbound MCP tools/call failed. The host fn maps each to a catchable script error (see [mcp_error_to_throw]).

Constants§

MCP_MAX_RESPONSE_BYTES
MCP_MODULE_NAME
The single internal host module every MCP call dispatches through.

Traits§

McpTransport
The embedder-provided outbound MCP transport: performs the JSON-RPC tools/call (resolving auth, refreshing on 401, reusing connections) and returns a bounded JSON tree. Transport decoders must bound response bytes and nesting before allocating recursive JSON values.

Functions§

install_mcp_async
Install the async submilli:mcp.call dispatch host fn. Reads (server, tool, argsJson), runs the capability check, dispatches through StoreData::mcp_transport, and builds guest values directly from its tree.
mcp_call_package_declaration
Codegen-facing definitions for the internal submilli:mcp.call host fn: call(server: string, tool: string, args: string): unknown. Lowered as (ref $string) x3 -> (ref null $Object) by the generic host-import path.
request_digest
The digest the call log records for a call’s request: what a transport sees of it, so a transport can recognize a call it saw recorded.