Marea.Mcp.Server (marea v0.0.1-rc.1)

Copy Markdown View Source

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. Reports tools capability.
  • notifications/initialized — acknowledged silently.
  • ping — replies with an empty result.
  • tools/list — returns descriptors from Marea.Mcp.Tools.
  • tools/call — invokes one descriptor through Marea.Mcp.Runner and returns its captured output as a single text content 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

Runs the stdio server loop until EOF on stdin.

Functions

run()

@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.