# MCP Server for Claude Code & Codex

When launched via stdio pipe, `agen` runs as an MCP server. Any MCP-compatible agent (Claude Code, Codex, OpenCode, etc.) can connect and use Agenvoy's tools — including building new ones on the fly.

## What external agents gain

- **Sandboxed execution** — all script tools run inside OS-native sandbox (macOS `sandbox-exec` / Linux `bwrap`), isolating `~/.ssh`, `~/.aws`, `.env`, `*.pem` and other sensitive paths
- **Auto tool creation** — the server instructions tell the agent to search existing tools (`script_*`, `ext_*`) first; when none covers a request it calls `tool_generate_guide`, which starts from `public_api_list`: a fitting API is called directly, and only when none fits (or a user-supplied API needs a key) does the agent build a script tool with `edit_tool(mode=write)` → `test_tool`. The tool is persisted and reusable across sessions. API tools were Removed in v1.3.2; a script tool or a direct API call replaces them
- **Shared tool library** — tools created by any agent (Agenvoy internal, Claude Code, Codex, etc.) are saved to `~/.config/agenvoy/tools/script/` and available to all connected agents. Build once, use everywhere
- **Live data access** — `public_api_list` (built in since v1.3.2; formerly `api_public_api_list`) lists public API categories, or the keyless APIs in one category; the agent picks one, calls it, and answers with real data instead of training-knowledge guesses

## Quick setup

There is no TUI installer (`/mcp` has no `install` action); add the entry to your agent's config by hand.

Config per agent:

**Claude Code** — `~/.claude.json`
```json
{ "mcpServers": { "agenvoy": { "command": "agen" } } }
```

**Codex** — `~/.codex/config.toml`
```toml
[mcp_servers.agenvoy]
command = "agen"
```

**OpenCode** — `~/.config/opencode/opencode.jsonc`
```json
{ "mcp": { "agenvoy": { "type": "local", "command": ["agen"] } } }
```

## Generic MCP client setup

For any MCP client not listed above, the only requirement is:

- **Transport**: stdio (JSON-RPC over stdin/stdout)
- **Command**: `agen`
- **Args**: none
- **Prerequisite**: `agen` binary in `$PATH` (`curl -fsSL https://agenvoy.com/scripts/install.sh | bash`)

The server speaks [MCP protocol version `2024-11-05`](https://spec.modelcontextprotocol.io/specification/2024-11-05/), supports `tools/list` (with `listChanged` notifications) and `tools/call`. No authentication required — the server runs locally as the current user.

Typical config pattern across MCP clients:

```json
{
  "<servers_key>": {
    "agenvoy": {
      "command": "agen"
    }
  }
}
```

Where `<servers_key>` varies by client (`mcpServers`, `mcp_servers`, `mcp`, etc.). Some clients require an explicit `"type": "stdio"` or `"type": "local"` field. Check your client's documentation.
