MCP Startup Framework

MCP Startup Framework

A comprehensive framework for building remote MCP servers on Cloudflare Workers featuring OAuth 2.1 authentication, PostgreSQL integration, and Stripe-powered paid tools. It enables developers to create scalable, platform-agnostic MCP tools with support for user registration and subscription-based functionality.

Category
访问服务器

README

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

⚡ Quick Start

Prerequisites

  • Node.js 18+
  • Cloudflare account
  • PostgreSQL database (see database setup)
  • Stripe account (for paid tools)

Installation

# Clone the repository
git clone https://github.com/f/mcp-startup-framework
cd mcp-startup-framework

# Install dependencies
npm install

# Copy environment template
cp .dev.vars.example .dev.vars

Configuration

Edit .dev.vars with your settings:

DATABASE_URL="postgresql://username:password@host:port/database"
JWT_SECRET="your-super-secret-jwt-key"
COOKIE_ENCRYPTION_KEY="32-character-encryption-key"
STRIPE_SECRET_KEY="sk_test_your_stripe_key"
STRIPE_PRICE_ID_FOR_PREMIUM_MATH="price_your_stripe_price_id"
BASE_URL="https://your-domain.workers.dev"

Development

# Start development server
npm run dev

# Initialize database (in another terminal)
curl -X POST http://localhost:8787/init-db

# Visit http://localhost:8787 to register/login

🛠️ 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.

🚀 Deployment

# Set production secrets
wrangler secret put JWT_SECRET
wrangler secret put COOKIE_ENCRYPTION_KEY
wrangler secret put STRIPE_SECRET_KEY

# Set custom price IDs per paid tool
wrangler secret put STRIPE_PRICE_ID_FOR_PREMIUM_MATH

# Deploy to Cloudflare
npm run deploy

See Deployment Guide for full instructions.

🔗 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.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选