# GraphQL模型上下文协议服务器
## 基本信息
- Slug: `launchthatbrand-mcp-graphql`
- Source: modelscope
- Publisher: @launchthatbrand/mcp-graphql
- Categories: databases / developer-tools
- Hosted: Yes
- License: MIT License
- Source URL: https://www.modelscope.cn/mcp/servers/@launchthatbrand/mcp-graphql
## 简介
一种模型上下文协议服务器，通过提供模式内省和查询执行功能，使大型语言模型能够与GraphQL API进行交互。
## 安装提示

```bash
# 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
```

## MCP Server 详情

# mcp-graphql

[![smithery badge](https://smithery.ai/badge/mcp-graphql)](https://smithery.ai/server/mcp-graphql)

一个 Model Context Protocol 服务器，使 LLM 能够与 GraphQL API 进行交互。该实现提供了模式内省和查询执行功能，允许模型动态地发现和使用 GraphQL API。

<a href="https://glama.ai/mcp/servers/4zwa4l8utf"><img width="380" height="200" src="https://glama.ai/mcp/servers/4zwa4l8utf/badge" alt="mcp-graphql MCP server" /></a>

## 使用方法

使用正确的端点运行 `mcp-graphql`，它将自动尝试内省您的查询。

### 命令行参数

| 参数 | 描述 | 默认值 |
|----------|-------------|---------|
| `--endpoint` | GraphQL 端点 URL | `http://localhost:4000/graphql` |
| `--headers` | 包含请求头的 JSON 字符串 | `{}` |
| `--enable-mutations` | 启用变更操作（默认禁用） | `false` |
| `--name` | MCP 服务器名称 | `mcp-graphql` |
| `--schema` | 本地 GraphQL 模式文件路径（可选） | - |

### 示例

```bash
# 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](https://smithery.ai/server/mcp-graphql) 自动为 Claude Desktop 安装 GraphQL MCP 服务器：

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


### 手动安装

可以手动安装到 Claude：
```json
{
    "mcpServers": {
        "mcp-graphql": {
            "command": "npx",
            "args": ["mcp-graphql", "--endpoint", "http://localhost:3000/graphql"]
        }
    }
}
```


## 安全注意事项

默认情况下禁用变更操作，作为一种安全措施，以防止 LLM 修改您的数据库或服务数据。在生产环境中启用变更操作之前请仔细考虑。

## 自定义您的服务器

这是一个非常通用的实现，它允许进行完整的内省，并让您的用户执行任何操作（包括变更）。如果您需要更具体的实现，建议创建自己的 MCP 并限制客户端只能输入特定的查询字段和/或变量。您可以将此作为参考。

