thegraph-mcp 是一个基于 MCP(模型上下文协议)的服务器,其核心目标是为 AI 智能体接入 The Graph 的索引区块链数据。根据仓库提供的资料,它面向需要访问链上索引数据的场景,使 AI 智能体能够获取子图结构并执行 GraphQL 查询。
主要能力 该项目目前提供两个工具:
- getSubgraphSchema:获取指定子图的 schema,为 AI 智能体生成 GraphQL 查询提供所需上下文。参数包括 subgraphId(子图 ID,例如 "QmZBQcF...")和 asText(输出格式标志)。asText 为 true 时返回人类可读的 GraphQL schema;为 false 时返回 JSON schema(默认值)。
- querySubgraph:针对指定子图执行 GraphQL 查询。参数包括 subgraphId(子图 ID)和 query(GraphQL 查询字符串)。资料说明,查询通常由 AI 生成,但也可以手动编写。
使用方式 克隆仓库: 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 " } } } }
适用场景 资料列出了可用于触发的自然语言提示示例,涵盖以下用途:查看或理解某个子图的 schema 结构与数据模型;查询交易量、流动性等链上指标;获取 swap 事件及其代币符号与金额;分析交易量趋势、比较不同交易对的流动性、发现异常交易模式;以及先获取 schema 再编写查询来定位高价值交易、查询代币价格字段等。
示例提示包括:
- "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"
限制 该资料未说明收费、价格、性能表现或除上述两个工具之外的其他功能。使用需要配置 THEGRAPH_API_KEY 环境变量。项目采用 MIT 许可证,具体细节见仓库中的 LICENSE 文件。