Skip to main content

Crate sim_codec_mcp

Crate sim_codec_mcp 

Source
Expand description

MCP JSON-RPC envelope codec for SIM.

This crate provides codec:mcp, a pure data codec for one MCP JSON-RPC envelope per frame. It owns only envelope validation and conversion; routing, transport, and callable execution live in later MCP libraries. As a domain codec it round-trips only MCP envelopes and fails closed outside them.

Module map (all modules are private; the public surface is re-exported from this crate root):

  • canonical: the McpCodec decoder/encoder and the McpCodecLib host lib bridging MCP JSON-RPC text and the envelope model.
  • envelope: the envelope types (McpEnvelope and its request, notification, response, and error variants) and their class symbols.
  • error: the JSON-RPC and MCP error-code constants and the codec error helper.
  • expr: conversion between envelopes and checked Expr values (envelope_to_expr, expr_to_envelope).

Structs§

McpCodec
The codec:mcp decoder/encoder.
McpCodecLib
The host-registered Lib that installs McpCodec as the domain codec codec:mcp.
McpError
The error object inside an McpErrorEnvelope.
McpErrorEnvelope
A JSON-RPC error response for a prior request.
McpNotification
A JSON-RPC notification: a method call with no id and no response.
McpRequest
A JSON-RPC request: an addressed method call expecting a response.
McpResponse
A JSON-RPC successful response for a prior request.

Enums§

McpEnvelope
One MCP JSON-RPC 2.0 envelope: the typed payload carried by a single frame.

Constants§

CANCELLED
MCP cancelled: the request was cancelled before completion (-32003).
CAPABILITY_DENIED
MCP capability denied: a required capability was not granted (-32001).
EXECUTION_ERROR
MCP execution error: a tool or method failed while executing (-32002).
INTERNAL_ERROR
JSON-RPC internal error: an internal failure occurred (-32603).
INVALID_PARAMS
JSON-RPC invalid params: the method parameters are invalid (-32602).
INVALID_REQUEST
JSON-RPC invalid request: the payload is not a valid request object (-32600).
METHOD_NOT_FOUND
JSON-RPC method not found: the requested method does not exist (-32601).
NOT_FOUND
MCP not found: the addressed resource does not exist (-32004).
PARSE_ERROR
JSON-RPC parse error: invalid JSON was received (-32700).
RATE_LIMITED
MCP rate limited: the request was throttled (-32005).

Functions§

envelope_to_expr
Project an McpEnvelope into its canonical Expr map, with the mcp version field and the variant-specific fields.
expr_to_envelope
Validate a canonical Expr map back into a typed McpEnvelope.
mcp_error_class_symbol
The stable class symbol mcp/Error for McpError.
mcp_error_envelope_class_symbol
The stable class symbol mcp/ErrorEnvelope for McpErrorEnvelope.
mcp_notification_class_symbol
The stable class symbol mcp/Notification for McpNotification.
mcp_request_class_symbol
The stable class symbol mcp/Request for McpRequest.
mcp_response_class_symbol
The stable class symbol mcp/Response for McpResponse.