GS

graphops/subgraph-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

8 stars 6 forks 质量 58 趋势 16Apache-2.0

A Model Context Protocol (MCP) server that allows LLMs to interact with Subgraphs available on The Graph Network.

概览

A Model Context Protocol (MCP) server that allows LLMs to interact with Subgraphs available on The Graph Network. - Get the GraphQL schema for any subgraph/deployment - Execute GraphQL queries against any subgraph/deployment - Find the top subgraph deployments for a contract address on a specific chain - Search for subgraphs by keyword - Get 30-day query volume for subgraph deployments - Supports MCP resources, tools, and prompts - Can run in STDIO mode or as an SSE (Server-Sent Events) server The subgraph-mcp server offers two primary ways to interact with The Graph Network: This is the quickest way to get started. You can configure your MCP client (e.g., Claude Desktop) to connect to our hosted subgraph-mcp service. - A Gateway API key for The Graph Network. Add the following to your configuration file of your client (e.g.,claude_desktop_config.json): Replace YOUR_GATEWAY_API_KEY with your actual Gateway API key. After adding the configuration, restart your MCP client.

README

以下为原文 README 节选,完整内容请查看原文。

Subgraph MCP Server

A Model Context Protocol (MCP) server that allows LLMs to interact with Subgraphs available on The Graph Network.

Features

  • Get the GraphQL schema for any subgraph/deployment
  • Execute GraphQL queries against any subgraph/deployment
  • Find the top subgraph deployments for a contract address on a specific chain
  • Search for subgraphs by keyword
  • Get 30-day query volume for subgraph deployments
  • Supports MCP resources, tools, and prompts
  • Can run in STDIO mode or as an SSE (Server-Sent Events) server

Usage

The subgraph-mcp server offers two primary ways to interact with The Graph Network:

  1. Connecting to the Remote Hosted MCP Service (Recommended for most users)
  2. Building and Running the Server Locally

Connecting to the Remote Hosted MCP Service

This is the quickest way to get started. You can configure your MCP client (e.g., Claude Desktop) to connect to our hosted subgraph-mcp service.

Requirements

  • A Gateway API key for The Graph Network.

Configuration

Add the following to your configuration file of your client (e.g.,claude_desktop_config.json):

{
  "mcpServers": {
    "subgraph-mcp": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "--header",
        "Authorization:${AUTH_HEADER}",
        "https://subgraphs.mcp.thegraph.com/sse"
      ],
      "env": {
        "AUTH_HEADER": "Bearer YOUR_GATEWAY_API_KEY" // <-- Replace with your actual key
      }
    }
  }
}

Replace YOUR_GATEWAY_API_KEY with your actual Gateway API key. After adding the configuration, restart your MCP client.

Once configured, you can skip to the “Available Tools” or “Natural Language Queries” sections to learn how to interact with the service.

Building and Running the Server Locally

This option is for users who prefer to build, run, and potentially modify the server on their own machine.

Requirements (for Local Execution)

  • Rust (latest stable version recommended: 1.75+).
    You can install it using the following command on macOS, Linux, or other Unix-like systems: \
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    
    Follow the on-screen instructions. For other platforms, see the official Rust installation guide.
  • A Gateway API key for The Graph Network.

Installation (for Local Execution)

# Clone the repository
git clone [email protected]:graphops/subgraph-mcp.git
cd subgraph-mcp

# Build the project
cargo build --release

Configuration (for Local Execution)

Add the following to your configuration file of your client (e.g.,claude_desktop_config.json):

{
  "mcpServers": {
    "subgraph-mcp": {
      "command": "/path/to/your/subgraph-mcp/target/release/subgraph-mcp", // <-- Replace this with the actual path!
      "env": {
        "GATEWAY_API_KEY": "YOUR_GATEWAY_API_KEY" // <-- Replace with your actual key
      }
    }
  }
}
在 GitHub 查看完整 README

安装

npx mcp-remote --header Authorization:${AUTH_HEADER} https://subgraphs.mcp.thegraph.com/sse
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "subgraph-mcp": { "command": "npx", "args": [ "mcp-remote", "--header", "Authorization:${AUTH_HEADER}", "https://subgraphs.mcp.thegraph.com/sse" ], "env": { "AUTH_HEADER": "Bearer YOUR_GATEWAY_API_KEY" // <-- Replace with your actual key } } } }