mcp-graphql
用于GraphQL的模型上下文协议服务器。
MCP-GraphQL 是一个模型上下文协议服务器,让大语言模型能够发现并与 GraphQL API 交互。
基本用法
# 基本用法
npx mcp-graphql --endpoint http://localhost:3000/graphql
# 添加认证头
npx mcp-graphql --endpoint https://api.example.com/graphql --headers '{"Authorization":"Bearer token123"}'
命令行选项
参数 | 描述 | 默认值 |
---|---|---|
--endpoint | GraphQL 端点 URL | http://localhost:4000/graphql |
--headers | 请求头 (JSON 格式) | {} |
--enable-mutations | 启用变异操作 | false |
--schema | 本地模式文件路径 | - |
--name | 服务器名称 | mcp-graphql |
主要功能
- 内省: 自动发现 GraphQL 模式
- 执行查询: 允许模型执行 GraphQL 查询
- 安全性: 默认禁用变异操作
安装
使用 Smithery (推荐)
npx -y @smithery/cli install mcp-graphql --client claude
手动安装到 Claude
{
"mcpServers": {
"mcp-graphql": {
"command": "npx",
"args": ["mcp-graphql", "--endpoint", "http://localhost:3000/graphql"]
}
}
}
可用工具
- introspect-schema: 检索 GraphQL 模式
- query-graphql: 执行 GraphQL 查询
安全注意事项
默认禁用变异操作以保护您的数据。在生产环境中启用变异前请谨慎考虑。