Skip to main content
Glama
mcp-graphql

mcp-graphql

by blurrah

mcp-graphql

铁匠徽章

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

用法

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

环境变量(1.0.0 中的重大变化)

**注意:**从 1.0.0 版本开始,命令行参数已被环境变量取代。

环境变量

描述

默认

ENDPOINT

GraphQL 端点 URL

http://localhost:4000/graphql

HEADERS

包含请求标头的 JSON 字符串

{}

ALLOW_MUTATIONS

启用变异操作(默认禁用)

false

NAME

MCP 服务器的名称

mcp-graphql

SCHEMA

本地 GraphQL 模式文件的路径(可选)

-

示例

# Basic usage with a local GraphQL server
ENDPOINT=http://localhost:3000/graphql npx mcp-graphql

# Using with custom headers
ENDPOINT=https://api.example.com/graphql HEADERS='{"Authorization":"Bearer token123"}' npx mcp-graphql

# Enable mutation operations
ENDPOINT=http://localhost:3000/graphql ALLOW_MUTATIONS=true npx mcp-graphql

# Using a local schema file instead of introspection
ENDPOINT=http://localhost:3000/graphql SCHEMA=./schema.graphql npx mcp-graphql

Related MCP server: mcp4gql

资源

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

可用工具

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

  1. introspect-schema :此工具用于检索 GraphQL 架构。如果您无法将架构作为资源访问,请首先使用此工具。它使用本地架构文件或自省查询。

  2. query-graphql :针对端点执行 GraphQL 查询。默认情况下,除非ALLOW_MUTATIONS设置为true ,否则变更功能处于禁用状态。

安装

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 GraphQL MCP 服务器:

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

手动安装

可以手动安装到 Claude 中:

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

安全注意事项

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

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

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

Available Tools

2 tools
introspect-schemaA

Introspect the GraphQL schema, use this tool before doing a query to get the schema information if you do not have it available as a resource already.

Inputs: endpoint, headers.

query-graphqlC

Query a GraphQL endpoint with the given query and variables

Inputs: query (required), endpoint, headers, variables.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.1/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools have clearly distinct purposes: introspect-schema retrieves schema information, while query-graphql executes queries. There is no overlap or ambiguity between them, making it easy for an agent to select the correct tool.

    Naming Consistency3/5

    The tools use a verb-noun pattern (introspect-schema, query-graphql), which is consistent. However, the hyphenated naming style is less common than snake_case or camelCase, and with only two tools, it's hard to assess full consistency, but they follow the same convention.

    Tool Count2/5

    With only two tools, the server feels thin for a GraphQL domain, which typically involves operations like mutations, subscriptions, or schema updates. While core querying is covered, the scope is limited, potentially requiring agents to work around missing functionality.

    Completeness2/5

    The server covers basic introspection and querying but lacks essential GraphQL operations like mutations (for data modification) or subscriptions (for real-time updates). This creates significant gaps that could lead to agent failures when full lifecycle management is needed.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Turn any GraphQL endpoint into a set of MCP tools
      23
      MIT
    • A
      license
      A
      quality
      Not graded
      maintenance
      GraphQL MCP Server that acts as a bridge allowing MCP clients (like Cursor or Claude Desktop) to interact with target GraphQL APIs through standard tools for schema introspection and operation execution.
      2
      3
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP that can proxy any GraphQL API and expose graphql operations as mcp tools.
      76 npm
      18
      Apache 2.0
    • A
      license
      A
      quality
      B
      maintenance
      Enhanced MCP server for GraphQL with filtered introspection and full variable support.
      14
      2
      47,434 npm
      8
      MIT