MCP server for running Claude Code programmatically

MCP server for running Claude Code programmatically

claude-mcp•byebeloded

A Model Context Protocol server that lets AI tools execute prompts through Claude Code, with fresh and resumed conversations, working directory support, and asynchronous task management.

License: MIT•Runtime: Awaiting documentation review•Category: ai agents-models

WHAT IT DOES

  • •Provides start and resume tools to launch fresh conversations or continue existing ones in synchronous or asynchronous modes.
  • •Supports running Claude Code in a specified working directory for fresh conversations.
  • •Includes task management tools to monitor elapsed time, cancel operations, and retrieve results.
  • •Allows branching conversations by resuming from any previous response ID.

BEST FOR

  • •Quick synchronous queries and immediate responses from Claude Code within an AI tool.
  • •Long-running, non-blocking operations such as broad codebase analysis.
  • •Analyzing projects in separate directories or git worktrees.

ABOUT CLAUDE-MCP

MCP server for running Claude Code programmatically is cataloged as an MCP server attributed to ebeloded. A Model Context Protocol server that lets AI tools execute prompts through Claude Code, with fresh and resumed conversations, working directory support, and asynchronous task management. It is categorized under ai agents-models. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT. Check the source repository's current license and terms before using, modifying or distributing this software.

Capability inspector

Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.

