Mcp
Implements the Model Context Protocol over JSON-RPC 2.0. All operations go through a single POST /mcp endpoint, differentiated by the request body.
- Spec: modelcontextprotocol.io
- MIME:
application/json - Serializer:
McpSerializer - Routing: Body-matched (single endpoint)
import crate.protocols.mcp.policy;
auto crateRouter = router.crateSetup!Mcp;crateRouter.add(userCrate);Generated Tools
Section titled “Generated Tools”All operations use POST /mcp with a JSON-RPC body. The params.name field determines the operation:
| Tool Name | Operation |
|---|---|
list_users | List all |
get_user | Get one |
create_user | Create |
replace_user | Replace |
update_user | Update fields |
delete_user | Delete |
Request Format
Section titled “Request Format”{ "jsonrpc": "2.0", "method": "tools/call", "params": { "name": "get_user", "arguments": { "id": "abc123" } }, "id": 1}Base Operations
Section titled “Base Operations”MCP registers additional protocol-level operations via onRouterInit:
| Endpoint | Body Match | Purpose |
|---|---|---|
POST /mcp | method: "initialize" | Protocol handshake |
POST /mcp | method: "tools/list" | List available tools |
GET /mcp/sse | — | Server-Sent Events stream |
GET /.well-known/oauth-protected-resource | — | OAuth 2.1 metadata |
The tools list is populated lazily via onRouterReady after all models are registered.
Not Yet Supported
Section titled “Not Yet Supported”- Resources: Only tools are exposed; no MCP resource endpoints
- Prompts: No prompt support
- Sampling: No sampling / LLM model endpoints
- Notifications: Server-to-client via SSE only; no client-initiated notifications
- Progress tracking: No progress reporting mechanism
- Logging: No structured logging API
- Cancellation: No request cancellation
Custom Base URL
Section titled “Custom Base URL”auto crateRouter = router.crateSetup!(McpPolicy!(PolicyConfig("/tools")));// Endpoint at POST /tools/mcp