Skip to content

Add hosted mode for Claude.ai (HTTP transport + OAuth)#6

Open
digitalhen wants to merge 3 commits into
Pixelworlds:masterfrom
digitalhen:feat/hosted-mode
Open

Add hosted mode for Claude.ai (HTTP transport + OAuth)#6
digitalhen wants to merge 3 commits into
Pixelworlds:masterfrom
digitalhen:feat/hosted-mode

Conversation

@digitalhen

Copy link
Copy Markdown

Summary

  • Adds a hosted MCP server mode (src/hosted.ts) that enables integration with Claude.ai and other remote MCP clients via Streamable HTTP transport
  • Implements OAuth 2.0 with PKCE and dynamic client registration for secure access
  • Includes Docker support (Dockerfile + docker-compose.yml) for easy self-hosting
  • Fixes positional argument mapping in callModularTool — methods like pingSet(data, config) and pingStart(jobid, data, config) now receive arguments in the correct positions instead of as a merged object (affects both stdio and hosted modes)

How it works

The hosted mode (yarn start:hosted or Docker) runs an Express HTTP server that:

  1. Discovers tools at runtime by introspecting the OPNsense client (no build step needed)
  2. Serves MCP over Streamable HTTP at /mcp
  3. Provides OAuth 2.0 endpoints (/authorize, /token, /register) with a simple password gate
  4. Exposes /.well-known/oauth-authorization-server for automatic discovery

The existing stdio mode (index.js) is completely unchanged — this is purely additive.

Setup for Claude.ai

  1. Copy .env.example to .env and fill in OPNsense API credentials + an OAuth password
  2. docker compose up -d --build
  3. Expose via reverse proxy / Cloudflare Tunnel
  4. Add as custom connector in Claude.ai with the /mcp URL

Test plan

  • Full OAuth flow tested end-to-end (registration → authorize → token → MCP calls)
  • MCP initialize handshake works through HTTP transport
  • Auth rejection works with invalid/missing tokens
  • Positional arg fix verified against ping, firewall, and diagnostics methods
  • Existing stdio mode unaffected (no changes to index.js or its generation)

🤖 Generated with Claude Code

Henry Williams and others added 3 commits March 28, 2026 13:48
Adds a hosted MCP server mode (`src/hosted.ts`) that runs alongside
the existing stdio transport. This enables integration with Claude.ai
and other remote MCP clients via Streamable HTTP.

New features:
- HTTP transport with Streamable HTTP (MCP spec compliant)
- OAuth 2.0 with PKCE and dynamic client registration
- Simple password-based authorization flow
- Runtime tool discovery (no build step needed)
- Docker support with Dockerfile and docker-compose.yml

Also fixes positional argument mapping in callModularTool (both stdio
and hosted modes). Methods like pingSet(data, config) now receive
their arguments in the correct positions instead of as a merged object.

The existing stdio mode (index.js) is unchanged and continues to work
with Claude Desktop, Cursor, etc.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude.ai setup instructions, Docker quickstart, Cloudflare Tunnel
guide, OAuth flow explanation, and hosted-mode env vars.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude.ai re-authenticates on every request when expires_in is missing,
treating the token as immediately expired.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant