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§
Enums§
- Protocol
Result - Result of handling a protocol method.
Constants§
- DEFAULT_
MAP_ LIMIT - Default cap on the number of URLs
crw_mapreturns 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
initializehandshake (lib.rsinitializearm). Bumped from “2024-11-05” to “2025-06-18” to legitimize tooloutputSchemaand resultstructuredContent, 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/limitarguments (see [resolve_bound] for the0 = unboundedopt-out). Non-mutating w.r.t. any stored state: it transforms an ownedValueproduced by the dispatch and returns a new one. Shared by the embedded, proxy, and CLI paths, and handles BOTH the bare (embedded) andApiResponse- 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
nameis one of the server’s tool names. A genuinely unknown tool should be answered with a JSON-RPC-32602protocol error (clients degrade more gracefully than on anisErrorexecution result). Checks the full set regardless of runtime availability (e.g.crw_searchis 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’slimit) before a proxy forwards the call to a REST endpoint that may reject unknown body fields. These are applied locally viaapply_boundson the response instead. Notecrw_search.limitis a real backend param and is intentionally NOT stripped. - tool_
definitions - tool_
output_ schema - Returns the declared
outputSchemafor a tool, if it declares one. - tool_
result_ response - Wrap a tool call result into an MCP-compliant content response.