Mead.MCP.Server.Dispatcher (mead v0.1.1)

Copy Markdown View Source

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.

Summary

Types

context()

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

Functions

dispatch(arg, context)

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