Mcp42. Protocol
(mcp42 v0.1.1)
Copy Markdown
Pure JSON-RPC 2.0 encoding/decoding for MCP messages.
All functions are pure; the only side effect is Jason serialization.
Summary
Types
A JSON-RPC error object: %{code: integer, message: String.t(), data: term | nil}
Functions
Decodes raw JSON into a single MCP message.
Encodes a JSON-RPC error response. id may be nil for unparseable requests.
Encodes a JSON-RPC request. params of nil is omitted.
Encodes a JSON-RPC success response.
True when the message carries no id (a JSON-RPC notification).
Types
Functions
Decodes raw JSON into a single MCP message.
Note: JSON-RPC batching is NOT supported — MCP Streamable HTTP (2025-06-18) removed batching; arrays are rejected as invalid request.
Returns:
{:ok, map}— one request/notification{:error, error_response_map}— a ready-to-send JSON-RPC error (parse error or invalid request)
Encodes a JSON-RPC error response. id may be nil for unparseable requests.
Encodes a JSON-RPC request. params of nil is omitted.
Encodes a JSON-RPC success response.
True when the message carries no id (a JSON-RPC notification).