Sub-Agents

Sub-Agents

shinpr

Delegates tasks to specialized AI assistants defined in markdown files, making Claude Code-style sub-agents work across any MCP-compatible tool like Cursor or Claude Desktop.

Delegates tasks to specialized AI assistants in Cursor and Claude Code CLI tools by automatically discovering agent definition files and providing execution with timeout management and performance monitoring for building orchestration workflows and task delegation systems.

71464 views16Local (stdio)

What it does

  • Execute specialized AI agents via Cursor CLI, Claude Code, or Gemini CLI
  • Auto-discover agent definition files from directories
  • Monitor agent execution with timeout management
  • Track performance metrics across agent runs
  • Manage agent sessions with error handling
  • Define reusable task-specific agents in markdown

Best for

Teams wanting to share AI agents across different IDEsDevelopers building orchestration workflowsCreating task delegation systems with specialized agentsPorting Claude Code sub-agent workflows to other tools
Works across multiple MCP-compatible toolsBuilt-in session management and error handlingAuto-discovery of agent definitions

About Sub-Agents

Sub-Agents is a community-built MCP server published by shinpr that provides AI assistants with tools and capabilities via the Model Context Protocol. Sub-Agents delegates tasks to specialized AI assistants, automating workflow orchestration with performance monitoring a It is categorized under developer tools.

How to install

You can install Sub-Agents in your AI client of choice. Use the install panel on this page to get one-click setup for Cursor, Claude Desktop, VS Code, and other MCP-compatible clients. This server runs locally on your machine via the stdio transport.

License

Sub-Agents is released under the MIT license. This is a permissive open-source license, meaning you can freely use, modify, and distribute the software.

Sub-Agents MCP Server

npm version License: MIT

Bring Claude Code–style sub-agents to any MCP-compatible tool.

This MCP server lets you define task-specific AI agents (like "test-writer" or "code-reviewer") in markdown files, and execute them via Cursor CLI, Claude Code, Gemini CLI, or Codex backends.

Why?

Claude Code offers powerful sub-agent workflows—but they're limited to its own environment. This MCP server makes that workflow portable, so any MCP-compatible tool (Cursor, Claude Desktop, Windsurf, etc.) can use the same agents.

Concrete benefits:

  • Define reusable agents once, use them across multiple tools
  • Share agent definitions within teams regardless of IDE choice
  • Leverage Cursor CLI, Claude Code, Gemini CLI, or Codex capabilities from any MCP client

Read the full story

Alternative: Agent Skills

sub-agents-skills offers a lightweight alternative.

sub-agents-mcpsub-agents-skills
SetupMCP configuration requiredCopy skill files to your environment
FeaturesSession management, error handlingMinimal
StabilityMore robustLightweight

Choose sub-agents-mcp for production use with reliability features. Choose sub-agents-skills for quick setup in Skill-compatible environments.

Table of Contents

Prerequisites

  • Node.js 20 or higher
  • One of these execution engines (they actually run the sub-agents):
    • cursor-agent CLI (from Cursor)
    • claude CLI (from Claude Code)
    • gemini CLI (from Gemini CLI)
    • codex CLI (from Codex)
  • An MCP-compatible tool (Cursor IDE, Claude Desktop, Windsurf, etc.)

Quick Start

1. Create Your First Agent

Create a folder for your agents and add code-reviewer.md:

# Code Reviewer

Review code for quality and maintainability issues.

## Task
- Find bugs and potential issues
- Suggest improvements
- Check code style consistency

## Done When
- All target files reviewed
- Issues listed with explanations

See Writing Effective Agents for more on agent design.

2. Install Your Execution Engine

Pick one based on which tool you use:

For Cursor users:

# Install Cursor CLI (includes cursor-agent)
curl https://cursor.com/install -fsS | bash

# Authenticate (required before first use)
cursor-agent login

For Claude Code users:

# Option 1: Native install (recommended)
curl -fsSL https://claude.ai/install.sh | bash

# Option 2: NPM (requires Node.js 18+)
npm install -g @anthropic-ai/claude-code

