Skip to main content
Glama

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: mcp-graphql-schema

资源

  • 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 并锁定调用工具,以便客户端仅输入特定的查询字段和/或变量。您可以将其用作参考。

One-click Deploy
A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/blurrah/mcp-graphql'

If you have feedback or need assistance with the MCP directory API, please join our Discord server