# `MCPKit.Protocol`
[🔗](https://github.com/mcostasilva/mcp_kit/blob/v0.2.4/lib/mcp_kit/protocol.ex#L1)

JSON-RPC helpers used by the MCP transport.

This module is intentionally small and focused on message shape detection,
decoding, and standard protocol error payloads.

## Examples

    iex> MCPKit.Protocol.request?(%{"jsonrpc" => "2.0", "method" => "ping", "id" => 1})
    true

    iex> MCPKit.Protocol.success(1, %{"ok" => true})
    %{"jsonrpc" => "2.0", "id" => 1, "result" => %{"ok" => true}}

# `decode`

Decodes a raw JSON-RPC request body.

## Examples

    iex> MCPKit.Protocol.decode(~s({"jsonrpc":"2.0","method":"ping","id":1}))
    {:ok, %{"id" => 1, "jsonrpc" => "2.0", "method" => "ping"}}

    iex> MCPKit.Protocol.decode("{")
    {:error, :parse_error}

# `encode!`

Encodes a JSON-RPC payload to JSON.

# `forbidden`

Builds a JSON-RPC forbidden payload.

# `internal_error`

Builds a JSON-RPC internal error payload.

# `invalid_params`

Builds a JSON-RPC invalid params payload.

# `invalid_request`

Builds a JSON-RPC invalid request payload.

# `method_not_found`

Builds a JSON-RPC method not found payload.

# `notification?`

Returns true when the payload is a JSON-RPC notification.

# `parse_error`

Builds a JSON-RPC parse error payload.

# `request?`

Returns true when the payload is a JSON-RPC request.

# `response?`

Returns true when the payload is a JSON-RPC response.

# `success`

Builds a successful JSON-RPC response payload.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
