Ragex.MCP.Protocol
(Ragex v0.10.0)
View Source
Implements the Model Context Protocol (MCP) JSON-RPC 2.0 protocol.
Handles encoding/decoding of MCP messages and protocol-level validation.
Summary
Functions
Decodes a JSON-RPC message from a string.
Encodes a response to JSON string.
Creates an error response message.
Creates a notification message.
Validates if a message is a notification (no id).
Standard error codes and helpers.
Validates if a message is a request (has an id).
Creates a successful response message.
Types
Functions
@spec decode(String.t()) :: {:ok, request() | notification()} | {:error, term()}
Decodes a JSON-RPC message from a string.
@spec encode(response() | error_response() | notification()) :: {:ok, String.t()} | {:error, term()}
Encodes a response to JSON string.
@spec error_response(integer(), String.t(), any(), id()) :: error_response()
Creates an error response message.
@spec notification(method(), params()) :: notification()
Creates a notification message.
Validates if a message is a notification (no id).
Standard error codes and helpers.
Validates if a message is a request (has an id).
Creates a successful response message.