# Sub Agents MCP

> Sub Agents MCP is an open-source MCP server for developer tools. Run reusable Markdown-defined coding agents through the CLI you already use. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, macOS, Linux, Windows
- **Repository:** https://github.com/shinpr/sub-agents-mcp
- **MCP Registry name:** io.github.shinpr/sub-agents-mcp
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools), [AI models and LLM tooling](https://ai-powered.com/categories/ai-and-llm)
- **Listing updated:** 2026-11-23

## About

You write an agent as a Markdown file, such as a code reviewer or test writer, and the filename becomes its name. When an assistant is told to use that agent, the server launches your chosen coding CLI with those instructions and returns the result to the same conversation. That lets different MCP clients share one set of agent definitions and one backend and model setting.

The AGENT_TYPE variable picks the backend from a long list: Codex, Claude Code, Cursor CLI, Command Code, GLM, Kimi, Grok Build, Google Antigravity, Gemini CLI, OpenCode, MiniMax Code and Pi. The selected CLI must already be installed and signed in. GLM and Kimi need a CLI_API_KEY, while the others use the CLI's own login. AGENT_PERMISSION chooses read-only, safe-edit (default) or yolo, which the README treats as guidance rather than a security boundary.

Sessions can be switched on so an agent remembers earlier calls when the assistant reuses the returned session ID. Execution times out at five minutes by default. It needs Node.js 22 or later and is MIT licensed.

## Features

- **Markdown agent definitions:** Defines each agent in a Markdown file named after the agent.
- **Many CLI backends:** Runs agents through Codex, Claude Code, Cursor, Gemini, Grok, Pi and others.
- **Permission levels:** Offers read-only, safe-edit and yolo modes.
- **Shared model setting:** One AGENT_MODEL value applies to every agent.
- **Session continuity:** Optional sessions let an agent continue earlier work.
- **Execution timeout:** Limits a run to a configurable time, five minutes by default.

## Good for

- Delegate a code review to a focused reviewer agent
- Have a test-writer agent add unit tests
- Investigate a failing flow with a dedicated agent
- Share agent definitions across several MCP clients

## Install

### Claude Code: Add with the CLI (Terminal)

```sh
claude mcp add sub-agents-mcp --env AGENTS_DIR='<AGENTS_DIR>' --env AGENT_TYPE='<AGENT_TYPE>' --env CURSOR_API_KEY='<CURSOR_API_KEY>' --env CLI_API_KEY='<CLI_API_KEY>' -- npx -y sub-agents-mcp
```

Add --scope user to use it in every project, or --scope project to share it in .mcp.json.

### Claude Code: Or share it with your project (.mcp.json)

```json
{
  "mcpServers": {
    "sub-agents-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "sub-agents-mcp"
      ],
      "env": {
        "AGENTS_DIR": "<AGENTS_DIR>",
        "AGENT_TYPE": "<AGENT_TYPE>",
        "CURSOR_API_KEY": "<CURSOR_API_KEY>",
        "CLI_API_KEY": "<CLI_API_KEY>"
      }
    }
  }
}
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "sub-agents-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "sub-agents-mcp"
      ],
      "env": {
        "AGENTS_DIR": "<AGENTS_DIR>",
        "AGENT_TYPE": "<AGENT_TYPE>",
        "CURSOR_API_KEY": "<CURSOR_API_KEY>",
        "CLI_API_KEY": "<CLI_API_KEY>"
      }
    }
  }
}
```

Settings → Developer → Edit Config, then quit and reopen Claude Desktop.

### Cursor (~/.cursor/mcp.json)

```json
{
  "mcpServers": {
    "sub-agents-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "sub-agents-mcp"
      ],
      "env": {
        "AGENTS_DIR": "<AGENTS_DIR>",
        "AGENT_TYPE": "<AGENT_TYPE>",
        "CURSOR_API_KEY": "<CURSOR_API_KEY>",
        "CLI_API_KEY": "<CLI_API_KEY>"
      }
    }
  }
}
```

Use .cursor/mcp.json in a project to share it with the project.

### VS Code (~/.copilot/mcp-config.json)

```json
{
  "mcpServers": {
    "sub-agents-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "sub-agents-mcp"
      ],
      "env": {
        "AGENTS_DIR": "<AGENTS_DIR>",
        "AGENT_TYPE": "<AGENT_TYPE>",
        "CURSOR_API_KEY": "<CURSOR_API_KEY>",
        "CLI_API_KEY": "<CLI_API_KEY>"
      }
    }
  }
}
```

Or put the same entry in .mcp.json at your workspace root to share it.

### Codex: Add with the CLI (Terminal)

```sh
codex mcp add sub-agents-mcp --env AGENTS_DIR='<AGENTS_DIR>' --env AGENT_TYPE='<AGENT_TYPE>' --env CURSOR_API_KEY='<CURSOR_API_KEY>' --env CLI_API_KEY='<CLI_API_KEY>' -- npx -y sub-agents-mcp
```

### Codex: Or add to config.toml (~/.codex/config.toml)

```toml
[mcp_servers.sub-agents-mcp]
command = "npx"
args = ["-y", "sub-agents-mcp"]
env = { AGENTS_DIR = "<AGENTS_DIR>", AGENT_TYPE = "<AGENT_TYPE>", CURSOR_API_KEY = "<CURSOR_API_KEY>", CLI_API_KEY = "<CLI_API_KEY>" }
```

### Gemini CLI and Antigravity: Gemini CLI (~/.gemini/settings.json)

```json
{
  "mcpServers": {
    "sub-agents-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "sub-agents-mcp"
      ],
      "env": {
        "AGENTS_DIR": "<AGENTS_DIR>",
        "AGENT_TYPE": "<AGENT_TYPE>",
        "CURSOR_API_KEY": "<CURSOR_API_KEY>",
        "CLI_API_KEY": "<CLI_API_KEY>"
      }
    }
  }
}
```

Or run: gemini mcp add -s user -e AGENTS_DIR='<AGENTS_DIR>' -e AGENT_TYPE='<AGENT_TYPE>' -e CURSOR_API_KEY='<CURSOR_API_KEY>' -e CLI_API_KEY='<CLI_API_KEY>' sub-agents-mcp npx -- -y sub-agents-mcp

### Gemini CLI and Antigravity: Antigravity (~/.gemini/config/mcp_config.json)

```json
{
  "mcpServers": {
    "sub-agents-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "sub-agents-mcp"
      ],
      "env": {
        "AGENTS_DIR": "<AGENTS_DIR>",
        "AGENT_TYPE": "<AGENT_TYPE>",
        "CURSOR_API_KEY": "<CURSOR_API_KEY>",
        "CLI_API_KEY": "<CLI_API_KEY>"
      }
    }
  }
}
```

Use .agents/mcp_config.json to add it to one workspace only.

### Devin Desktop (~/.config/devin/mcp_config.json)

```json
{
  "mcpServers": {
    "sub-agents-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "sub-agents-mcp"
      ],
      "env": {
        "AGENTS_DIR": "<AGENTS_DIR>",
        "AGENT_TYPE": "<AGENT_TYPE>",
        "CURSOR_API_KEY": "<CURSOR_API_KEY>",
        "CLI_API_KEY": "<CLI_API_KEY>"
      }
    }
  }
}
```

On Windows the file is %APPDATA%\\devin\\mcp_config.json. Use .devin/mcp_config.json to share it with a project.

### Cline (cline_mcp_settings.json)

```json
{
  "mcpServers": {
    "sub-agents-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "sub-agents-mcp"
      ],
      "env": {
        "AGENTS_DIR": "<AGENTS_DIR>",
        "AGENT_TYPE": "<AGENT_TYPE>",
        "CURSOR_API_KEY": "<CURSOR_API_KEY>",
        "CLI_API_KEY": "<CLI_API_KEY>"
      }
    }
  }
}
```

Open it from the MCP Servers icon → Configure → Configure MCP Servers.

### Zed (Zed settings.json)

```json
{
  "context_servers": {
    "sub-agents-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "sub-agents-mcp"
      ],
      "env": {
        "AGENTS_DIR": "<AGENTS_DIR>",
        "AGENT_TYPE": "<AGENT_TYPE>",
        "CURSOR_API_KEY": "<CURSOR_API_KEY>",
        "CLI_API_KEY": "<CLI_API_KEY>"
      }
    }
  }
}
```

Open it with zed: open settings file. Merge context_servers into the settings you already have.

### JetBrains AI Assistant and Junie: AI Assistant (Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add)

```json
{
  "mcpServers": {
    "sub-agents-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "sub-agents-mcp"
      ],
      "env": {
        "AGENTS_DIR": "<AGENTS_DIR>",
        "AGENT_TYPE": "<AGENT_TYPE>",
        "CURSOR_API_KEY": "<CURSOR_API_KEY>",
        "CLI_API_KEY": "<CLI_API_KEY>"
      }
    }
  }
}
```

The AI Assistant docs only show command and args. If the env block is ignored, use Junie for this server.

### JetBrains AI Assistant and Junie: Junie (~/.junie/mcp/mcp.json)

```json
{
  "mcpServers": {
    "sub-agents-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "sub-agents-mcp"
      ],
      "env": {
        "AGENTS_DIR": "<AGENTS_DIR>",
        "AGENT_TYPE": "<AGENT_TYPE>",
        "CURSOR_API_KEY": "<CURSOR_API_KEY>",
        "CLI_API_KEY": "<CLI_API_KEY>"
      }
    }
  }
}
```

Use .junie/mcp/mcp.json to share it with a project.

### Kiro (~/.kiro/settings/mcp.json)

```json
{
  "mcpServers": {
    "sub-agents-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "sub-agents-mcp"
      ],
      "env": {
        "AGENTS_DIR": "<AGENTS_DIR>",
        "AGENT_TYPE": "<AGENT_TYPE>",
        "CURSOR_API_KEY": "<CURSOR_API_KEY>",
        "CLI_API_KEY": "<CLI_API_KEY>"
      }
    }
  }
}
```

Use .kiro/settings/mcp.json to add it to one workspace only.

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "sub-agents-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "sub-agents-mcp"
      ],
      "env": {
        "AGENTS_DIR": "<AGENTS_DIR>",
        "AGENT_TYPE": "<AGENT_TYPE>",
        "CURSOR_API_KEY": "<CURSOR_API_KEY>",
        "CLI_API_KEY": "<CLI_API_KEY>"
      }
    }
  }
}
```

## FAQ

### What do I need installed?

Node.js 22 or later, an MCP client and one supported coding CLI that is signed in.

### How do I name an agent?

Use the filename; code-reviewer.md becomes code-reviewer.

### Are the permission levels a security boundary?

No. The README says enforcement depends on the backend, so treat them as guidance.

### How do agents remember earlier calls?

Set SESSION_ENABLED to true and have the assistant reuse the returned session_id.

### Is Sub Agents MCP free?

Yes. Sub Agents MCP is open source, so you can use and self-host it for free.

### How do I add Sub Agents MCP to Claude Code?

Run this command in your terminal: claude mcp add sub-agents-mcp --env AGENTS_DIR='<AGENTS_DIR>' --env AGENT_TYPE='<AGENT_TYPE>' --env CURSOR_API_KEY='<CURSOR_API_KEY>' --env CLI_API_KEY='<CLI_API_KEY>' -- npx -y sub-agents-mcp

### What are the best alternatives to Sub Agents MCP?

The closest alternatives to Sub Agents MCP are REA, Context7, Chrome DevTools MCP, Codebase Memory and GitHub.

## Where this comes from

- Description: written from the project's README.
- Install steps: from the official MCP Registry entry.

## Alternatives

- [REA](https://ai-powered.com/mcp/rea): REA is an open-source MCP server for developer tools.
- [Context7](https://ai-powered.com/mcp/context7): Context7 is a freemium MCP server for developer tools.
- [Chrome DevTools MCP](https://ai-powered.com/mcp/chrome-devtools-mcp-2): Chrome DevTools MCP is an open-source MCP server for browser automation.
- [Codebase Memory](https://ai-powered.com/mcp/codebase-memory): Codebase Memory is an open-source MCP server for knowledge and memory.
- [GitHub](https://ai-powered.com/mcp/github): GitHub is an open-source MCP server for developer tools.
- [Serena MCP: the IDE for your agent](https://ai-powered.com/mcp/serena-mcp-the-ide-for-your-agent): Serena MCP: the IDE for your agent is an open-source MCP server for developer tools.
- [XERJ](https://ai-powered.com/mcp/xerj): XERJ is an open-source MCP server for knowledge and memory.
- [awesome-mcp-servers](https://ai-powered.com/mcp/awesome-mcp-servers-2): awesome-mcp-servers is an open-source MCP server for developer tools.

---
Source: https://ai-powered.com/mcp/sub-agents-mcp
