Ragex. MCP. Protocol
(Ragex v0.32.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 internal_error(String.t(), id()) :: error_response()
@spec invalid_params(String.t(), id()) :: error_response()
@spec invalid_request(id()) :: error_response()
@spec method_not_found(method(), id()) :: error_response()
@spec notification(method(), params()) :: notification()
Creates a notification message.
Validates if a message is a notification (no id).
@spec parse_error(id()) :: error_response()
Standard error codes and helpers.
Validates if a message is a request (has an id).
Creates a successful response message.