mcp-graphql

mcp-graphql

用于GraphQL的模型上下文协议服务器。

smithery 徽章 mcp-graphql MCP 服务器

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"}'

命令行选项

参数描述默认值
--endpointGraphQL 端点 URLhttp://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"]
        }
    }
}

可用工具

  1. introspect-schema: 检索 GraphQL 模式
  2. query-graphql: 执行 GraphQL 查询

安全注意事项

默认禁用变异操作以保护您的数据。在生产环境中启用变异前请谨慎考虑。