Query Blockchain Data via The Graph
Query indexed blockchain data from The Graph - fetch subgraph schemas and run GraphQL queries conversationally.
Why it matters
Access and analyze indexed blockchain data from The Graph. This asset enables AI agents to execute GraphQL queries against subgraphs for detailed blockchain analytics and trading insights.
Outcomes
What it gets done
Retrieve subgraph schemas for context.
Execute GraphQL queries for data extraction.
Analyze blockchain data for trading analytics.
Support natural language queries for data retrieval.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-thegraph-mcp | bash Capabilities
Tools your agent gets
Retrieves the schema of a specified subgraph for AI agents to understand data structure
Executes GraphQL queries to a specified subgraph for blockchain data analysis
Overview
thegraph-mcp server
TheGraph MCP Server lets Claude fetch a subgraph's schema and run GraphQL queries against The Graph's indexed blockchain data. Use it when you know the target subgraph ID and want to explore its schema or query blockchain data like token prices and swaps.
What it does
TheGraph MCP Server gives Claude access to indexed blockchain data from The Graph, letting it fetch a subgraph's schema and execute GraphQL queries against it.
When to use - and when NOT to
Use it to explore a subgraph's data model and then query it, e.g. "Show me the schema for subgraph QmZBQcF... in a readable format," "Find the top 5 tokens by trading volume in the last 24 hours from subgraph QmZBQcF...," "Get the latest 10 swap events from the QmZBQcF... subgraph, including token symbols and amounts," or "First get the schema of QmZBQcF..., then help me write a query to find high-value transactions." It requires knowing the target subgraph ID and is limited to whatever data that subgraph indexes.
Capabilities
getSubgraphSchema(subgraphId, asText): fetches a subgraph's schema, either as human-readable GraphQL (asText=true) or JSON (default).querySubgraph(subgraphId, query): executes a GraphQL query string against a specified subgraph, whether AI-generated or hand-crafted.
How to install
git clone https://github.com/kukapay/thegraph-mcp.git
Configure the client:
{
"mcpServers": {
"thegraph-mcp": {
"command": "uv",
"args": ["--directory", "path/to/thegraph-mcp", "run", "main.py"],
"env": {
"THEGRAPH_API_KEY": "your_api_key_here"
}
}
}
}
Requires Python 3.10+ and a THEGRAPH_API_KEY.
Who it's for
Web3 developers and analysts who want Claude to inspect subgraph schemas and query indexed blockchain data (token prices, swaps, liquidity, trading volume) without hand-writing every GraphQL query.
Source README
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
Installation
- Clone the Repository
git clone https://github.com/kukapay/thegraph-mcp.git - Client 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"
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.