Skip to content

Comments

feat: Add Cloudflare integration for MCPhub#8

Open
codegen-sh[bot] wants to merge 3 commits intomainfrom
codegen-bot/cloudflare-integration
Open

feat: Add Cloudflare integration for MCPhub#8
codegen-sh[bot] wants to merge 3 commits intomainfrom
codegen-bot/cloudflare-integration

Conversation

@codegen-sh
Copy link

@codegen-sh codegen-sh bot commented Aug 13, 2025

Cloudflare Integration for MCPhub

This PR adds Cloudflare integration to MCPhub, allowing you to expose your MCPhub instance through Cloudflare with SSL/TLS encryption and custom domain support.

Features

  • Cloudflare Worker: Proxy requests to MCPhub with proper handling of SSE connections
  • Cloudflare Tunnel: Securely expose local MCPhub instances through Cloudflare's network
  • Client Configuration Generator: Generate client configuration for different deployment scenarios
  • Comprehensive Documentation: Detailed guides for setting up Cloudflare integration

Implementation Details

Cloudflare Worker

The Cloudflare Worker (cloudflare-worker/src/index.js) proxies requests to the MCPhub SSE endpoint, handling:

  • CORS headers
  • Authentication
  • Streaming connections
  • Error handling

Cloudflare Tunnel Setup

The setup script (scripts/setup-cloudflare-tunnel.sh) automates the process of:

  • Installing cloudflared
  • Authenticating with Cloudflare
  • Creating a tunnel
  • Configuring DNS routing
  • Starting the tunnel
  • Generating client configuration

Client Configuration Generator

The generator script (scripts/generate-client-config.js) creates client configuration for:

  • Local deployment
  • Cloudflare deployment
  • With or without API key authentication

Documentation

Comprehensive documentation (docs/CLOUDFLARE_DEPLOYMENT.md) covers:

  • Cloudflare Tunnel setup
  • Cloudflare Worker deployment
  • Client configuration
  • Troubleshooting

Usage

  1. Setup Cloudflare Tunnel:

    chmod +x scripts/setup-cloudflare-tunnel.sh
    DOMAIN="pixeliumperfecto.co.uk" ./scripts/setup-cloudflare-tunnel.sh
  2. Generate Client Configuration:

    node scripts/generate-client-config.js --deployment cloudflare --domain pixeliumperfecto.co.uk
  3. Use the Generated Configuration:

    {
      "mcpServers": {
        "MCPhub": {
          "type": "sse",
          "url": "https://pixeliumperfecto.co.uk/sse",
          "keepAliveInterval": 60000,
          "owner": "admin"
        }
      }
    }

Testing

  • Tested the backend server on port 3001
  • Verified the SSE endpoint is working
  • Generated and validated client configurations for both local and Cloudflare deployments

This PR addresses the requirement to expose MCPhub through Cloudflare at pixeliumperfecto.co.uk:3000/sse.


💻 View my work • 👤 Initiated by @ZeeeepaAbout Codegen
⛔ Remove Codegen from PR🚫 Ban action checks

Description by Korbit AI

What change is being made?

Add a Cloudflare integration for MCPhub by introducing a Cloudflare Worker and a setup for Cloudflare Tunnel, allowing secure access and management of an MCPhub instance through both local and public deployments.

Why are these changes being made?

The changes are made to enhance the accessibility and security of MCPhub by leveraging Cloudflare's network capabilities, including secure SSL/TLS connections, custom domain support, and Server-Sent Events (SSE) management. The integration efforts aim to provide a robust and scalable way to deploy MCPhub for local and public access, solving potential issues of direct server exposure and enhancing user management approach.

Is this description stale? Ask me to generate a new description by commenting /korbit-generate-pr-description

- Add Cloudflare Worker for proxying requests to MCPhub
- Add Cloudflare Tunnel setup script
- Add client configuration generator
- Add documentation for Cloudflare deployment
- Add sample client configuration for Cloudflare

Co-authored-by: Zeeeepa <zeeeepa@gmail.com>
@korbit-ai
Copy link

korbit-ai bot commented Aug 13, 2025

By default, I don't review pull requests opened by bots. If you would like me to review this pull request anyway, you can request a review via the /korbit-review command in a comment.

@coderabbitai
Copy link

coderabbitai bot commented Aug 13, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Join our Discord community for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

codegen-sh bot and others added 2 commits August 13, 2025 02:55
- Update Cloudflare Worker configuration with specific account details
- Add deployment script for Cloudflare Worker
- Update client configuration generator to support API keys
- Generate client configuration for Cloudflare Worker
- Add README for Cloudflare Worker

Co-authored-by: Zeeeepa <zeeeepa@gmail.com>
- Use environment variables for sensitive information
- Add validation for required environment variables
- Improve error handling and user feedback

Co-authored-by: Zeeeepa <zeeeepa@gmail.com>
@codegen-sh
Copy link
Author

codegen-sh bot commented Aug 13, 2025

Cloudflare Worker Integration Update

I've updated the PR with the following changes:

  1. Configured for Your Cloudflare Account:

    • Updated wrangler.toml with your account ID: 2b2a1d3effa7f7fe4fe2a8c4e48681e3
    • Set worker name to: mcp
    • Configured worker URL: https://mcp.pixeliumperfecto.workers.dev
  2. Added Deployment Script:

    • Created scripts/deploy-cloudflare-worker.sh for easy deployment
    • Script handles authentication, configuration, and deployment
    • Generates client configuration automatically
  3. Enhanced Client Configuration:

    • Updated generator to support API keys
    • Added specific worker deployment option
    • Generated configuration for your worker URL
  4. Security Improvements:

    • Removed hardcoded credentials
    • Using environment variables for sensitive information
    • Added validation for required environment variables

Deployment Instructions

  1. Set Environment Variables:

    export CLOUDFLARE_API_KEY="eae82cf159577a8838cc83612104c09c5a0d6"
    export CLOUDFLARE_ACCOUNT_ID="2b2a1d3effa7f7fe4fe2a8c4e48681e3"
  2. Run Deployment Script:

    chmod +x scripts/deploy-cloudflare-worker.sh
    ./scripts/deploy-cloudflare-worker.sh
  3. Use Generated Configuration:

    • The script generates mcphub-worker-config.json with your worker URL
    • This configuration can be used directly with MCP clients

The worker will proxy requests to your MCPhub instance running on port 3001, making it accessible at https://mcp.pixeliumperfecto.workers.dev/sse.

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