Skip to content

Add Modal deployment with OpenRouter integration - #3

Closed
jakemannix wants to merge 1 commit into
mainfrom
feature/modal-deployment
Closed

Add Modal deployment with OpenRouter integration#3
jakemannix wants to merge 1 commit into
mainfrom
feature/modal-deployment

Conversation

@jakemannix

Copy link
Copy Markdown
Owner

Summary

Adds serverless deployment support for the MCP Gateway via Modal, along with OpenRouter integration for user-provided API keys instead of server-side credentials.

Features

Modal Deployment

  • modal_app.py: Complete Modal deployment with separate gateway and UI images
  • Gateway image includes Node.js for npx-based MCP servers
  • Scaledown window (5min) and concurrent request support (max 100 inputs)
  • Registry configuration via REGISTRY_FILE environment variable
  • Fast, reproducible installs using uv

OpenRouter Integration

  • Replaces server-side ANTHROPIC_API_KEY with user-provided OpenRouter key
  • API key stored in browser localStorage (never persisted server-side)
  • OpenAI-compatible API calls to OpenRouter
  • Default model: anthropic/claude-3.5-haiku
  • Privacy-focused: key only used for LLM calls, never logged

New Files

File Purpose
modal_app.py Modal deployment configuration with gateway and UI functions
demo/registries/modal-demo.json Registry optimized for Modal (remote HTTP servers only)
.github/workflows/opencode.yml OpenCode GitHub Actions integration

UI Enhancements

  • API key input field with password masking
  • localStorage persistence with automatic save/load
  • HTMX request header injection for chat endpoint
  • Link to openrouter.ai/keys for API key acquisition
  • Privacy notice about client-side storage

Dependencies

  • Add modal>=1.0.0 as optional dependency (modal extra)
  • Install with: uv sync --extra modal

Deployment

# Install with Modal support
uv sync --extra modal

# Deploy to Modal
uv run modal deploy modal_app.py

# Configure gateway URL (after first deploy)
modal secret create gateway-config \
  GATEWAY_URL=https://YOUR-WORKSPACE--mcp-gateway-demo-gateway.modal.run

# Use full showcase (with subprocess servers)
REGISTRY_FILE=showcase.json uv run modal deploy modal_app.py

Testing

All existing tests pass (204 tests). Modal deployment tested with:

  • Cloudflare Docs server (public, no auth)
  • Cloudflare Radar server (OAuth-protected)
  • Tool renaming and output projection features

🤖 Generated with Claude Code

Modal Deployment:
- modal_app.py: Deploy gateway + UI to Modal serverless platform
- Separate images for gateway (with Node.js for npx servers) and UI
- Scaledown window (5min) and concurrent request support
- Registry configuration via REGISTRY_FILE env var

OpenRouter Integration:
- Replace server-side Anthropic API key with user-provided OpenRouter key
- Client-side localStorage for API key (never persisted server-side)
- OpenAI-compatible API integration with OpenRouter
- Default model: anthropic/claude-3.5-haiku

Registry & Infrastructure:
- modal-demo.json: Cloudflare servers (docs, radar) for Modal deployment
- .github/workflows/opencode.yml: OpenCode GitHub Actions integration

UI Enhancements:
- API key input with localStorage persistence
- Password-masked input field with link to openrouter.ai/keys
- API key injected into HTMX requests via headers
- Privacy notice about client-side storage

Dependencies:
- Add modal>=1.0.0 as optional dependency (modal extra)
- UI image uses uv for fast, reproducible installs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@jakemannix
jakemannix changed the base branch from mcp-gateway-prototype to main January 6, 2026 18:27
@jakemannix jakemannix closed this Jan 9, 2026
@jakemannix
jakemannix deleted the feature/modal-deployment branch January 9, 2026 23:34
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