sim_codec_mcp/lib.rs
1//! MCP JSON-RPC envelope codec for SIM.
2//!
3//! This crate provides `codec:mcp`, a pure data codec for one MCP JSON-RPC
4//! envelope per frame. It owns only envelope validation and conversion; routing,
5//! transport, and callable execution live in later MCP libraries. As a domain
6//! codec it round-trips only MCP envelopes and fails closed outside them.
7//!
8//! Module map (all modules are private; the public surface is re-exported from
9//! this crate root):
10//! - canonical: the `McpCodec` decoder/encoder and the `McpCodecLib` host lib
11//! bridging MCP JSON-RPC text and the envelope model.
12//! - envelope: the envelope types (`McpEnvelope` and its request, notification,
13//! response, and error variants) and their class symbols.
14//! - error: the JSON-RPC and MCP error-code constants and the codec error
15//! helper.
16//! - expr: conversion between envelopes and checked `Expr` values
17//! (`envelope_to_expr`, `expr_to_envelope`).
18
19#![forbid(unsafe_code)]
20#![deny(missing_docs)]
21
22mod canonical;
23mod envelope;
24mod error;
25mod expr;
26
27#[cfg(test)]
28mod tests;
29
30pub use canonical::{McpCodec, McpCodecLib};
31pub use envelope::{
32 McpEnvelope, McpError, McpErrorEnvelope, McpNotification, McpRequest, McpResponse,
33 mcp_error_class_symbol, mcp_error_envelope_class_symbol, mcp_notification_class_symbol,
34 mcp_request_class_symbol, mcp_response_class_symbol,
35};
36pub use error::{
37 CANCELLED, CAPABILITY_DENIED, EXECUTION_ERROR, INTERNAL_ERROR, INVALID_PARAMS, INVALID_REQUEST,
38 METHOD_NOT_FOUND, NOT_FOUND, PARSE_ERROR, RATE_LIMITED,
39};
40pub use expr::{envelope_to_expr, expr_to_envelope};