Package Exports
- mcp-webapi-bridge
- mcp-webapi-bridge/mcp-webapi-bridge.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mcp-webapi-bridge) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
mcp-webapi-bridge
MCP (Model Context Protocol) WebAPI bridge agent for HTTP proxy. Connects MCP clients to servers via HTTP requests and SSE (Server-Sent Events).
安装
全局安装
npm install -g mcp-webapi-bridge本地安装
npm install mcp-webapi-bridge使用方法
作为命令行工具
全局安装后,可以直接使用 mcp-webapi-bridge 命令:
mcp-webapi-bridge <targetUrl> [token]作为本地依赖
npx mcp-webapi-bridge <targetUrl> [token]参数说明
<targetUrl>: MCP 服务器的目标 URL,例如http://127.0.0.1:7001/mcp/task/168f2f91-150b-4480-b0f6-5166f4896245[token]: 可选的认证令牌,格式为自定义的token,比如:Bearer your-token
IDE中的MCP配置
不需要npm install ,直接使用 npx
{
"mcpServers": {
"law-search-server": {
"command": "npx",
"args": [
"mcp-webapi-bridge",
"http://127.0.0.1:7001/mcp/task/168f2f91-150b-4480-b0f6-5166f4896245/sse",
"c14bccba-5b6c-4042-8799-352c3c994ae3"
]
}
}
}环境变量
也可以通过环境变量设置配置:
MCP_TARGET_URL=<url> MCP_TOKEN=<token> mcp-webapi-bridge示例
# 基本用法
mcp-webapi-bridge http://127.0.0.1:7001/mcp/task/xxx
# 带认证令牌
mcp-webapi-bridge http://127.0.0.1:7001/mcp/task/xxx "Bearer your-token"
# 使用环境变量
MCP_TARGET_URL=http://127.0.0.1:7001/mcp/task/xxx MCP_TOKEN="Bearer your-token" mcp-webapi-bridge功能特性
- 连接到 MCP 服务器的 SSE (Server-Sent Events) 流
- 处理 SSE 消息并提取 endpoint URL
- 从 stdin 读取 MCP 客户端的请求
- 将请求转发到 MCP 服务器
- 将服务器的响应转发到 stdout
工作原理
- 工具启动后,会连接到指定的 MCP 服务器 URL
- 建立 SSE 连接,接收服务器发送的消息
- 从消息中提取 endpoint URL,用于后续的请求发送
- 从 stdin 读取 MCP 客户端的请求
- 将请求转发到提取的 endpoint URL
- 将服务器的响应通过 stdout 发送回 MCP 客户端
故障排除
常见问题
- 错误: targetUrl is required
- 原因:未提供目标 URL
- 解决:提供 MCP 服务器的 URL 作为命令行参数或设置 MCP_TARGET_URL 环境变量
- SSE connection error
- 原因:无法连接到 MCP 服务器
- 解决:检查目标 URL 是否正确,服务器是否运行,网络连接是否正常
- No endpoint received
- 原因:服务器未发送 endpoint URL
- 解决:检查 MCP 服务器是否正常运行,是否正确配置
日志
工具会将连接状态、错误信息等输出到 stderr,便于调试。
注意事项
- 工具需要保持运行状态以维持 SSE 连接
- 请确保提供的 token 具有足够的权限访问 MCP 服务器
- 工具仅支持 HTTP 协议,不支持 HTTPS
许可证
MIT License