emcee生成器
为任何使用OpenAPI文档描述的端点生成MCP服务器。
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"twitter": {
"args": [
"--bearer-auth=op://shared/x/credential",
"https://api.twitter.com/2/openapi.json"
],
"command": "emcee"
},
"weather": {
"args": [
"https://api.weather.gov/openapi.json"
],
"command": "emcee"
}
}
}
该服务需要配置环境变量:PUBMED_API_KEY、PUBMED_EMAIL
服务介绍
emcee
emcee 是一个工具,它为任何具有 OpenAPI 规范的 Web 应用程序提供 模型上下文协议 (MCP) 服务器。你可以使用 emcee 将 Claude Desktop 和 其他应用程序 连接到外部工具和数据服务,类似于 ChatGPT 插件。
快速开始
如果你使用 macOS 并已安装 Homebrew,你可以快速上手。
# Install emcee
brew install loopwork-ai/tap/emcee
确保你已经安装了 Claude Desktop。
要配置 Claude Desktop 以与 emcee 一起使用:
- 打开 Claude Desktop 设置 (⌘,)
- 在侧边栏中选择“开发者”部分
- 点击“编辑配置”以打开配置文件
配置文件应位于应用支持目录中。你也可以直接在 VSCode 中使用以下命令打开它:
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
添加以下配置以添加 weather.gov MCP 服务器:
{
"mcpServers": {
"weather": {
"command": "emcee",
"args": [
"https://api.weather.gov/openapi.json"
]
}
}
}
保存文件后,退出并重新打开 Claude。你应该会在聊天框右下角看到 🔨57。点击它可以看到通过 MCP 提供给 Claude 的所有工具列表。
开始一个新的聊天,并询问你所在地区的天气。
波特兰,俄勒冈州的天气怎么样?
Claude 会参考通过 MCP 提供给它的工具,并在认为适合回答你的问题时请求使用其中一个工具。你可以审查这个请求并批准或拒绝它。
如果你允许,Claude 将与 MCP 通信,并使用结果来形成其回应。
[!提示]
构建代理?想要部署远程 MCP 服务器?
请通过 emcee@loopwork.com 联系我们
为什么使用 emcee?
MCP 提供了一种标准化的方法将 AI 模型连接到工具和数据源。尽管这还处于早期阶段,但已经有各种 可用的服务器 可以连接到浏览器、开发工具和其他系统。
我们认为 emcee 是一种方便的方式,可以连接到那些还没有现有 MCP 服务器实现的服务——特别是你自己正在构建的服务。有一个具有 OpenAPI 规范的 Web 应用程序?你可能会惊讶于即使没有仪表板或客户端库,你能做到的程度。
安装
安装脚本
使用 安装脚本 下载并安装适用于你的平台(Linux x86-64/i386/arm64 和 macOS Intel/Apple Silicon)的 预构建版本。
# fish
sh (curl -fsSL https://get.emcee.sh | psub)
# bash, zsh
sh <(curl -fsSL https://get.emcee.sh)
Homebrew
使用 Homebrew 从 Loopwork 的 tap 安装 emcee。
brew install loopwork-ai/tap/emcee
Docker
预构建的带有 emcee 的 Docker 镜像 可用。
docker run -it ghcr.io/loopwork-ai/emcee
从源码构建
需要 go 1.24 或更高版本。
git clone https://github.com/loopwork-ai/emcee.git
cd emcee
go build -o emcee cmd/emcee/main.go
构建完成后,你可以直接运行 (./emcee) 或将其移动到你的 PATH 中的某个位置,例如 /usr/local/bin。
使用方法
Usage:
emcee [spec-path-or-url] [flags]
Flags:
--basic-auth string Basic auth value (either user:pass or base64 encoded, will be prefixed with 'Basic ')
--bearer-auth string Bearer token value (will be prefixed with 'Bearer ')
-h, --help help for emcee
--raw-auth string Raw value for Authorization header
--retries int Maximum number of retries for failed requests (default 3)
-r, --rps int Maximum requests per second (0 for no limit)
-s, --silent Disable all logging
--timeout duration HTTP request timeout (default 1m0s)
-v, --verbose Enable debug level logging to stderr
--version version for emcee
emcee 实现了用于 MCP 的 标准输入/输出 (stdio) 传输,它使用 JSON-RPC 2.0 作为其线格式。
当你从命令行运行 emcee 时,它会启动一个监听标准输入、输出到标准输出并将日志记录到标准错误的程序。
身份验证
对于需要身份验证的 API,emcee 支持几种身份验证方法:
| 身份验证类型 | 示例用法 | 结果头部 |
|---|---|---|
| Bearer Token | --bearer-auth="abc123" |
Authorization: Bearer abc123 |
| Basic Auth | --basic-auth="user:pass" |
Authorization: Basic dXNlcjpwYXNz |
| 原始值 | --raw-auth="Custom xyz789" |
Authorization: Custom xyz789 |
这些身份验证值可以直接提供,也可以作为 1Password 密钥引用 提供。
使用 1Password 引用时:
- 使用格式
op://vault/item/field(例如--bearer-auth="op://Shared/X/credential") - 确保 1Password CLI ([op][op]) 已安装并可从你的
PATH中访问 - 在运行 emcee 或启动 Claude Desktop 之前登录 1Password
# Install op
brew install 1password-cli
# Sign in 1Password CLI
op signin
{
"mcpServers": {
"twitter": {
"command": "emcee",
"args": [
"--bearer-auth=op://shared/x/credential",
"https://api.twitter.com/2/openapi.json"
]
}
}
}
[!IMPORTANT]
当从作为命令参数提供的 URL 下载 OpenAPI 规范时,emcee 不使用身份验证凭据。
如果您的 OpenAPI 规范需要身份验证才能访问,请先使用您首选的 HTTP 客户端将其下载到本地文件,然后将本地文件路径提供给 emcee。
转换 OpenAPI 规范
您可以使用标准的 Unix 工具在将 OpenAPI 规范传递给 emcee 之前进行转换。这适用于:
- 选择特定的端点作为工具公开,使用 [jq][jq] 或 [yq][yq]
- 修改描述或参数,使用 [OpenAPI Overlays][openapi-overlays]
- 合并多个规范,使用 [Redocly][redocly-cli]
例如,您可以使用 jq 仅包含来自 weather.gov 的 point 工具。
cat path/to/openapi.json | \
jq 'if .paths then .paths |= with_entries(select(.key == "/points/{point}")) else . end' | \
emcee
JSON-RPC
您可以通过发送 JSON-RPC 请求直接与提供的 MCP 服务器交互。
[!NOTE]
emcee 仅提供 MCP 工具功能。
其他功能如资源、提示和采样尚不支持。
列出工具
{"jsonrpc": "2.0", "method": "tools/list", "params": {}, "id": 1}
{
"jsonrpc":"2.0",
"result": {
"tools": [
// ...
{
"name": "tafs",
"description": "Returns Terminal Aerodrome Forecasts for the specified airport station.",
"inputSchema": {
"type": "object",
"properties": {
"stationId": {
"description": "Observation station ID",
"type": "string"
}
},
"required": ["stationId"]
}
},
// ...
]
},
"id": 1
}
调用工具
{"jsonrpc": "2.0", "method": "tools/call", "params": { "name": "taf", "arguments": { "stationId": "KPDX" }}, "id": 1}
{
"jsonrpc":"2.0",
"content": [
{
"type": "text",
"text": /* Weather forecast in GeoJSON format */,
"annotations": {
"audience": ["assistant"]
}
}
]
"id": 1
}
调试
MCP Inspector 是一个用于测试和调试 MCP 服务器的工具。如果 Claude 和/或 emcee 没有按预期工作,该检查器可以帮助您理解发生了什么。
npx @modelcontextprotocol/inspector emcee https://api.weather.gov/openapi.json
# 🔍 MCP Inspector is up and running at http://localhost:5173 🚀
open http://localhost:5173
许可证
emcee 采用 Apache License, Version 2.0 许可。