thegraph-mcp is a server based on MCP (Model Context Protocol), whose core goal is to connect AI agents to The Graph's indexed blockchain data. According to the information provided by the repository, it is aimed at scenarios that require access to on-chain indexed data, enabling AI agents to obtain subgraph structures and execute GraphQL queries.
Main capabilities This project currently provides two tools:
- getSubgraphSchema: obtains the schema of a specified subgraph, providing the required context for AI agents to generate GraphQL queries. The parameters include subgraphId (subgraph ID, for example "QmZBQcF...") and asText (output format flag). When asText is true, it returns a human-readable GraphQL schema; when false, it returns a JSON schema (default value).
- querySubgraph: executes a GraphQL query against a specified subgraph. The parameters include subgraphId (subgraph ID) and query (GraphQL query string). The information states that queries are usually generated by AI, but they can also be written manually.
Usage Clone the repository: git clone https://github.com/kukapay/thegraph-mcp.git
Client configuration example: { "mcpServers" : { "thegraph-mcp" : { "command" : " uv " , "args" : [ " --directory " , " path/to/thegraph-mcp " , " run " , " main.py " ], "env" : { "THEGRAPH_API_KEY" : " your_api_key_here " } } } }
Applicable scenarios The information lists examples of natural language prompts that can be used for triggering, covering the following uses: viewing or understanding the schema structure and data model of a subgraph; querying on-chain metrics such as trading volume and liquidity; obtaining swap events and their token symbols and amounts; analyzing trading volume trends, comparing the liquidity of different trading pairs, and discovering unusual trading patterns; and first obtaining the schema and then writing queries to locate high-value transactions, query token price fields, and so on.
Example prompts include:
- "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?"
- "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"
- "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..."
- "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"
Limitations The information does not describe fees, pricing, performance, or other features beyond the above two tools. Usage requires configuring the THEGRAPH_API_KEY environment variable. The project uses the MIT license, and specific details can be found in the LICENSE file in the repository.