MCP HubMCP Hub
EvalsOne

MCP-connect

by: EvalsOne

Enables cloud-based AI services to access local Stdio based MCP servers via HTTP requests

103created 21/12/2024
Visit
AI
HTTP

📌Overview

Purpose: MCP Connect is designed to enable cloud-based AI services to interact seamlessly with local Stdio-based MCP servers, overcoming the limitations of traditional transport methods.

Overview: MCP Connect serves as a bridge between cloud applications and local Model Context Protocol (MCP) servers, facilitating secure and flexible communication without requiring modifications to existing server implementations.

Key Features:

  • Cloud Integration: Allows cloud AI tools to communicate efficiently with local MCP servers, expanding their usability.

  • Protocol Translation: Converts HTTP/HTTPS requests to Stdio, enabling smooth interactions with local resources.

  • Security: Ensures secure access to local systems while maintaining user control over resource utilization.

  • Flexibility: Supports various MCP server configurations without necessitating changes to their setup.

  • Easy to Use: Simple setup process that requires no alterations to the MCP server, ensuring quick deployment.

  • Tunnel Support: Built-in functionality for Ngrok tunnels, allowing public access to the bridge.


MCP Connect

The Model Context Protocol (MCP) introduced by Anthropic is innovative, yet most MCP servers rely on Stdio transport, which limits their functionality in cloud-based applications. MCP Connect addresses this issue by providing:

  • Cloud Integration: Facilitates interaction between cloud-based AI services and local Stdio-based MCP servers.
  • Protocol Translation: Converts HTTP/HTTPS requests to Stdio communication.
  • Security: Ensures secure access to local resources while maintaining control.
  • Flexibility: Supports various MCP servers without requiring changes to their implementation.
  • Easy to Use: Operates locally without modifying the MCP server.
  • Tunnel Support: Built-in support for Ngrok tunnel.

By bridging this gap, MCP Connect allows the full potential of local MCP tools to be utilized in cloud-based AI applications securely.

How It Works

+-----------------+     HTTPS/SSE      +------------------+      stdio      +------------------+
|                 |                    |                  |                 |                  |
|  Cloud AI tools | <--------------->  |  Node.js Bridge  | <------------>  |    MCP Server    |
|   (Remote)      |       Tunnels      |    (Local)       |                 |     (Local)      |
|                 |                    |                  |                 |                  |
+-----------------+                    +------------------+                 +------------------+

Prerequisites

  • Node.js

Quick Start

  1. Clone the repository:
    git clone https://github.com/EvalsOne/MCP-connect.git
    cd MCP-connect
    
  2. Configure the environment:
    cp .env.example .env
    
  3. Install dependencies:
    npm install
    
  4. Run MCP Connect:
    npm run build
    npm run start      # Run MCP Connect
    npm run dev       # Run in dev mode (supports hot reloading by nodemon)
    
    MCP Connect should be accessible at http://localhost:3000/bridge.

Note: The bridge must run on a local machine, requiring a tunnel to the local MCP server that is accessible from the cloud. Recommended tools for tunneling include Ngrok, Cloudflare Zero Trust, and LocalTunnel.

Running with Ngrok Tunnel

To utilize Ngrok with MCP Connect:

  1. Obtain your Ngrok auth token from the Ngrok dashboard.
  2. Add to your .env file:
    NGROK_AUTH_TOKEN=your_ngrok_auth_token
    
  3. Start with the Ngrok tunnel:
    npm run start:tunnel   # Production mode with tunnel
    npm run dev:tunnel      # Development mode with tunnel
    
    After starting, you can view the bridge URL in the console.

API Endpoints

MCP Connect exposes the following endpoints:

  • GET /health: Health check endpoint
  • POST /bridge: Main bridge endpoint for receiving requests from the cloud

Example Configuration

To list tools of the MCP server:

curl -X POST http://localhost:3000/bridge \
     -d '{
       "method": "tools/list",
       "serverPath": "npx",
       "args": [
         "-y",
         "@modelcontextprotocol/server-github"
       ],
       "params": {},
       "env": {
         "GITHUB_PERSONAL_ACCESS_TOKEN": "<your_github_personal_access_token>"
       }
     }'

To call a tool, e.g., searching repositories:

curl -X POST http://localhost:3000/bridge \
     -d '{
       "method": "tools/call",
       "serverPath": "npx",
       "args": [
         "-y",
         "@modelcontextprotocol/server-github"
       ],
       "params": {
         "name": "search_repositories",
         "arguments": {
            "query": "modelcontextprotocol"
         }
       },
       "env": {
         "GITHUB_PERSONAL_ACCESS_TOKEN": "<your_github_personal_access_token>"
       }
     }'

Authentication

MCP Connect uses token-based authentication stored in the .env file. To authenticate requests:

curl -X POST http://localhost:3000/bridge \
     -H "Authorization: Bearer <your_auth_token>" \
     -d '{
       "method": "tools/list",
       "serverPath": "npx",
       "args": [
         "-y",
         "@modelcontextprotocol/server-github"
       ],
       "params": {},
       "env": {
         "GITHUB_PERSONAL_ACCESS_TOKEN": "<your_github_personal_access_token>"
       }
     }'

Configuration

Required environment variables:

  • AUTH_TOKEN: Authentication token for the bridge API (optional)
  • PORT: HTTP server port (default: 3000, required)
  • LOG_LEVEL: Logging level (default: info, required)
  • NGROK_AUTH_TOKEN: Ngrok auth token (optional)

License

This project is licensed under the MIT License.