GraphQL MCP Toolkit

Integrations

  • Enables interaction with GraphQL APIs by providing schema introspection and query execution capabilities, allowing models to discover and use GraphQL APIs dynamically.

mcp-graphql

模型上下文协议 (MLM) 服务器,使 LLM 能够与 GraphQL API 交互。此实现提供了架构自检和查询执行功能,允许模型动态发现和使用 GraphQL API。

用法

使用正确的端点运行mcp-graphql ,它将自动尝试检查您的查询。

命令行参数

争论描述默认
--endpointGraphQL 端点 URLhttp://localhost:4000/graphql
--headers包含请求标头的 JSON 字符串{}
--enable-mutations启用变异操作(默认禁用)false
--nameMCP 服务器的名称mcp-graphql
--schema本地 GraphQL 模式文件的路径(可选)-

示例

# Basic usage with a local GraphQL server npx mcp-graphql --endpoint http://localhost:3000/graphql # Using with custom headers npx mcp-graphql --endpoint https://api.example.com/graphql --headers '{"Authorization":"Bearer token123"}' # Enable mutation operations npx mcp-graphql --endpoint http://localhost:3000/graphql --enable-mutations # Using a local schema file instead of introspection npx mcp-graphql --endpoint http://localhost:3000/graphql --schema ./schema.graphql

可用工具

该服务器提供两个主要工具:

  1. introspect-schema :此工具用于检索 GraphQL 架构。如果您无法将架构作为资源访问,请首先使用此工具。它使用本地架构文件或自省查询。
  2. query-graphql :针对端点执行 GraphQL 查询。默认情况下,除非指定--enable-mutations否则变更功能处于禁用状态。

资源

  • graphql-schema :服务器将 GraphQL 架构公开为客户端可以访问的资源。这可以是本地架构文件,也可以是基于自省查询的。

安装

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 GraphQL MCP Toolkit:

npx -y @smithery/cli install mcp-graphql --client claude

手动安装

可以手动安装到 Claude 中:

{ "mcpServers": { "mcp-graphql": { "command": "npx", "args": ["mcp-graphql", "--endpoint", "http://localhost:3000/graphql"] } } }

安全注意事项

出于安全考虑,更改功能默认处于禁用状态,以防止 LLM 修改您的数据库或服务数据。在生产环境中启用更改之前,请仔细考虑。

为您自己的服务器进行定制

这是一个非常通用的实现,它允许完全自省,并允许用户执行任何操作(包括修改)。如果您需要更具体的实现,我建议您创建自己的 MCP 并锁定调用工具,以便客户端仅输入特定的查询字段和/或变量。您可以将其用作参考。

-
security - not tested
F
license - not found
-
quality - not tested

模型上下文协议服务器通过提供模式自省和查询执行功能,使 LLM 能够与 GraphQL API 交互。

  1. Usage
    1. Command Line Arguments
    2. Examples
  2. Available Tools
    1. Resources
      1. Installation
        1. Installing via Smithery
        2. Installing Manually
      2. Security Considerations
        1. Customize for your own server
          ID: 522wo98jd7