MCP.Protocol (MCP Elixir SDK v1.1.0)

Copy Markdown View Source

JSON-RPC 2.0 encoding/decoding for MCP messages.

Summary

Functions

Decodes a JSON string into a classified message struct.

Classifies a decoded JSON map into the appropriate message struct.

Encodes a message struct to a JSON string.

Encodes a message struct to a JSON string, raising on error.

Returns the JSON-RPC version.

Returns the MCP protocol version this library targets.

Functions

decode(json)

Decodes a JSON string into a classified message struct.

decode_message(map)

Classifies a decoded JSON map into the appropriate message struct.

encode(message)

Encodes a message struct to a JSON string.

encode!(message)

Encodes a message struct to a JSON string, raising on error.

jsonrpc_version()

@spec jsonrpc_version() :: String.t()

Returns the JSON-RPC version.

protocol_version()

@spec protocol_version() :: String.t()

Returns the MCP protocol version this library targets.