Docs
Search⌘ K
  • Home
  • حول The Graph
  • الشبكات المدعومة
  • Protocol Contracts
  • Subgraphs
    • متعدد-السلاسل
      • Token API
        • Hypergraph
          • AI Suite
            • Indexing
              • Resources
                AI Suite > Subgraph MCP

                2 minutes

                Cline

                This guide walks you through the integration of Subgraph Model Context Protocol⁠ (MCP) to access Subgraph data through natural language conversations with Cline.

                Prerequisites

                • Cline⁠ installed (latest version)
                • A Gateway API key from Subgraph Studio
                • npx⁠ or bunx⁠ installed and available in your path

                Configuration Steps

                1. Open Configuration File

                Create or edit your cline_mcp_settings.json file.

                MCP Servers > Installed > Configure MCP Servers

                2. Add Configuration

                1{2  "mcpServers": {3    "subgraph": {4      "command": "npx",5      "args": ["mcp-remote", "--header", "Authorization:${AUTH_HEADER}", "https://subgraphs.mcp.thegraph.com/sse"],6      "env": {7        "AUTH_HEADER": "Bearer GATEWAY_API_KEY"8      }9    }10  }11}

                3. Add Your API Key

                Replace GATEWAY_API_KEY with your API key from Subgraph Studio.

                Using The Graph Resource in Cline

                After configuring Cline:

                1. Restart Cline
                2. Start a new conversation
                3. Enable the Subgraph MCP from the context menu
                4. Add “Subgraph Server Instructions” as a resource to your chat context

                Available Tools and Usage

                The Subgraph MCP provides several tools for interacting with Subgraphs:

                Schema Retrieval Tools

                • Get schema by deployment ID: Access the GraphQL schema using a deployment ID (0x…)
                • Get schema by Subgraph ID: Access the schema for the current deployment of a Subgraph (5zvR82…)
                • Get schema by IPFS hash: Access the schema using a Subgraph’s IPFS manifest hash (Qm…)

                Query Execution Tools

                • Execute query by deployment ID: Run GraphQL queries against specific, immutable deployments
                • Execute query by Subgraph ID: Run GraphQL queries against the latest version of a Subgraph

                Discovery Tools

                • Get top Subgraph deployments: Find the top 3 Subgraph deployments indexing a specific contract on a particular chain

                Natural Language Queries

                One of the most powerful features of the Subgraph MCP integration is the ability to ask questions in natural language. Cline will:

                1. Understand your goal (lookup, find Subgraphs, query, get schema)
                2. Find relevant deployments if needed
                3. Fetch and interpret the Subgraph schema
                4. Convert your question into an appropriate GraphQL query
                5. Execute the query and present the results in a readable format

                Example Natural Language Queries

                1What are the pairs with maximum volume on deployment 0xde0a7b5368f846f7d863d9f64949b688ad9818243151d488b4c6b206145b9ea3?
                1Which tokens have the highest market cap in this Subgraph?
                1Show me the most recent 5 swaps for the USDC/ETH pair

                Key Identifier Types

                When working with Subgraphs, you’ll encounter different types of identifiers:

                • Subgraph ID (e.g., 5zvR82...): Logical identifier for a Subgraph
                • Deployment ID (e.g., 0x4d7c...): Identifier for a specific, immutable deployment
                • IPFS Hash (e.g., QmTZ8e...): Identifier for the manifest of a specific deployment
                ⁠Edit on GitHub⁠

                Claude DesktopCursor
                On this page
                • Prerequisites
                • Configuration Steps
                • 1. Open Configuration File
                • 2. Add Configuration
                • 3. Add Your API Key
                • Using The Graph Resource in Cline
                • Available Tools and Usage
                • Schema Retrieval Tools
                • Query Execution Tools
                • Discovery Tools
                • Natural Language Queries
                • Example Natural Language Queries
                • Key Identifier Types
                The GraphStatusTestnetBrand AssetsForumSecurityPrivacy PolicyTerms of Service