Note: Claude Code installs the claude CLI command.

For Gemini CLI users:

# Install Gemini CLI
npm install -g @google/gemini-cli

# Authenticate via browser (required before first use)
gemini

Note: Gemini CLI uses OAuth authentication. Run gemini once to authenticate via browser.

For Codex users:

# Install Codex
npm install -g @openai/codex

3. Configure MCP

Add this to your MCP configuration file:

Cursor: ~/.cursor/mcp.json Claude Desktop: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)

{
  "mcpServers": {
    "sub-agents": {
      "command": "npx",
      "args": ["-y", "sub-agents-mcp"],
      "env": {
        "AGENTS_DIR": "/absolute/path/to/your/agents-folder",
        "AGENT_TYPE": "cursor"  // or "claude", "gemini", or "codex"
      }
    }
  }
}

Important: Use absolute paths only.

  • /Users/john/Documents/my-agents (Mac/Linux)
  • C:\\Users\\john\\Documents\\my-agents (Windows)
  • ./agents or ~/agents won't work

Restart your IDE and you're ready to go.

4. Fix "Permission Denied" Errors When Running Shell Commands

Sub-agents may fail to execute shell commands with permission errors. This happens because sub-agents can't respond to interactive permission prompts.

Recommended approach:

  1. Run your CLI tool directly with the task you want sub-agents to handle:

    # For Cursor users
    cursor-agent
    
    # For Claude Code users
    claude
    
    # For Gemini CLI users
    gemini
    
    # For Codex CLI users
    codex
    
  2. When prompted to allow commands (e.g., "Add Shell(cd), Shell(make) to allowlist?"), approve them

  3. This automatically updates your configuration file, and those commands will now work when invoked via MCP sub-agents

Manual configuration (alternative):

If you prefer to configure permissions manually, edit:

  • Cursor: <project>/.cursor/cli.json or ~/.cursor/cli-config.json
  • Claude Code: .claude/settings.json or .claude/settings.local.json
{
  "permissions": {
    "allow": [
      "Shell(cd)",
      "Shell(make)",
      "Shell(git)"
    ]
  }
}

Note: Agents often run commands as one-liners like cd /path && make build, so you need to allow all parts of the command.

Usage Examples

Just tell your AI to use an agent:

"Use the code-reviewer agent to check my UserService class"
"Use the test-writer agent to create unit tests for the auth module"
"Use the doc-writer agent to add JSDoc comments to all public methods"

Your AI automatically invokes the specialized agent and returns results.

