TheGraph MCP Server
TheGraph MCP 服务器
MCP 服务器使用来自The Graph的索引区块链数据为 AI 代理提供支持。
可用工具
1. 获取子图模式
获取指定子图的模式,为 AI 代理提供生成 GraphQL 查询所需的上下文。
参数:
subgraphId:子图 ID(例如“QmZBQcF...”)asText:输出格式标志true:返回人类可读的 GraphQL 模式false:返回 JSON 模式(默认)
2. 查询子图
针对指定子图执行 GraphQL 查询。虽然查询通常由 AI 生成,但您也可以手动创建自己的查询。
参数:
subgraphId:子图IDquery:GraphQL 查询字符串
Related MCP server: Subgraph Registry MCP
安装
克隆存储库
git clone https://github.com/kukapay/thegraph-mcp.git客户端配置
{ "mcpServers": { "thegraph-mcp": { "command": "uv", "args": ["--directory", "path/to/thegraph-mcp", "run", "main.py"], "env": { "THEGRAPH_API_KEY": "your_api_key_here" } } } }
示例提示
以下是一些触发该工具的自然语言提示:
架构查询
“以可读格式向我展示子图 QmZBQcF 的架构……”
“QmZBQcF...子图的结构是什么?请以 GraphQL 格式显示它”
“我需要了解子图 QmZBQcF 的数据模型...,您能获取它的模式吗?”
数据查询
“从子图 QmZBQcF 中查找过去 24 小时内交易量排名前 5 的代币……”
“显示子图 QmZBQcF 中所有流动性大于 100 万美元的货币对...”
“从 QmZBQcF... 子图获取最新的 10 个交换事件,包括代币符号和金额”
分析任务
“使用子图 QmZBQcF 分析上周 USDT 对的交易量……”
“比较子图 QmZBQcF 中 ETH 和 USDC 对的流动性……”
“从子图 QmZBQcF 中查找过去 24 小时内的异常交易模式...”
组合任务
“首先获取 QmZBQcF 的模式......然后帮我编写一个查询来查找高价值交易”
“检查 QmZBQcF 的模式......并告诉我哪些字段可用于查询代币价格”
“使用子图 QmZBQcF...,通过首先了解模式然后查询相关事件来分析大额交易的市场影响”
执照
本项目遵循 MIT 许可证。详情请参阅LICENSE文件。
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.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
2 tool updates
- First observed
getSubgraphSchema - First observed
querySubgraph
TDQS
Scored across 2 tools
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
Related MCP Connectors
Pay-per-call Base and Polygon onchain data over x402 for AI agents.
Market and on-chain crypto data for AI agents. Pay per call in USDC on Base (x402).
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.
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.4146 npmMIT
- AlicenseBqualityDmaintenanceEnables AI assistants to execute GraphQL queries and retrieve schema information from any GraphQL endpoint.2141 npm8MIT
- 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.76 npm1MIT