TheGraph MCP Server
Allows executing GraphQL queries against specified subgraphs, with tools for fetching schema information and querying data
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@TheGraph MCP Serverget the schema for subgraph QmZBQcF... in readable format"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
TheGraph MCP Server
An MCP server that powers AI agents with indexed blockchain data from The Graph.
Available Tools
1. getSubgraphSchema
Fetches the schema of a specified subgraph, providing AI agents with the context needed to generate GraphQL queries.
Parameters:
subgraphId: The subgraph ID (e.g., "QmZBQcF...")asText: Output format flagtrue: Returns human-readable GraphQL schemafalse: Returns JSON schema (default)
2. querySubgraph
Executes GraphQL queries against a specified subgraph. While queries are typically generated by AI, you can also manually craft your own.
Parameters:
subgraphId: The subgraph IDquery: GraphQL query string
Related MCP server: Subgraph Registry MCP
Installation
Clone the Repository
git clone https://github.com/kukapay/thegraph-mcp.gitClient Configuration
{ "mcpServers": { "thegraph-mcp": { "command": "uv", "args": ["--directory", "path/to/thegraph-mcp", "run", "main.py"], "env": { "THEGRAPH_API_KEY": "your_api_key_here" } } } }
Example Prompts
Here are some natural language prompts to trigger the tools:
Schema Queries
"Show me the schema for subgraph QmZBQcF... in a readable format"
"What's the structure of the QmZBQcF... subgraph? Please display it in GraphQL format"
"I need to understand the data model of subgraph QmZBQcF..., can you fetch its schema?"
Data Queries
"Find the top 5 tokens by trading volume in the last 24 hours from subgraph QmZBQcF..."
"Show me all pairs with liquidity greater than 1 million USD in subgraph QmZBQcF..."
"Get the latest 10 swap events from the QmZBQcF... subgraph, including token symbols and amounts"
Analysis Tasks
"Analyze the trading volume of USDT pairs in the last week using subgraph QmZBQcF..."
"Compare the liquidity of ETH and USDC pairs in subgraph QmZBQcF..."
"Find unusual trading patterns in the last 24 hours from subgraph QmZBQcF..."
Combined Tasks
"First get the schema of QmZBQcF..., then help me write a query to find high-value transactions"
"Check the schema of QmZBQcF... and tell me what fields are available for querying token prices"
"Using subgraph QmZBQcF..., analyze the market impact of large trades by first understanding the schema and then querying relevant events"
License
This project is licensed under the MIT License. See the LICENSE file for details.
Available Tools
2 toolsgetSubgraphSchemaA
Fetch the schema of a specified subgraph using GraphQL introspection.
Args: subgraphId (str): The ID of the subgraph to query. asText (bool): If True, return schema as GraphQL text; otherwise, return JSON.
Returns: str: Schema in JSON or GraphQL text format, or an error message.
| Name | Required | Description | Default |
|---|---|---|---|
| subgraphId | Yes | ||
| asText | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden. It discloses the return format options (JSON or GraphQL text) and mentions error messages, but lacks details about authentication requirements, rate limits, or what happens with invalid subgraph IDs.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with a clear purpose statement followed by Args and Returns sections. It's appropriately sized, though the 'Args' and 'Returns' labels could be more integrated with the flow rather than section headers.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with 2 parameters, no annotations, and no output schema, the description provides good coverage of purpose, parameters, and return behavior. It could be more complete by addressing authentication or error scenarios, but covers the essentials adequately.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 0% schema description coverage, the description fully compensates by clearly explaining both parameters: 'subgraphId' specifies which subgraph to query, and 'asText' controls the return format (text vs JSON). This adds essential meaning beyond the bare schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the specific action ('Fetch the schema') and resource ('specified subgraph using GraphQL introspection'), distinguishing it from the sibling 'querySubgraph' which presumably executes queries rather than fetching schema metadata.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage for obtaining schema information via introspection, but does not explicitly state when to use this tool versus the sibling 'querySubgraph' or provide any exclusions or prerequisites for usage.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
querySubgraphA
Execute a GraphQL query against a specified subgraph.
Args: subgraphId (str): The ID of the subgraph to query. query (str): The GraphQL query string to execute.
Returns: str: Query result in JSON format, or an error message.
| Name | Required | Description | Default |
|---|---|---|---|
| subgraphId | Yes | ||
| query | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool executes queries and returns results or errors, which covers basic functionality. However, it doesn't mention authentication requirements, rate limits, timeout behavior, or whether queries are read-only or can mutate data. The description adds some value but lacks comprehensive behavioral context.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is perfectly structured with a clear purpose statement followed by well-organized sections for Args and Returns. Every sentence earns its place, with no redundant information. The formatting with clear headings makes it easy to parse while remaining extremely concise.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity of GraphQL query execution and the lack of both annotations and output schema, the description provides adequate but minimal information. It covers the basic purpose and parameters but doesn't explain the format of query results beyond 'JSON format', nor does it address error handling, authentication, or other operational considerations that would be helpful for an AI agent.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 0% schema description coverage, the description must compensate for the lack of parameter documentation in the schema. It clearly explains that 'subgraphId' identifies which subgraph to query and 'query' is the GraphQL query string to execute, providing essential semantic meaning beyond the bare schema. However, it doesn't specify format requirements or constraints for these parameters.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the specific action ('Execute a GraphQL query') and resource ('against a specified subgraph'), distinguishing it from the sibling tool 'getSubgraphSchema' which presumably retrieves schema information rather than executing queries. The verb+resource combination is precise and unambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage context by specifying it's for executing GraphQL queries against subgraphs, but doesn't explicitly state when to use this tool versus alternatives like 'getSubgraphSchema' or other query methods. It provides clear context but lacks explicit comparison or exclusion guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
The two tools have clearly distinct purposes: getSubgraphSchema retrieves schema information via introspection, while querySubgraph executes actual GraphQL queries. There is no overlap in functionality, making it easy for an agent to select the correct tool based on the need for metadata versus data retrieval.
Both tools follow a consistent verb_noun pattern (getSubgraphSchema, querySubgraph) using camelCase, which is predictable and readable. The naming convention is uniform across all tools, with no deviations or mixed styles.
With only 2 tools, the server feels thin for interacting with The Graph protocol, which typically involves more operations like listing subgraphs, managing deployments, or handling subscriptions. This limited set may restrict agents from performing comprehensive tasks in the domain.
The tool surface is severely incomplete for a The Graph server, lacking essential operations such as listing available subgraphs, creating or updating subgraphs, and handling mutations or subscriptions. Agents will face dead ends when trying to perform basic lifecycle management or discover subgraphs beyond a known ID.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
The Graph MCP — indexed blockchain data via subgraph GraphQL queries
Provide AI agents and automation tools with contextual access to blockchain data including balance…
Agent-native scoring, search and routing for tokenized real-world assets across multi-chain.
Market data and web intelligence for AI agents, paid per call in USDC on Base via x402.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that powers AI agents with indexed blockchain data from The Graph.3MIT
- AlicenseAqualityAmaintenanceAgent-friendly semantic classification of all subgraphs on The Graph Network. Pre-computed index of 15,500+ subgraphs with domain classification, protocol type detection, schema fingerprinting, canonical entity mapping, and composite reliability scoring.41,159MIT
- AlicenseBqualityDmaintenanceEnables AI assistants to execute GraphQL queries and retrieve schema information from any GraphQL endpoint.21,3308MIT
- AlicenseAqualityDmaintenanceProvides comprehensive GraphQL introspection, filtering, and query/mutation execution with safety controls. Enables AI agents to explore and interact with GraphQL APIs through natural language.7131MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/kukapay/thegraph-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server