Claude Runner MCP Server

An MCP server for scheduling and executing Claude Code CLI tasks

README.md

Claude Runner - MCP Server with Job Scheduling

A single-file MCP server that schedules and executes Claude Code CLI tasks via cron expressions. Features a web dashboard, webhook support, dynamic MCP server creation, and token/cost tracking.

Dashboard

Prerequisites

  • Python 3.11+ (required for asyncio.timeout())
  • Claude Agent SDK (pip install claude-agent-sdk)
  • SQLite3 (usually pre-installed on macOS/Linux)
  • Anthropic API key - Jobs are executed via the Claude Agent SDK, which requires an ANTHROPIC_API_KEY. Do not rely on a personal Max/Pro subscription — the SDK needs an API key from console.anthropic.com. Set it in your environment or .env file:
    export ANTHROPIC_API_KEY=sk-ant-...
    

Quick Start

# Clone the repository
git clone https://github.com/floriansmeyers/SFLOW-AIRunner-MCP-PRD.git
cd SFLOW-AIRunner-MCP-PRD

# Create and activate virtual environment
python3 -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Run the server (stdio transport for Claude Desktop)
python server.py

On first run, the server will:

  1. Create jobs.db SQLite database with all tables
  2. Auto-generate OAuth credentials (printed to stderr - save these!)
  3. Start the scheduler loop (checks every 60 seconds)

Running

Local (stdio transport - for Claude Desktop)

python server.py

Add to Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "claude-runner": {
      "command": "/path/to/SFLOW-AIagents-MCP-Spinner/.venv/bin/python",
      "args": ["/path/to/SFLOW-AIagents-MCP-Spinner/server.py"]
    }
  }
}

Important: Use the full path to the Python interpreter inside your .venv to ensure dependencies are available.

Remote (SSE transport - for web dashboard)

MCP_TRANSPORT=sse python server.py
# Server accessible at http://localhost:8080
# Web dashboard at http://localhost:8080/

Both Transports

MCP_TRANSPORT=both python server.py
# stdio for Claude Desktop + SSE for web dashboard

Environment Variables

Variable Required Default Description
ANTHROPIC_API_KEY Yes - API key from console.anthropic.com — required for job execution via the Claude Agent SDK. Do not use a personal Max/Pro subscription.
MCP_TRANSPORT No both Transport mode: stdio, sse, or both
OAUTH_CLIENT_ID No auto-generated OAuth client ID
OAUTH_CLIENT_SECRET No auto-generated OAuth client secret
OAUTH_SECRET_KEY No auto-generated Secret key for signing JWT tokens
DASHBOARD_USERNAME No - Basic auth username for dashboard
DASHBOARD_PASSWORD No - Basic auth password for dashboard
NGROK_AUTHTOKEN No - ngrok auth token for remote tunneling
PUBLIC_URL No - Override base URL for OAuth callbacks (e.g., https://your-domain.com)

Create a .env file to persist these:

ANTHROPIC_API_KEY=sk-ant-...
OAUTH_CLIENT_ID=your_client_id
OAUTH_CLIENT_SECRET=your_client_secret
OAUTH_SECRET_KEY=your_secret_key
DASHBOARD_USERNAME=admin
DASHBOARD_PASSWORD=secure_password
NGROK_AUTHTOKEN=your_ngrok_token

Authentication (OAuth 2.1)

SSE transport requires OAuth 2.1 authentication. On first startup, the server auto-generates credentials and prints them to stderr:

============================================================
OAUTH CREDENTIALS FOR CLAUDE CONNECTOR
============================================================
Client ID:     abc123...
Client Secret: xyz789...

Save these to your .env file:
  OAUTH_CLIENT_ID=abc123...
  OAUTH_CLIENT_SECRET=xyz789...
============================================================

Important: Save these credentials immediately. The secret is only shown once and cannot be recovered.

OAuth Endpoints

Endpoint Description
/.well-known/oauth-authorization-server Server metadata
/.well-known/oauth-protected-resource Protected resource metadata
/oauth/authorize Authorization endpoint
/oauth/token Token endpoint

Regenerating Credentials

If you lose your credentials, delete the client from the database:

sqlite3 jobs.db "DELETE FROM oauth_clients WHERE client_name = 'Claude (auto)'"

Then restart the server to generate new credentials.

Directory Structure

SFLOW-AIRunner-MCP-PRD/
├── server.py              # Main MCP server
├── requirements.txt       # Python dependencies
├── jobs.db               # SQLite database (auto-created)
├── .env                  # Environment variables (optional)
├── fixed-servers/        # Built-in MCP servers
│   └── email/
│       ├── server.py
│

Environment Variables

ANTHROPIC_API_KEYrequiredAPI key from console.anthropic.com required for job execution
MCP_TRANSPORTTransport mode: stdio, sse, or both
DASHBOARD_USERNAMEBasic auth username for dashboard
DASHBOARD_PASSWORDBasic auth password for dashboard

Try it

Schedule a daily task at 9 AM to run the Claude Code CLI on my project directory.
Show me the execution history and token usage for my scheduled AI jobs.
Create a new recurring job that runs a code quality check every Monday.
List all currently scheduled tasks and their next execution times.

Frequently Asked Questions

What are the key features of Claude Runner?

Schedules and executes Claude Code CLI tasks using cron expressions. Includes a web dashboard for managing jobs and viewing history. Provides token and cost analytics for AI job executions. Supports both stdio and SSE transport modes. Includes OAuth 2.1 authentication for the web dashboard.

What can I use Claude Runner for?

Automating recurring code maintenance tasks using Claude Code. Tracking AI agent costs and token usage across multiple automated jobs. Managing AI-driven project workflows via a centralized web interface. Triggering AI tasks via webhooks for external integrations.

How do I install Claude Runner?

Install Claude Runner by running: git clone https://github.com/floriansmeyers/SFLOW-AIRunner-MCP-PRD.git && cd SFLOW-AIRunner-MCP-PRD && python3 -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt

What MCP clients work with Claude Runner?

Claude Runner works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Claude Runner docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Open Conare