Skip to main content

Crate crw_mcp_proto

Crate crw_mcp_proto 

Source
Expand description

Shared MCP (Model Context Protocol) JSON-RPC types and tool definitions.

Used by both the HTTP MCP endpoint (crw-server) and the stdio MCP proxy (crw-mcp).

Structs§

JsonRpcError
JsonRpcRequest
JsonRpcResponse

Enums§

ProtocolResult
Result of handling a protocol method.

Constants§

DEFAULT_MAP_LIMIT
Default cap on the number of URLs crw_map returns to the model.
DEFAULT_MAX_LENGTH
Default per-content-field char cap for scrape/parse/crawl-status results. ~15K chars ≈ ~3.5–4K tokens — well under the typical ~25K-token client cap.
PROTOCOL_VERSION
MCP spec revision advertised in the initialize handshake (lib.rs initialize arm). Bumped from “2024-11-05” to “2025-06-18” to legitimize tool outputSchema and result structuredContent, both introduced in the 2025-06-18 revision. There is no per-feature capability flag for structured output, so advertising the revision that defines it is the only spec-legal way to emit it.

Functions§

apply_bounds
Bound a tool result’s size at the MCP layer, driven by the call’s own maxLength/limit arguments (see [resolve_bound] for the 0 = unbounded opt-out). Non-mutating w.r.t. any stored state: it transforms an owned Value produced by the dispatch and returns a new one. Shared by the embedded, proxy, and CLI paths, and handles BOTH the bare (embedded) and ApiResponse- enveloped (proxy) result shapes so the two behave identically.
handle_protocol_method
Handle common MCP protocol methods (initialize, tools/list, ping, notifications).
is_known_tool
Whether name is one of the server’s tool names. A genuinely unknown tool should be answered with a JSON-RPC -32602 protocol error (clients degrade more gracefully than on an isError execution result). Checks the full set regardless of runtime availability (e.g. crw_search is a known name even when no search backend is configured — calling it then yields a clear runtime error).
strip_mcp_only_args
Remove MCP-only control args (maxLength, crw_map’s limit) before a proxy forwards the call to a REST endpoint that may reject unknown body fields. These are applied locally via apply_bounds on the response instead. Note crw_search.limit is a real backend param and is intentionally NOT stripped.
tool_definitions
tool_output_schema
Returns the declared outputSchema for a tool, if it declares one.
tool_result_response
Wrap a tool call result into an MCP-compliant content response.