Tip: Always include what you want done in your request—not just which agent to use. For example:

  • ✅ "Use the code-reviewer agent to check my UserService class"
  • ❌ "Use the code-reviewer agent" (too vague—the agent won't know what to review)

The more specific your task, the better the results.

Writing Effective Agents

The Single Responsibility Principle

Each agent should do one thing well. Avoid "swiss army knife" agents.

✅ Good❌ Bad
Reviews code for security issuesReviews code, writes tests, and refactors
Writes unit tests for a moduleWrites tests and fixes bugs it finds

Essential Structure

# Agent Name

One-sentence purpose.

## Task
- Action 1
- Action 2

## Done When
- Criterion 1
- Criterion 2

Keep Agents Self-Contained

Agents run in isolation with fresh context. Avoid:

  • References to other agents ("then use X agent...")
  • Assumptions about prior context ("continuing from before...")
  • Scope creep beyond the stated purpose

Advanced Patterns

For complex agents, consider adding:

  • Scope boundaries: Explicitly state what's out of scope
  • Prohibited actions: List common mistakes the agent should avoid
  • Output format: Define structured output when needed

Agent Examples

Each .md or .txt file in your agents folder becomes an agent. The filename becomes the agent name (e.g., bug-investigator.md → "bug-investigator").

bug-investigator.md

# Bug Investigator

Investigate bug reports and identify root causes.

## Task
- Collect evidence from error logs, code, and git history
- Generate multiple hypotheses for the cause
- Trace each hypothesis to its root cause
- Report findings with supporting evidence

## Out of Scope
- Fixing the bug (investigation only)
- Making assumptions without evidence

## Done When
- At least 2 hypotheses documented with evidence
- Most likely cause identified with confidence level
- Affected code locations listed

For more advanced patterns (completion checklists, prohibited actions, structured output), see claude-code-workflows/agents. These are written for Claude Code, but the design patterns apply to any execution engine.

Configuration Reference

Required Environment Variables

AGENTS_DIR Path to your agents folder. Must be absolute.

AGENT_TYPE Which execution engine to use:

  • "cursor" - uses cursor-agent CLI
  • "claude" - uses claude CLI
  • "gemini" - uses gemini CLI
  • "codex" - uses codex CLI (OpenAI Codex)

Optional Settings

EXECUTION_TIMEOUT_MS How long agents can run before timing out (default: 5 minutes, max: 10 minutes)

AGENTS_SETTINGS_PATH Path to custom CLI settings directory for sub-agents.

Each CLI normally reads settings from project-level directories (.claude/, .cursor/, .codex/) or user-level directories (~/.claude/, ~/.cursor/, ~/.codex/). If you want sub-agents to run with different settings (e.g., different permissions or model), specify a separate settings directory here.

Supported CLI types: claude, cursor, codex

Note: Gemini CLI does not support custom settings paths, so this option has no effect when AGENT_TYPE is gemini.

Example with custom settings:

{
  "mcpServers": {
    "sub-agents": {
      "command": "npx",
      "args": ["-y", "sub-agents-mcp"],
      "env": {
        "AGENTS_DIR": "/absolute/path/to/agents",
        "AGENT_TYPE": "cursor",
        "EXECUTION_TIMEOUT_MS": "600000",
        "AGENTS_SETTINGS_PATH": "/absolute/path/to/custom-cli-settings"
      }
    }
  }
}

Security Note

Agents have access to your project directory. Only use agent definitions from trusted sources.

Session Management

Session management allows sub-agents to remember previous executions, which helps when you want agents to build on earlier work or maintain context across multiple calls.

Why Sessions Matter

By default, each sub-agent


README truncated. View full README on GitHub.

Alternatives

Related Skills

Browse all skills
ui-design-system

UI design system toolkit for Senior UI Designer including design token generation, component documentation, responsive design calculations, and developer handoff tools. Use for creating design systems, maintaining visual consistency, and facilitating design-dev collaboration.

18
ai-sdk

Answer questions about the AI SDK and help build AI-powered features. Use when developers: (1) Ask about AI SDK functions like generateText, streamText, ToolLoopAgent, embed, or tools, (2) Want to build AI agents, chatbots, RAG systems, or text generation features, (3) Have questions about AI providers (OpenAI, Anthropic, Google, etc.), streaming, tool calling, structured output, or embeddings, (4) Use React hooks like useChat or useCompletion. Triggers on: "AI SDK", "Vercel AI SDK", "generateText", "streamText", "add AI to my app", "build an agent", "tool calling", "structured output", "useChat".

6
api-documenter

Master API documentation with OpenAPI 3.1, AI-powered tools, and modern developer experience practices. Create interactive docs, generate SDKs, and build comprehensive developer portals. Use PROACTIVELY for API documentation or developer portal creation.

4
openai-knowledge

Use when working with the OpenAI API (Responses API) or OpenAI platform features (tools, streaming, Realtime API, auth, models, rate limits, MCP) and you need authoritative, up-to-date documentation (schemas, examples, limits, edge cases). Prefer the OpenAI Developer Documentation MCP server tools when available; otherwise guide the user to enable `openaiDeveloperDocs`.

4
cli-builder

Guide for building TypeScript CLIs with Bun. Use when creating command-line tools, adding subcommands to existing CLIs, or building developer tooling. Covers argument parsing, subcommand patterns, output formatting, and distribution.

3
ydc-ai-sdk-integration

Integrate Vercel AI SDK applications with You.com tools (web search, AI agent, content extraction). Use when developer mentions AI SDK, Vercel AI SDK, generateText, streamText, or You.com integration with AI SDK.

2