api mind MCP服务器
用于从中发现API的MCP服务器 .mind 规范文件。可与Claude Code、Claude Desktop和任何兼容MCP的AI助手配合使用。
快速开始
# 1. Install spec-mind to generate .mind files from OpenAPI specs
brew install spec-mind
# 2. Run the setup script from your project directory
curl -fsSL https://raw.githubusercontent.com/msegoviadev/api-mind-mcp/main/setup-mcp.sh | bash
# 3. Add your OpenAPI specs and generate .mind files
mkdir specs
cp your-api.yaml specs/
spec-mind sync --no-notation ./specs/
# 4. Restart Claude Code在克劳德代码中:
What APIs are available?
Show me the endpoints for payments
Call GET /payments/{id} in dev______________________________________________________________________
安装
先决条件
安装 规格思维 生成 .mind OpenAPI规范中的文件:
brew install spec-mind设置
跑 setup-mcp.sh 从您的项目目录:
curl -fsSL https://raw.githubusercontent.com/msegoviadev/api-mind-mcp/main/setup-mcp.sh | bash或用于用户范围的安装(所有项目):
curl -fsSL https://raw.githubusercontent.com/msegoviadev/api-mind-mcp/main/setup-mcp.sh | bash -s -- --global脚本:
- 创建一个
specs/项目中的目录 - 在Claude Code中使用正确的规范路径注册api mind
- 支架
~/.config/api-mind/dev.env对于环境默认值
______________________________________________________________________
用法
1.添加您的API规格
# Copy your OpenAPI/Swagger YAML/JSON files to specs/
cp your-api.yaml specs/2.生成.mind文件
spec-mind sync --no-notation ./specs/3.在克劳德代码中使用
User: "What APIs are available?"
Claude: *uses list_apis tool*
"Found 2 APIs: ecommerce, payments"
User: "Show me payment endpoints"
Claude: *uses list_endpoints tool*
"POST /payments [auth: oauth2]
GET /payments/{id}"
User: "Call GET /payments/{id} in dev"
Claude: *uses get_endpoint_schema + get_call_context tools*
"Resolved base URL: https://api.dev.example.com
Calling GET /payments/123..."______________________________________________________________________
工具
list_apis
列出从specs文件夹加载的所有API。
Input: none
Output: JSON with API names, titles, base URLs, and environmentslist_endpoints
列出所有API的端点。
Input:
filter (optional): Substring match on method, path, or section
Output: JSON with environments and endpoint listget_endpoint_schema
返回端点的完整上下文。
Input:
api: API name
method: HTTP method
path: Endpoint path
Output: Text block with base URL, environments, auth, and schema在构造curl之前调用以了解端点契约。
get_call_context
返回执行API调用所需的运行时上下文。
Input:
api: API name
env (optional): Environment to use (dev, stage, uat). Defaults to dev.
Output: Resolved base URL, active environment, and default values for credentials and parameters当用户想要实际调用端点时,在构造curl之前调用此函数。 阅读来源 ~/.config/api-mind/.env 和 ~/.config/api-mind//.env.
______________________________________________________________________
身份验证模式
当 get_endpoint_schema 显示身份验证要求,构造标头:
| 架构中的身份验证 | curl标头 |
|---|---|
None | 无标题 |
bearer | -H 'Authorization: Bearer ' |
oauth2 | -H 'Authorization: Bearer ' |
api_key | -H ': ' |
basic | -H 'Authorization: Basic ' |
______________________________________________________________________
环境默认值
get_call_context 从以下位置读取默认值 ~/.config/api-mind/:
~/.config/api-mind/
dev.env # base defaults for all APIs (dev environment)
stage.env # base defaults for stage
auth0/
dev.env # API-specific overrides for auth0每 .env 文件用途 key=value 格式(以开头的行 # 被忽略)。这 base_url 键会覆盖规范中的占位符URL。
示例 ~/.config/api-mind/dev.env:
base_url=https://api.dev.example.com
auth0_client_id=abc123
auth0_cacert=/etc/ssl/cert.pemsetup-mcp.sh 在第一次运行时脚手架此文件。
______________________________________________________________________
工作流程
list_apis → list_endpoints → get_endpoint_schema → get_call_context → [LLM constructs curl] → bashlist_apis-发现可用的APIlist_endpoints-查找相关端点get_endpoint_schema-获取端点合约(URL、身份验证、模式)get_call_context-解析目标环境的基本URL和凭据- LLM使用解析值构造curl命令
- LLM通过执行
bash工具
______________________________________________________________________
高级配置
Manual installation and team setup
手动安装
claude mcp add --transport stdio api-mind \
--env SPECS_DIR=/absolute/path/to/specs \
-- npx -y @msegoviadev/api-mind-mcp重要提示: 始终使用绝对路径。MCP服务器作为独立进程运行,没有项目上下文。
项目配置(.mcp.json)
创建 .mcp.json 在项目根目录中:
{
"mcpServers": {
"api-mind": {
"command": "npx",
"args": ["-y", "@msegoviadev/api-mind-mcp"],
"env": {
"SPECS_DIR": "/absolute/path/to/specs"
}
}
}
}注: 每个团队成员都需要自己的 .mcp.json 他们的绝对道路。添加 .mcp.json 到 .gitignore.
______________________________________________________________________
发展(贡献者)
git clone https://github.com/msegoviadev/api-mind-mcp
cd api-mind-mcp
npm install
npm run build
# Test locally
node dist/index.js /path/to/specs______________________________________________________________________
相关
许可证
麻省理工学院
