MCP 連接
MCP Connect 是一個工具,能讓基於雲端的 AI 服務訪問本地的 Stdio 基礎模型上下文協議 (MCP) 伺服器,架起本地資源與雲端應用之間的橋樑。
概覽
什麼是 MCP Connect?
MCP Connect 是一個工具,能夠讓基於雲端的 AI 服務訪問本地的基於 Stdio 的模型上下文協議 (MCP) 伺服器,橋接本地資源和雲端應用之間的差距。
如何使用 MCP Connect?
要使用 MCP Connect:
- 克隆倉庫
- 配置環境變數
- 安裝依賴項
- 本地運行應用程序
- 可選地,使用隧道(例如 Ngrok)以便雲端可訪問
MCP Connect 的主要特點
- 雲端整合:將雲端 AI 工具與本地 MCP 伺服器連接
- 協議轉換:將 HTTP/HTTPS 請求轉換為 Stdio 通信
- 安全性:確保安全訪問本地資源
- 靈活性:支持各種 MCP 伺服器而無需修改
- 易於使用:不需要對 MCP 伺服器進行更改
- 隧道支持:內建對 Ngrok 隧道的支持
MCP Connect 的使用案例
- 將本地 AI 工具與基於雲端的應用集成
- 從雲端環境安全訪問本地資源
- 促進雲端服務與本地 MCP 伺服器之間的通信
MCP Connect 的常見問題
MCP Connect 容易設置嗎?
是的!它需要最少的配置,並且可以快速設置。
我可以將 MCP Connect 與任何 MCP 伺服器一起使用嗎?
是的!MCP Connect 設計為可以與各種 MCP 伺服器一起使用,而無需修改。
使用 MCP Connect 的先決條件是什麼?
您需要安裝 Node.js 以運行 MCP Connect。
詳細
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 that is 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, we can leverage 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
and enter the directorygit 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
Now MCP connect should be running on http://localhost:3000/bridge
.
Note:
- The bridge is designed to be run on a local machine, so you still need to build a tunnel to the local MCP server that is 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 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, you can see the MCP bridge URL in the console.
API Endpoints
After MCP Connect is running, there are two endpoints 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 as the following to list the tools of the MCP server and 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 the request.
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)
Using MCP Connect with ConsoleX AI to access local MCP Server
The following is a demo of using MCP Connect to access a local MCP Server on ConsoleX AI:
License
MIT License