cc-mcp
by aravhawk
README.md
# cc-mcp
Run Claude Code as an async task runner for remote MCP clients, from a machine you own.
Cloud assistants can't reach your Pi, and your Pi has a Claude subscription doing nothing. cc-mcp is a small MCP server that closes the gap: the assistant calls `start_task`, goes away, and comes back for the result while Claude Code works on your hardware.
```
MCP client ──HTTPS──▶ Cloudflare Tunnel ──▶ cc-mcp (127.0.0.1) ──▶ detached runner ──▶ claude -p
Bearer token or OAuth auth · limits · audit one per task stream-json
```
## Why
- **Tasks outlive requests.** Each task runs in its own detached process. Restart the server, lose the connection, close the laptop: the task keeps going, and `wait_task` never blocks longer than a tunnel tolerates.
- **Research first.** A task with no repository runs in a fresh scratch directory with web search and file tools and no shell. The last message is the result.
- **Safe to leave on the internet.** Per-client hashed tokens, optional OAuth 2.1 approved from your own shell, per-IP lockout, host and origin checks, an audit log, and a locked-down child environment. [Threat model](docs/security.md).
- **Plain Node.** Node 22, no native modules, no database; state is files in one directory.
## Quickstart
You need Node 22+, [Claude Code](https://docs.anthropic.com/en/docs/claude-code) signed in as the user that will run the server, and a hostname on Cloudflare. The [Pi deployment guide](docs/deploy-pi.md) covers systemd and the tunnel in full.
```sh
git clone https://github.com/aravhawk/cc-mcp && cd cc-mcp
npm ci && npm run build && npm link # provides the cc-mcp command
claude login # or set CLAUDE_CODE_OAUTH_TOKEN from "claude setup-token"
cc-mcp doctor # checks Node, claude, auth, directories, exposure
cc-mcp token create --label hark --expires 90d # printed once; save it
export CC_MCP_PUBLIC_URL=https://cc.example.com
export CC_MCP_TRUST_PROXY=true # required behind a tunnel, see below
cc-mcp serve # listens on 127.0.0.1:8787
```
Point cloudflared at `http://127.0.0.1:8787` ([example config](deploy/cloudflared-config.yml)), then add this to your MCP client:
| | |
| --- | --- |
| URL | `https://cc.example.com/mcp` (Streamable HTTP) |
| Header | `Authorization: Bearer <token>` |
> **Behind a tunnel, set `CC_MCP_TRUST_PROXY=true`.** cloudflared connects from loopback, so without it every visitor on the internet shares the address 127.0.0.1 and five failed attempts lock out your own client. `cc-mcp doctor` warns when it sees a tunnel without it, and so does the server log.
Check it end to end:
```sh
curl -s https://cc.example.com/healthz
# {"status":"ok"}
```
## Tools
| Tool | Purpose |
| --- | --- |
| `start_task` | Start a task and get its id back at once. No `path` means research mode. |
| `wait_task` / `get_task` | Block up to 90 s, or check without blocking. Finished tasks return their result text. |
| `get_events` | Page through the transcript: assistant text, tool calls, results. |
| `send_message` | Join a running task, interrupt it, or resume a finished one in the same Claude Code session. |
| `cancel_task` | Stop a task; it can be resumed later. |
| `list_tasks` / `search_tasks` / `update_task` | Browse, full-text search, rename and tag. |
| `ask` | Start a research task and wait for the answer in one call. |
Arguments, states and examples are in [docs/tools.md](docs/tools.md).
## Working in a repository
Off by default. Set `CC_MCP_ALLOWED_ROOTS` and clients can pass a `path` inside those directories, optionally with `isolation: "worktree"` to work in a throwaway git worktree. Set `CC_MCP_REPO_URL_HOSTS=github.com` to let tasks clone https repositories from those hosts. Tasks get `Read`, `Glob`, `Grep`, `Edit` and `Write` and nothing else unless you widen `CC_MCP_REPO_TOOLS`.
## Configuration
Everything is an `CC_MCP_*` environment variable, and invalid values stop startup with a message naming the variable. A typical env file:
```sh
CC_MCP_PUBLIC_URL=https://cc.example.com
CC_MCP_TRUST_PROXY=true
CC_MCP_MAX_CONCURRENT=2 # tasks at once; the rest queue
CC_MCP_ALLOWED_ROOTS=/home/pi/projects # optional: enables path tasks
CC_MCP_DEFAULT_MODEL=opus
CC_MCP_MAX_EFFORT=high
```
The full list is in [docs/configuration.md](docs/configuration.md). OAuth for clients that require it is covered in [docs/oauth.md](docs/oauth.md), and the moving parts in [docs/architecture.md](docs/architecture.md).
## Status
Pre-1.0. The suite (`npm test`) runs against a fake `claude` binary, and CI covers Node 22 and 24. What has **not** been exercised yet: an authenticated Claude Code run through cc-mcp, a real Raspberry Pi behind a live Cloudflare Tunnel, and any particular MCP client (including Hark). Expect rough edges there and please open an issue.
## Contributing and security
See [CONTRIBUTING.md](CONTRIBUTING.md). Report vulnerabilities privately as described in [SECURITY.md](SECURITY.md).
## License
[MIT](LICENSE) © Arav Jain
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues