MCP-connect
by: EvalsOne
Enables cloud-based AI services to access local Stdio based MCP servers via HTTP requests
📌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 cool. However, most MCP servers are built on Stdio transport, which, while excellent for accessing local resources, limits their use in cloud-based applications.
MCP Connect is a tiny tool created to solve this problem:
- Cloud Integration: Enables cloud-based AI services to interact with local Stdio based MCP servers
- Protocol Translation: Converts HTTP/HTTPS requests to Stdio communication
- Security: Provides secure access to local resources while maintaining control
- Flexibility: Supports various MCP servers without modifying their implementation
- Easy to use: Just run MCP Connect locally, zero modification to the MCP server
- Tunnel: Built-in support for Ngrok tunnel
By bridging this gap, MCP Connect allows leveraging the full potential of local MCP tools in cloud-based AI applications without compromising on security.
How It Works
+-----------------+ HTTPS/SSE +------------------+ stdio +------------------+
| | | | | |
| Cloud AI tools | <---------------> | Node.js Bridge | <------------> | MCP Server |
| (Remote) | Tunnels | (Local) | | (Local) |
| | | | | |
+-----------------+ +------------------+ +------------------+
Prerequisites
- Node.js
Quick Start
- Clone the repository
git clone https://github.com/EvalsOne/MCP-connect.git cd MCP-connect
- Copy
.env.example
to.env
and configure the port and auth_token:cp .env.example .env
- Install dependencies:
npm install
- Run MCP Connect:
# build MCP Connect npm run build # run MCP Connect npm run start # or, run in dev mode (supports hot reloading by nodemon) npm run dev
MCP Connect should now be running on http://localhost:3000/bridge
.
Note:
- The bridge is designed to run on a local machine, so you need to build a tunnel to the local MCP server accessible from the cloud.
- Ngrok, Cloudflare Zero Trust, and LocalTunnel are recommended for building the tunnel.
Running with Ngrok Tunnel
MCP Connect has built-in support for Ngrok tunnel. To run the bridge with a public URL using Ngrok:
- Get your Ngrok auth token from https://dashboard.ngrok.com/authtokens
- Add it to your
.env
file:NGROK_AUTH_TOKEN=your_ngrok_auth_token
- Run with tunnel:
# Production mode with tunnel npm run start:tunnel # Development mode with tunnel npm run dev:tunnel
After MCP Connect is running, the MCP bridge URL will appear in the console.
API Endpoints
Once MCP Connect is running, these endpoints are exposed:
GET /health
: Health check endpointPOST /bridge
: Main bridge endpoint for receiving requests from the cloud
For example, the following is a configuration of the official GitHub MCP:
{
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-github"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "<your_github_personal_access_token>"
}
}
You can send a request to the bridge to list the tools of the MCP server or call a specific tool.
Listing tools:
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>"
}
}'
Calling a tool:
Using the search_repositories
tool to search for repositories related to modelcontextprotocol
:
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 a simple token-based authentication system. The token is stored in the .env
file. If the token is set, MCP Connect will use it to authenticate requests.
Sample request with token:
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
MIT License