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.

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.envfile: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:
- Create
jobs.dbSQLite database with all tables - Auto-generate OAuth credentials (printed to stderr - save these!)
- 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 executionMCP_TRANSPORTTransport mode: stdio, sse, or bothDASHBOARD_USERNAMEBasic auth username for dashboardDASHBOARD_PASSWORDBasic auth password for dashboard