claude-os/deployment/mcp-only/DEPLOYMENT_COMPARISON.md
Claude 0e5687b0f1
Add MCP-only deployment package for standalone knowledge base server
This commit adds a complete deployment solution for running Claude OS's
MCP (Model Context Protocol) server as a standalone service, separate
from the full coding environment. This allows other applications to
access the knowledge bases without requiring the CLI or coding tools.

Features:
- Docker-based deployment with Ollama integration
- Automated setup script with model pulling
- Read-only database mounting by default
- CORS and authentication configuration
- Complete API documentation and examples
- Python and JavaScript client examples

Also includes alternative Cloudflare Workers implementation:
- TypeScript starter template
- D1 and Vectorize integration examples
- Migration scripts and documentation
- Deployment comparison guide

Files added:
- deployment/mcp-only/Dockerfile
- deployment/mcp-only/docker-compose.yml
- deployment/mcp-only/requirements.txt
- deployment/mcp-only/setup.sh
- deployment/mcp-only/.env.example
- deployment/mcp-only/.dockerignore
- deployment/mcp-only/README.md
- deployment/mcp-only/DEPLOYMENT_COMPARISON.md
- deployment/mcp-only/examples/chat-integration.py
- deployment/mcp-only/examples/chat-integration.js
- deployment/mcp-only/cloudflare-workers/*

This addresses the need to expose MCP data to other applications
(knowledge base access, live chat) without deploying the full
Claude OS environment to production servers.
2025-11-05 17:46:00 +00:00

11 KiB

Deployment Options: Your Server vs Cloudflare Workers

You have two main options for deploying your MCP server. Here's a detailed comparison to help you choose.

Option 1: Docker on Your Server (This Repo)

What It Is

  • Run the MCP server as a Docker container on your own server
  • Sits alongside your other applications
  • Uses your existing SQLite database directly

Pros ✅

  1. Dead Simple Setup

    • Your database is already there
    • Just mount it as a volume
    • No data migration needed
  2. Zero Code Changes

    • Use the exact Python code from Claude OS
    • No rewriting required
    • Full feature parity
  3. Fast Local Access

    • Your other apps can access via http://mcp-server:8051
    • No network latency
    • Can use Docker networks
  4. Full Control

    • Choose your own models (Ollama)
    • Adjust configuration freely
    • Access to all RAG features (hybrid, rerank, agentic)
  5. Cost

    • Free (you're already paying for the server)
    • No additional services needed
  6. Debugging

    • Direct access to logs
    • Can inspect database
    • Easy to troubleshoot

Cons ❌

  1. Server Requirements

    • Needs ~500MB disk space
    • ~200-500MB RAM
    • Must manage Docker containers
  2. Scaling

    • Limited to your server's resources
    • Need load balancer for multiple instances
  3. Availability

    • Single point of failure
    • Need to manage uptime yourself

When to Choose This

✅ Use Docker on your server if:

  • Your apps are already on that server
  • You want the simplest setup
  • You have a single server or small deployment
  • You want to use your existing database directly
  • You need all RAG features (hybrid search, reranking)
  • You don't need global distribution

Example Architecture

┌──────────────────────────────────┐
│     Your Server                  │
│                                  │
│  ┌──────────┐    ┌──────────┐   │
│  │ Chat App │───▶│MCP Server│   │
│  └──────────┘    └─────┬────┘   │
│                        │         │
│  ┌──────────┐         │         │
│  │ Docs App │─────────┤         │
│  └──────────┘         │         │
│                        ▼         │
│                  ┌──────────┐   │
│                  │SQLite DB │   │
│                  └──────────┘   │
│                                  │
└──────────────────────────────────┘

Option 2: Cloudflare Workers (Like cloudflare_mcp)

What It Is

  • Serverless functions running on Cloudflare's edge network
  • JavaScript/TypeScript only
  • Uses Cloudflare D1 (SQLite) and Vectorize (vectors)

How It Works

  1. Export your SQLite data to Cloudflare D1

    # Export schema and data
    sqlite3 data/claude-os.db .dump > dump.sql
    
    # Import to D1
    wrangler d1 execute claude-os-db --file=dump.sql
    
  2. Rewrite MCP endpoints in JavaScript

    • Translate Python → TypeScript
    • Use Cloudflare APIs instead of SQLiteManager
    • Use Cloudflare AI for embeddings
  3. Deploy to Workers

    wrangler deploy
    

Pros ✅

  1. Global Distribution

    • Runs in 300+ cities worldwide
    • Ultra-low latency for users anywhere
    • Automatic geo-routing
  2. Auto-Scaling

    • Handles 0 to millions of requests
    • No capacity planning
    • Pay per use
  3. High Availability

    • Built-in redundancy
    • 100% uptime SLA (on paid plans)
    • No maintenance windows
  4. No Server Management

    • Completely serverless
    • Automatic updates
    • No Docker, no VMs
  5. Free Tier

    • 100,000 requests/day free
    • 10GB D1 storage free
    • Good for most use cases

Cons ❌

  1. Major Rewrite Required

    • Must port Python → JavaScript/TypeScript
    • Reimplement all RAG logic
    • Could take days/weeks
  2. Cloudflare Limitations

    • D1: 500MB database limit (free tier)
    • Workers: 10ms CPU time per request (free tier)
    • Must use Cloudflare AI models (different from Ollama)
  3. Data Migration

    • Must export SQLite → D1
    • Must export vectors → Vectorize
    • Complex migration process
  4. Limited RAG Features

    • Cloudflare AI has fewer models
    • Harder to implement advanced features
    • No LlamaIndex integration
  5. Debugging

    • Harder to debug serverless
    • Limited logging (on free tier)
    • Can't inspect database easily
  6. Vendor Lock-in

    • Tied to Cloudflare ecosystem
    • Migration away is difficult

When to Choose This

✅ Use Cloudflare Workers if:

  • Your apps are distributed globally
  • You need extreme scalability
  • You want zero server management
  • You're comfortable rewriting in JavaScript
  • Your database is < 500MB (or you can split it)
  • You don't need advanced RAG features

Example Architecture

                Global Users
                     │
                     ▼
         ┌───────────────────────┐
         │  Cloudflare Edge      │
         │  (300+ locations)     │
         │                       │
         │  ┌─────────────────┐  │
         │  │  MCP Worker     │  │
         │  │  (TypeScript)   │  │
         │  └────┬────────────┘  │
         │       │               │
         │       ├──▶ D1 (SQLite)│
         │       └──▶ Vectorize  │
         │                       │
         └───────────────────────┘
                     ▲
                     │
            Your Chat/Docs Apps

Side-by-Side Comparison

Feature Your Server (Docker) Cloudflare Workers
Setup Time 5 minutes Days (rewrite code)
Code Changes None Full rewrite
Data Migration None Complex
Server Management Yes No
Scaling Manual Automatic
Global Latency Higher Ultra-low
Cost (small) $0 (existing server) $0 (free tier)
Cost (large) Fixed Pay-per-use
Database Size Unlimited 500MB (free tier)
RAG Features Full Limited
Model Choice Any (Ollama) Cloudflare AI only
Debugging Easy Harder
Vendor Lock-in None Cloudflare

For Your Use Case

Based on what you described:

  • ✅ You have MCPs populated with data locally
  • ✅ You have other apps that need this data
  • ✅ One needs it as a knowledge base
  • ✅ Another needs it for live chat

I recommend: Start with Docker on your server (Option 1)

Why?

  1. Fastest to deploy - 5 minutes vs days
  2. No code changes - Use existing Python code
  3. No data migration - Mount your existing DB
  4. Full features - All RAG capabilities work
  5. Same server - Your apps can access locally

Migration Path (If Needed Later)

Phase 1: Docker on your server (NOW)
   ↓
   Get your apps working
   Test performance
   Measure traffic
   ↓
Phase 2: Evaluate needs (LATER)
   ↓
   If scaling is needed → Consider Cloudflare
   If working well → Stay with Docker

Quick Start: Docker on Your Server

# 1. Navigate to deployment directory
cd deployment/mcp-only/

# 2. Run setup script
./setup.sh

# 3. Done! MCP server is running at http://localhost:8051

# 4. Update your apps to use:
#    http://mcp-server:8051 (if on same Docker network)
#    http://localhost:8051 (if on same server)

Hybrid Approach (Best of Both Worlds)

You can also do both:

┌────────────────────────────────┐
│  Your Server (Primary)         │
│  ┌────────┐    ┌────────────┐  │
│  │Chat App│───▶│MCP (Docker)│  │
│  └────────┘    └────────────┘  │
│  ┌────────┐          ▲         │
│  │Docs App│──────────┘         │
│  └────────┘                    │
└────────────────────────────────┘
         │
         │ (Optional: Sync to Cloudflare)
         ▼
┌────────────────────────────────┐
│  Cloudflare (Secondary)        │
│  ┌──────────────────────────┐  │
│  │ Read-only MCP (Workers)  │  │
│  │ For public docs search   │  │
│  └──────────────────────────┘  │
└────────────────────────────────┘

Use Docker for:

  • Internal apps (chat, docs)
  • Write operations
  • Full RAG features

Use Cloudflare for:

  • Public-facing documentation search
  • Global users
  • Read-only queries

Example: Cloudflare Workers Code (If You Choose That Path)

See the cloudflare-workers/ directory for a basic example of how to implement the MCP endpoints on Cloudflare Workers.

Note: This is a simplified example. A full implementation would require:

  • Complete D1 database migration
  • Vector embeddings in Vectorize
  • All 12 MCP tools reimplemented
  • Proper error handling and auth
  • Testing and deployment

Decision Flowchart

Do you need global distribution?
├─ No → Use Docker on your server ✅
│
└─ Yes
   │
   Are your apps < 100k requests/day?
   ├─ Yes
   │  │
   │  Is your database < 500MB?
   │  ├─ Yes → Consider Cloudflare Workers
   │  └─ No → Use Docker on your server ✅
   │
   └─ No → Use Docker + CDN or multiple regions

My Recommendation

Start with Docker on your server. It's:

  • ✅ 10x faster to set up
  • ✅ No code changes
  • ✅ Uses your existing data
  • ✅ Full feature set
  • ✅ Easy to debug

Then, if you need global scaling, consider:

  1. Adding a CDN in front of your Docker deployment
  2. Deploying Docker containers in multiple regions
  3. Only then consider Cloudflare Workers (requires significant effort)

Most applications don't need Cloudflare-level scaling. Your Docker deployment will likely handle thousands of requests per second, which is probably more than enough.


Questions?

See:

  • README.md - Full Docker setup guide
  • examples/ - Integration examples
  • cloudflare-workers/ - Cloudflare Workers starter (if you choose that path)