# `Mead.MCP.Server.Dispatcher`
[🔗](https://github.com/albertosca/mead/blob/main/lib/mead/mcp/server/dispatcher.ex#L1)

Turns one decoded JSON-RPC message into the server's answer. Pure apart from the tools it
calls: no HTTP, no process of its own, so every protocol rule is testable without a network.

It receives what `Mead.MCP.Protocol.decode/1` returns, minus `{:invalid, _}`, which the Plug
refuses before dispatching. A request gets `{:reply, binary}` (one line of JSON); a
notification, or a response a client sends back, gets `:no_reply`.

Protocol faults are JSON-RPC errors: `-32601` for an unknown method and `-32602` for params of
the wrong type or an unknown tool. A tool that fails while running is not a protocol fault; it
is a result with `isError: true`.

# `context`

```elixir
@type context() :: %{allow_effect: boolean()}
```

# `dispatch`

```elixir
@spec dispatch(Mead.MCP.Protocol.decoded(), context()) ::
  {:reply, binary()} | :no_reply
```

---

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