Generates MCP tools for explicitly declared GenServer calls and casts.
Import genserver_call/2 and genserver_cast/2 into a Snodo.Server module.
Each declaration generates an ordinary Snodo.Tool module and registers it
through the server DSL. The target is a fixed, registered module name; MCP
clients cannot choose a process, message, or Elixir term.
defmodule CounterServer do
use Snodo.Server, name: "counter", version: "1.0.0"
import Snodo.Tool.GenServer
genserver_call "counter_get",
target: Counter,
input_schema: %{"type" => "object", "additionalProperties" => false},
message: :get,
encode_reply: fn count -> %{"value" => count} end
end:message may be a fixed term or a one-argument function receiving the
validated string-keyed input map. Calls require :encode_reply, a one-argument
function that returns a JSON object. :timeout defaults to 5,000 milliseconds
and must be a positive integer. Failed validation, message construction,
unavailable targets, timeouts, and non-JSON replies become tool error results.
Input schemas may use the assertions enforced by
Snodo.Schema.Validator.Basic and the annotations title, description,
default, and x-mcp-header. Unsupported keywords fail compilation so a
declaration cannot advertise a constraint that this adapter ignores.
A cast result means only that GenServer.cast/2 accepted the message for
sending. An absent target is reported as a tool error, but the target can
stop after the availability check. A successful cast does not establish
that the target received or processed it.
Summary
Functions
Defines and registers a tool that sends a bounded GenServer.call/3.
Defines and registers a tool that sends GenServer.cast/2.
Functions
Defines and registers a tool that sends a bounded GenServer.call/3.
Defines and registers a tool that sends GenServer.cast/2.