Scoria.MCP.Protocol (scoria v0.1.0)

Copy Markdown View Source

JSON-RPC 2.0 parsing and formatting for the MCP Gateway.

Summary

Functions

Formats a JSON-RPC 2.0 error response.

Formats a successful JSON-RPC 2.0 response.

Parses an incoming map into a structured JSON-RPC request. Validates jsonrpc: "2.0", method, params, and id.

Types

jsonrpc_error()

@type jsonrpc_error() :: %{code: integer(), message: String.t(), data: term() | nil}

jsonrpc_request()

@type jsonrpc_request() :: %{
  jsonrpc: String.t(),
  method: String.t(),
  params: term() | nil,
  id: term() | nil
}

Functions

format_error(id, code, message, data \\ nil)

Formats a JSON-RPC 2.0 error response.

format_response(id, result)

Formats a successful JSON-RPC 2.0 response.

parse(payload)

Parses an incoming map into a structured JSON-RPC request. Validates jsonrpc: "2.0", method, params, and id.

Returns {:ok, request} or {:error, error_response}.