Builds the MCP configuration that injects Raxol's tools into a native CLI.
This is the "vendor owns the loop, we inject our tools" trick from omnigent:
when a native harness runs its own agent loop, the framework cannot drive tool
dispatch. Instead it exposes the agent's Actions to the CLI as an MCP server,
which the CLI discovers via its --mcp-config <path> flag and calls directly.
Two artifacts are produced:
- The MCP config the CLI consumes --
{"mcpServers": {"<name>": {command, args, env}}}. The CLI launches that command as a child and speaks MCP to it. - A tool manifest -- the Action tool definitions (derived via
Raxol.Agent.Action.ToolConverter) written to a side file whose path is passed to the server command via theRAXOL_MCP_TOOLS_FILEenv var, so the spawned MCP server can load exactly this agent's tools.
The referenced :command must be an MCP server that exposes the manifest's
tools (e.g. a mix mcp.server variant); wiring a specific server binary is the
caller's responsibility. This module owns the config/manifest format only.
Summary
Functions
Build the MCP config map the CLI consumes.
Derive MCP tool definitions (%{"name", "description", "inputSchema"}) from
Action modules, via ToolConverter.to_tool_definitions/1.
The env var name carrying the tool manifest path to the MCP server.
Write the MCP config and tool manifest to disk.
Types
Functions
Build the MCP config map the CLI consumes.
Requires :command (the MCP server launcher). Tools come from :tools
(pre-derived) or :actions (derived here). The tool manifest path is injected
into the server entry's env as RAXOL_MCP_TOOLS_FILE when :tools_file is
given.
Derive MCP tool definitions (%{"name", "description", "inputSchema"}) from
Action modules, via ToolConverter.to_tool_definitions/1.
@spec tools_env_var() :: String.t()
The env var name carrying the tool manifest path to the MCP server.
Write the MCP config and tool manifest to disk.
Writes the manifest (<dir>/raxol_mcp_tools.json) and the config
(<dir>/raxol_mcp_config.json), wiring the manifest path into the server env.
Returns {:ok, config_path}. :dir defaults to a unique temp directory.