Skip to main content
Glama

claude-custom-mcp

Give Claude tools that run on your own device. A self-hosted MCP server built for Claude: phone with Termux, Raspberry Pi or home server, no open ports.

CI License: MIT Node.js 20.12+ Cloudflare Workers free plan Zero dependencies

English · Bahasa Indonesia

Contents

Quick start · How it works · Configuration · Adding tools · Security · Troubleshooting · Contributing

Related MCP server: Remote MCP Server on Cloudflare

Quick start

1. Run the agent

pkg install nodejs cloudflared git
git clone https://github.com/vaeromon/claude-custom-mcp && cd claude-custom-mcp/termux
npm run setup

Install Node.js 20.12+ and cloudflared, then:

git clone https://github.com/vaeromon/claude-custom-mcp && cd claude-custom-mcp/termux
npm run setup

setup writes termux/.env and prints MCP_KEY and TERMUX_KEY. Keep both for step 2.

2. Deploy the Worker

Click to deploy your own copy:

Deploy to Cloudflare

Paste MCP_KEY and TERMUX_KEY when asked.

Fork this repo. In the Cloudflare dashboard: Workers & Pages > Create > Import a repository.

Field

Value

Root directory

worker

Deploy command

npx wrangler deploy

After the first deploy, add two Secrets under Settings > Variables and Secrets: MCP_KEY and TERMUX_KEY.

cd worker && npm install
npx wrangler login
npx wrangler secret put MCP_KEY
npx wrangler secret put TERMUX_KEY
npx wrangler deploy

Your URL is https://claude-custom-mcp.<your-subdomain>.workers.dev. Put it in termux/.env as WORKER_URL, or run npm run setup -- --url <url>.

3. Start the agent

cd termux && ./start.sh      # or: npm start

Wait for Tunnel URL sent to Worker.

4. Connect Claude

  1. Customize > Connectors > Add custom connector

  2. URL: https://<your-worker-url>/mcp

  3. Authentication: OAuth, register the client automatically

  4. On the page that opens, enter MCP_KEY

  5. In a chat, ask Claude to run ping_termux

NOTE

Claude's free plan allows one custom connector.

How it works

The agent runs a Cloudflare Quick Tunnel whose URL changes on every restart. It re-registers the current URL with the Worker every minute, so the Worker always knows where to send calls.

worker/                     Cloudflare Worker
  wrangler.jsonc            settings (name, domain, vars)
  src/index.js              routing
  src/core/                 MCP, OAuth, register, store, termux client
  src/tools/<name>/         tools that run on the Worker
  scripts/gen-tools.js      builds the tool list automatically
termux/                     agent for your device
  agent.js                  local server + tunnel + registration
  setup.js                  key generator
  tools/<name>/             tools that run on your device
docs/                       guides and diagrams (img/generate.py rebuilds the SVGs)
test/                       npm test

Configuration

Worker settings live in worker/wrangler.jsonc under vars. Keys are secrets and never go in that file.

Name

Where

Default

Meaning

MCP_KEY

Worker secret

required

Password on the login page. Also signs tokens.

TERMUX_KEY

Worker secret + termux/.env

required

Shared secret between Worker and agent.

SERVER_NAME

Worker var

claude-custom-mcp

Name on the login page and in MCP serverInfo.

ALLOWED_REDIRECT_URIS

Worker var

Claude callbacks

Comma-separated OAuth redirect URIs a client may use.

TOOL_TIMEOUT_MS

Worker var

15000

Max wait for a Termux tool call.

WORKER_URL

termux/.env

required

Your Worker's URL.

PORT

termux/.env

3939

Local agent port (127.0.0.1 only).

Uncomment routes in wrangler.jsonc, set your domain, and set workers_dev to false. The domain must be on your Cloudflare account and must not already have a DNS record for that name.

cp worker/.dev.vars.example worker/.dev.vars   # fill in both keys
npm run dev

Adding tools

Copy termux/tools/_template to termux/tools/my_tool, edit it, restart the agent. Tools that should run on the Worker itself go in worker/src/tools/. Full guide: docs/tools.md.

Security

Tools run code on your device on behalf of an AI, so read SECURITY.md before adding powerful ones.

  • Login uses OAuth with PKCE. Only the redirect URIs you allow can register.

  • Access tokens last 1 hour. Refresh tokens last 30 days and are single-use (rotated on every refresh).

  • To rotate keys: npm run setup -- --renew, update both Worker secrets, restart the agent, reconnect the connector. Changing MCP_KEY revokes all tokens.

Troubleshooting

WARNING

Quick Tunnels are meant for testing: no uptime guarantee, and the URL changes on every restart (handled automatically). For something permanent, use a named Cloudflare Tunnel and adapttermux/lib/tunnel.js.

Development

npm test

See CONTRIBUTING.md. Licensed under MIT.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables deploying and connecting to MCP servers on Cloudflare Workers with OAuth login, allowing remote access to tools via MCP clients like Claude Desktop.
      -
    • F
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables running MCP tools remotely on Cloudflare Workers with OAuth login, allowing Claude Desktop and other clients to call server-side tools like math operations.
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables a Claude Code cloud session to run shell commands inside a chroot jail on your own computer and to call the MCP servers already installed there, with every request authenticated and relayed over a Cloudflare quick tunnel so no router port is opened and no SSH key or tunnel is ever handed to the cloud VM.
      MIT