基本能力
产品定位
TheGraph MCP Server 是一个为AI代理提供索引区块链数据的MCP服务器,基于The Graph项目构建。
核心功能
- getSubgraphSchema: 获取指定子图的模式,为AI代理提供生成GraphQL查询所需的上下文。
- 参数:
subgraphId
(子图ID),asText
(输出格式标志) - querySubgraph: 对指定子图执行GraphQL查询。
- 参数:
subgraphId
(子图ID),query
(GraphQL查询字符串)
适用场景
- 区块链数据分析
- 智能合约开发
- 加密货币市场分析
- 区块链数据可视化
工具列表
- getSubgraphSchema: 获取子图的模式,支持JSON和人类可读的GraphQL格式。
- querySubgraph: 执行GraphQL查询,支持手动或AI生成的查询。
常见问题解答
- 如何获取API密钥?需要在环境变量中设置
THEGRAPH_API_KEY
。 - 如何输出人类可读的模式?设置
asText
参数为true
。
使用教程
使用依赖
- Python 3.10+
安装教程
- 克隆仓库
bash
git clone https://github.com/kukapay/thegraph-mcp.git - 客户端配置
json
{
"mcpServers": {
"thegraph-mcp": {
"command": "uv",
"args": ["--directory", "path/to/thegraph-mcp", "run", "main.py"],
"env": {
"THEGRAPH_API_KEY": "your_api_key_here"
}
}
}
}
调试方式
- 确保
THEGRAPH_API_KEY
已正确设置。 - 使用示例提示测试工具功能。
示例提示
模式查询
- "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"
数据查询
- "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..."
分析任务
- "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..."
组合任务
- "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"