j

jorgeraad

@jorgeraad/mcp4gql
0 Stars 300 次浏览 jorgeraad 更新于 2026-08-23

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "mcp4gql": {
      "args": [
        "-y",
        "mcp4gql"
      ],
      "command": "npx",
      "env": {
        "AUTH_TOKEN": "YOUR_OPTIONAL_AUTH_TOKEN",
        "GRAPHQL_ENDPOINT": "YOUR_GRAPHQL_ENDPOINT_URL"
      }
    }
  }
}

可用工具 (2 个)

该服务在 MCP 协议中暴露的工具,AI 可按需调用

introspectGraphQLSchema

Fetches the schema of the target GraphQL API using introspection. Returns the schema in JSON format.

该工具无需必填参数,直接调用即可

executeGraphQLOperation 3 个参数 需填 1 项

Executes an arbitrary GraphQL query or mutation against the target API. Use introspectGraphQLSchema first to understand the available operations.

必填参数:query

服务介绍

mcp4gql - GraphQL MCP 服务器

smithery 徽章

mcp4gql

该项目是一个 Node.js/TypeScript 服务器,实现了模型上下文协议(MCP)。它充当桥梁,允许 MCP 客户端(如 Cursor)与目标 GraphQL API 进行交互。

功能

  • MCP 服务器: 实现了来自 @modelcontextprotocol/sdk 的 MCP Server 类。
  • 标准输入输出传输: 通过标准输入输出与客户端通信。
  • GraphQL 客户端: 使用 axios 向配置的 GraphQL 端点发送请求。
  • 通用 GraphQL 工具: 向 MCP 客户端暴露以下工具:
    • introspectGraphQLSchema:使用内省获取目标 GraphQL API 的模式。
    • executeGraphQLOperation:对目标 API 执行任意 GraphQL 查询或变更,接受 query、可选的 variables 和可选的 operationName 作为输入。

配置

服务器需要以下环境变量:

  • GRAPHQL_ENDPOINT:目标 GraphQL API 的 URL。
  • AUTH_TOKEN:用于 Authorization: Bearer <token> 头部的身份验证令牌(可选)。

客户端配置

为了让像 Cursor 或 Claude Desktop 这样的客户端使用此服务器提供的工具,你需要配置它们以运行 npx 命令。

Cursor

  1. 转到 Cursor MCP 设置(Cursor > 设置 > Cursor 设置 > MCP)

  2. 转到 + 添加新的全局 MCP 服务器

  3. 将以下内容添加到你的 Cursor MCP 配置中:

    json
    {
    "mcpServers": {
    "mcp4gql": {
    "command": "npx",
    "type": "stdio",
    "args": ["-y", "mcp4gql"],
    "env": {
    "GRAPHQL_ENDPOINT": "YOUR_GRAPHQL_ENDPOINT_URL",
    "AUTH_TOKEN": "YOUR_OPTIONAL_AUTH_TOKEN"
    }
    }
    }
    }

Claude Desktop

  1. 打开 Claude Desktop 设置(Claude > 设置)。

  2. 转到开发者 > 编辑配置。

  3. 在配置中添加以下内容:

    json
    {
    "mcpServers": {
    "mcp4gql": {
    "command": "npx",
    "args": ["-y", "mcp4gql"],
    "env": {
    "GRAPHQL_ENDPOINT": "YOUR_GRAPHQL_ENDPOINT_URL",
    "AUTH_TOKEN": "YOUR_OPTIONAL_AUTH_TOKEN"
    }
    }
    }
    }

配置完成后,MCP 客户端应该能够列出并调用此服务器提供的 introspectGraphQLSchemaexecuteGraphQLOperation 工具。请记得在配置中设置所需的环境变量 (GRAPHQL_ENDPOINT 和可选的 AUTH_TOKEN),以便服务器可以连接到你的 API。

相关 MCP 服务