Labsco
f logo

MCP Startup Framework

โ˜… 127

from f

A framework for building MCP servers on Cloudflare Workers with OAuth, PostgreSQL, and Stripe.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeAdvanced setup

MCP Startup Framework

A complete framework for building remote Model Context Protocol (MCP) servers on Cloudflare Workers with OAuth authentication, PostgreSQL database, and Stripe-powered paid tools.

๐Ÿš€ Features

  • ๐Ÿ” OAuth 2.1 Provider - Complete authentication with user registration/login
  • ๐Ÿ—„๏ธ PostgreSQL Integration - Scalable production-ready database with connection pooling
  • ๐Ÿ’ณ Paid Tools Framework - Stripe-powered premium tools with subscription support
  • ๐ŸŒ Platform Agnostic - Optimized for Cloudflare Workers but deployable anywhere (Vercel, Railway, AWS, self-hosted)
  • ๐Ÿ› ๏ธ MCP Tools Framework - Modular tool system with user context
  • ๐Ÿ”Œ REST API Routes - Easy-to-use system for adding custom endpoints
  • ๐ŸŽจ Custom Views - Extensible UI system for privacy policies, ToS, documentation pages
  • ๐Ÿ“ก Streamable HTTP Transport - Works with mcp-remote for local Claude Desktop integration
  • ๐Ÿ“ฑ Cross-Platform - Works on desktop, web, and mobile MCP clients

๐Ÿ› ๏ธ Adding Tools & Routes

Everything starts from src/index.ts:

// Register MCP tools
backend
  .registerTool(registerAddTool)
  .registerTool(registerGreetingTool)
  .registerTool(registerPremiumMathTool);

// Add REST API routes
backend
  .route('GET', '/api/status', (c) => c.json({ status: 'ok' }))
  .authRoute('GET', '/api/profile', (c, userContext) => 
    c.json({ user: userContext })
  );

See Tools Guide and Routes Guide for details.

Custom Views

Extend beyond MCP with custom pages:

// Add privacy policy, terms of service, documentation
backend
  .route('GET', '/privacy', (c) => c.html(generatePrivacyPage()))
  .route('GET', '/terms', (c) => c.html(generateTermsPage()))
  .route('GET', '/docs', (c) => c.html(generateDocsPage()));

See Views Guide for creating custom pages.

๐Ÿ”— Integration Options

Using claude.ai (Pro Plan)

For claude.ai Pro users, you can integrate directly:

  1. Navigate to claude.ai settings
  2. Click "Add Integration"
  3. Enter your server URL: https://your-domain.workers.dev/sse
  4. Complete the OAuth flow

Using Claude Desktop

For local Claude Desktop app:

1. Install MCP Remote Client

npm install -g mcp-remote

2. Configure Claude Desktop

Open Claude Desktop settings: Settings > Developer > Edit Config

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "my-startup": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://your-domain.workers.dev/mcp"
      ]
    }
  }
}

3. Restart Claude Desktop

After saving, restart Claude Desktop. Your MCP tools will appear in the chat interface.

Transport Options

The framework supports multiple transport protocols:

  • Streamable HTTP (default) - /mcp endpoint
  • Server-Sent Events (SSE) - /sse endpoint

Both work seamlessly with mcp-remote for local development and production use.

๐ŸŒ Platform Flexibility

While optimized for Cloudflare Workers, this framework runs anywhere:

  • Vercel: Deploy with @vercel/node runtime
  • Railway: One-click deploy with built-in PostgreSQL
  • AWS Lambda: Use with RDS or Aurora Serverless
  • Google Cloud Run: Deploy with Cloud SQL
  • Self-hosted: Run with Docker on any VPS

Simply update your database connection and deployment configuration!

Production Database

The framework works with any PostgreSQL provider:

  • Neon - Serverless PostgreSQL with autoscaling
  • Supabase - PostgreSQL with real-time features
  • Railway - Managed PostgreSQL with automatic backups
  • Amazon RDS - Enterprise-grade PostgreSQL
  • Cloudflare Hyperdrive - Connection pooling for optimal performance

All providers support the scalability needed for production MCP servers.

๐Ÿ“š Documentation

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ“„ License

MIT License - see LICENSE file for details.