Tools (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Resources (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Prompts (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for MCP server for running Claude Code programmatically are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

How are tasks handled asynchronously and managed?

Async tasks don't block the server, multiple can run concurrently, and they can be monitored with status and cancelled with cancel.

Upstream README

View this exact version on GitHub

README.md · 994bfe8078d9 · Fetched 2026-11-13 10:06:40 UTC

Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.

Showing the last retrieved documentation snapshot; check the source for current changes.

Claude Code MCP Server

An MCP (Model Context Protocol) server that allows AI tools to interact with Claude Code programmatically, enabling powerful agent-in-agent workflows with conversation continuity and asynchronous execution support.

Overview

This MCP server provides a bridge between AI tools and Claude Code, allowing other AI systems to execute prompts via Claude Code while maintaining session state for conversation continuity. It supports both synchronous and asynchronous execution patterns, making it suitable for quick queries and long-running operations.

Features

  • Fresh conversations - start tool for starting new conversations (sync/async)
  • Resume conversations - resume tool for continuing existing conversations (sync/async)
  • Working directory support - Execute Claude Code in any directory (fresh conversations only)
  • Task management - Monitor tasks with elapsed time, cancel operations, and retrieve results
  • Conversation branching - Resume from any previous response ID to branch conversations
  • Robust CLI detection - Automatically finds Claude Code installation
  • Permission bypass - Uses --dangerously-skip-permissions for full functionality
  • Environment configuration - Customizable via environment variables
  • Debug logging - Optional verbose logging for troubleshooting
  • Modular architecture - Clean, maintainable codebase with separation of concerns
  • Automated publishing - GitHub Actions workflow for releases
  • System notifications - macOS notifications for task start/completion with distinct sounds
  • Process cleanup - Automatic cleanup of orphaned processes when MCP server disconnects

Design Decisions

This MCP server makes intentional design choices for clarity and practical use:

Response ID vs Session ID

We use "Response ID" terminology instead of "Session ID" because:

  • Each conversation turn generates a new Response ID
  • You can branch conversations from any previous Response ID
  • The term "session" incorrectly implies a continuous session, when in reality each response is a new branching point

No --continue Flag Support

We intentionally do not support Claude Code's --continue flag because:

  • With multiple agents running in parallel, "most recent conversation" is ambiguous
  • Each agent typically handles independent tasks
  • Use the resume tool with an explicit Response ID for precise conversation control

Permission Mode

Currently uses --dangerously-skip-permissions which is functionally equivalent to --permission-mode bypassPermissions. This deprecated flag will be replaced with the modern permission-mode system in future versions, enabling:

  • plan mode for read-only code analysis
  • acceptEdits for auto-accepting file changes while confirming dangerous operations
  • default for standard interactive prompts
  • bypassPermissions for maintaining current behavior (all permissions granted)

Prerequisites

  • Node.js 18+ runtime
  • Claude Code CLI installed and configured
  • Claude Code must be run once with --dangerously-skip-permissions to accept terms

Installation & Setup

Option 1: NPX (No Installation)

Use directly with npx:

{
  "mcpServers": {
    "claude": {
      "command": "npx",
      "args": ["claude-mcp"]
    }
  }
}

Option 2: Local Development

  1. Clone and install:

    git clone https://github.com/ebeloded/claude-mcp.git
    cd claude-mcp
    npm install
    
  2. Use in MCP config:

    {
      "mcpServers": {
        "claude": {
          "command": "node",
          "args": ["/path/to/claude-mcp/server.js"]
        }
      }
    }
    

First-time Claude Code Setup

Important: Before using the setup above, run Claude Code once to accept permissions:

claude --dangerously-skip-permissions

Accept the terms when prompted (one-time requirement).

Configuration

MCP Client Configuration

Add the configuration to your MCP configuration file:

  • Cursor: ~/.cursor/mcp.json
  • Windsurf: ~/.codeium/windsurf/mcp_config.json

Environment Variables

  • CLAUDE_CLI_NAME: Override Claude CLI binary name (default: "claude")
  • MCP_CLAUDE_DEBUG: Set to "true" for verbose debug logging
  • MCP_NOTIFICATIONS: Set to "false" to disable macOS system notifications

Tools

start - Fresh Conversations

Start fresh conversations with Claude Code. Supports both synchronous and asynchronous execution.

Parameters:

  • message (string, required): The message to send to the agent. Be specific about what you want - mention file paths, desired output format, and any constraints.
  • workingDirectory (string, optional): Working directory to execute from. Use absolute paths or relative to current directory. Useful for different projects or git worktrees.
  • appendSystemPrompt (string, optional): Text to append to the default system prompt.
  • async (boolean, optional): Whether to execute asynchronously. Defaults to true.

Example (Synchronous):

// Simple query in current directory
start({
  message: "What's 2 + 2?",
  async: false,
})

// Analyze specific code in project directory
start({
  message:
    "Analyze the authentication logic in src/auth.js and list security vulnerabilities as bullet points",
  workingDirectory: "/path/to/project",
  async: false,
})

Response Format (Sync):

4

Response ID: 938c8c6d-1897-4ce4-a727-d001a628a279

Example (Asynchronous):

start({
  message:
    "Analyze the entire codebase for performance bottlenecks, focusing on database queries and API endpoints. Provide specific recommendations with file locations.",
})

start({
  message:
    "Review all React components in src/components/ for accessibility issues and generate a detailed report with WCAG compliance suggestions",
  workingDirectory: "/path/to/frontend-project",
})

Response (Async):

Task started successfully. Use status with task ID: 550e8400-e29b-41d4-a716-446655440000

resume - Continue Conversations

Continue an existing conversation with Claude Code. Supports both synchronous and asynchronous execution. Uses the original conversation's working directory.

Parameters:

  • message (string, required): The message to send to the agent. Reference previous context when needed - the agent remembers the conversation history.
  • previousResponseId (string, required): Response ID from a previous agent response. Use to branch or continue any conversation.
  • async (boolean, optional): Whether to execute asynchronously. Defaults to true.

Example (Synchronous):

resume({
  message: "What did I just ask you?",
  previousResponseId: "938c8c6d-1897-4ce4-a727-d001a628a279",
  async: false,
})

Response Format (Sync):

You asked me about 2 + 2.

Response ID: b2c3d4e5-f6g7-8901-bcde-f23456789012

Example (Asynchronous):

resume({
  message: "Continue that analysis with more detail",
  previousResponseId: "938c8c6d-1897-4ce4-a727-d001a628a279",
})

Response (Async):

Task started successfully. Use status with task ID: 661f9511-e30c-41e5-a927-556677889900

status - Task Status Monitoring

Check the status and progress of an asynchronous task.

Parameters:

  • taskId (string, required): The task ID returned by ask_async

Example:

status({
  taskId: "550e8400-e29b-41d4-a716-446655440000",
})

Response (Running):

Task 550e8400-e29b-41d4-a716-446655440000:
Status: running
Elapsed: 45s
Working Directory: /Users/ebeloded/Code/claude-mcp
Created: 2025-05-28T21:15:30.123Z
Updated: 2025-05-28T21:16:15.456Z

Response (Completed):

Task 550e8400-e29b-41d4-a716-446655440000:
Status: completed
Elapsed: 1m 52s
Working Directory: /Users/ebeloded/Code/claude-mcp
Created: 2025-05-28T21:15:30.123Z
Updated: 2025-05-28T21:17:22.789Z

Result: [Claude's comprehensive analysis here...]
Response ID: 938c8c6d-1897-4ce4-a727-d001a628a279
Cost: $0.045
Duration: 112456ms

cancel - Task Cancellation

Cancel a running asynchronous task.

Parameters:

  • taskId (string, required): The task ID to cancel

Example:

cancel({
  taskId: "550e8400-e29b-41d4-a716-446655440000",
})

Response:

Task 550e8400-e29b-41d4-a716-446655440000 cancelled successfully

Architecture

The server follows a modular architecture for maintainability:

claude-mcp/
├── server.js                    # Main entry point & orchestration
├── src/
│   ├── server/
│   │   └── setup.js             # MCP server setup and signal handling
│   ├── services/
│   │   ├── TaskService.js       # Async task lifecycle & notification management
│   │   └── ClaudeService.js     # Claude CLI execution logic
│   ├── tools/
│   │   └── (MCP tool definitions)
│   └── utils/
│       ├── errors.js            # Error handling utilities
│       ├── logger.js            # Debug logging utilities
│       └── validation.js       # Input validation utilities
└── tests/
    └── *.e2e.test.ts            # End-to-end tests

Component Responsibilities

  • TaskService: Handles async task creation, tracking, progress monitoring, cancellation, cleanup, and system notifications
  • ClaudeService: Manages Claude CLI discovery and execution for both sync and async patterns with process group management
  • Setup: MCP server initialization, signal handling, and graceful shutdown coordination
  • Tools: Six MCP tools registered directly in server.js using MCP SDK pattern
  • Server: Minimal orchestration layer that wires components together

Development

Testing

npm test

The test suite includes:

  • Synchronous execution with session management
  • Asynchronous task creation and status monitoring
  • Task cancellation capabilities
  • Error handling for edge cases

Debug Mode

Set MCP_CLAUDE_DEBUG=true to enable verbose logging:

{
  "mcpServers": {
    "claude": {
      "command": "node",
      "args": ["/path/to/claude-mcp/server.js"],
      "env": {
        "MCP_CLAUDE_DEBUG": "true"
      }
    }
  }
}

Local Development

# Install dependencies
npm install

# Run tests
npm test

# Start in debug mode
MCP_CLAUDE_DEBUG=true npm start

STDIO logging (important)

This server communicates over STDIO. Do not write regular logs to stdout—doing so corrupts JSON-RPC. All logs go to stderr via the logger utility. See the MCP quickstart guidance on logging: https://modelcontextprotocol.io/quickstart/server.md

Use Cases

Fresh Conversations (start)

  • Starting new conversations or analysis
  • Working with different codebases (using workingDirectory)
  • Quick queries and immediate responses (sync mode)
  • Long-running operations that need to be non-blocking (async mode)
  • Analyzing projects in separate directories or git worktrees
  • Custom system prompts for specialized behavior

Resume Conversations (resume)

  • Continuing existing conversations and context
  • Building on previous responses or analysis
  • Following up with questions about prior context
  • Branching conversations from any previous response
  • Maintaining conversation continuity within the same working directory
  • Both sync and async execution modes

Writing Effective Prompts

Each tool provides detailed message guidance in its parameter descriptions to help you get the best results from Claude Code. The key principles are:

  • Be specific about what you want analyzed or created
  • Mention file paths and directories to focus Claude's attention
  • Specify output format (bullet points, JSON, code snippets, etc.)
  • Include constraints and focus areas (performance, security, accessibility, etc.)
  • For resume tools: Reference previous context and build incrementally

See the tool parameter descriptions for comprehensive guidance and examples.

Publishing

This project uses GitHub Actions for automated publishing:

  • Releases: Create a GitHub release to automatically publish to npm
  • Manual: Use the "Publish to npm" workflow dispatch for manual publishing

License

MIT

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

Troubleshooting

Claude CLI Not Found

  • Ensure Claude CLI is installed and in your PATH
  • Set CLAUDE_CLI_NAME environment variable if using a custom binary name
  • Check that the CLI works: claude --version

Permission Errors

  • Run claude --dangerously-skip-permissions once to accept terms
  • Ensure the MCP server has permission to execute the Claude CLI

Conversation Continuity Issues

  • Response IDs are returned in each response - save them for continuation
  • Conversations may expire after extended periods of inactivity
  • Each new conversation without a previousResponseId starts fresh
  • You can branch conversations from any previous response ID

Async Task Issues

  • Tasks are automatically cleaned up after 1 hour of completion
  • Use status to monitor long-running tasks
  • Tasks can be cancelled with cancel if needed
  • Check debug logs if tasks appear stuck
  • Tasks are automatically cancelled when MCP server disconnects

System Notifications

  • macOS notifications show task start ("Agent Task Started") and completion ("Agent Task Completed")
  • Different sounds for start (Tink) vs completion (Glass/Basso/Funk based on result)
  • Disable with MCP_NOTIFICATIONS=false environment variable
  • Notifications include truncated prompt text for context

Performance Considerations

  • Async tasks don't block the MCP server
  • Multiple async tasks can run concurrently
  • Monitor task progress to avoid resource exhaustion
  • Consider task cancellation for very long operations
  • Parent process monitoring prevents orphaned processes

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for MCP server for running Claude Code programmatically from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/claude-mcp)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

Downloads and pulls

Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.

No reviewed package or image identity; download statistics are not listed yet.

Related ai agents-models MCP Servers

Alternative and complementary servers in the same category

View all in ai agents-models →
Knowledge Graph Memory
@modelcontextprotocol/server-memory•Model Context Protocol

Store and retrieve entities, relations and observations in a persistent local knowledge graph.

create_entitiescreate_relationsadd_observations+6 more
92K
AI & Multi-Agent
Sequential Thinking
@modelcontextprotocol/server-sequential-thinking•Model Context Protocol

Organize problem solving into revisable, branching thought steps through an MCP tool.

sequential_thinking
92K
AI & Multi-Agent

Query-aware context compression with an MCP plugin for coding agents, plus Python and HTTP interfaces for reducing the context sent to a language model.

146
AI & Multi-Agent