Minimal MCP server for Marea, speaking JSON-RPC 2.0 over newline-delimited stdio (the stdio transport from the MCP spec).
Supported methods
initialize— handshake. Reportstoolscapability.notifications/initialized— acknowledged silently.ping— replies with an empty result.tools/list— returns descriptors fromMarea.Mcp.Tools.tools/call— invokes one descriptor throughMarea.Mcp.Runnerand returns its captured output as a singletextcontent block.
Any other method returns JSON-RPC error -32601 ("Method not
found"). Malformed JSON returns -32700 ("Parse error").
stdio discipline
The server keeps its original group leader so IO.read(:stdio, :line) reads MCP requests from real stdin. All non-protocol
output is routed to :standard_error explicitly (log/1).
Each tools/call runs in a Task that swaps its own group
leader to a StringIO (see Marea.Mcp.Runner), guaranteeing
command output never leaks to the protocol stream.
Caching
The tool list is computed once at startup (reading marea.yaml,
loading plugins, walking the args tree). Changing marea.yaml
or plugin code requires restarting the server.
Summary
Functions
@spec run() :: :ok
Runs the stdio server loop until EOF on stdin.
Returns :ok when the client closes the connection. Aborts via
Marea.Lib.stop/1 if no marea.yaml is reachable from the
current directory — interactive bootstrap would block forever
in a server context.