The Graph MCP Skill
Use this skill to run The Graph Subgraph MCP operations through uxc using the native SSE MCP endpoint.
Reuse the uxc skill for generic protocol discovery, envelope parsing, and error handling rules.
Prerequisites
- -
uxc is installed and available in PATH. - Network access to
https://subgraphs.mcp.thegraph.com/sse. - The Graph Gateway API key is available for authenticated calls.
Core Workflow (The Graph-Specific)
Endpoint candidate inputs before finalizing:
- - Official remote MCP endpoint:
- INLINECODE5
- 1. Verify protocol/path from official source and probe:
- Official source:
https://thegraph.com/docs/en/ai-suite/subgraph-mcp/introduction/
- probe candidate endpoint with:
-
uxc https://subgraphs.mcp.thegraph.com/sse -h
- Confirm protocol is MCP (
protocol == "mcp" in envelope).
- 2. Detect auth requirement explicitly:
- Run host help or a minimal read call and inspect envelope.
- This endpoint requires a The Graph Gateway API key sent as
Authorization: Bearer <key>.
- 3. Register credential and use fixed link command by default:
-
uxc auth credential set thegraph --secret-env THEGRAPH_API_KEY
-
uxc auth binding add --id thegraph-sse --host subgraphs.mcp.thegraph.com --path-prefix /sse --scheme https --credential thegraph --priority 100
-
command -v thegraph-mcp-cli
- If missing, create it:
-
uxc link thegraph-mcp-cli https://subgraphs.mcp.thegraph.com/sse
-
thegraph-mcp-cli -h
- If command conflict is detected and cannot be safely reused, stop and ask skill maintainers to pick another fixed command name.
- 4. Inspect operation schema before execution:
-
thegraph-mcp-cli -h
-
thegraph-mcp-cli <operation> -h
- 5. Prefer discovery/schema operations first:
- find candidate subgraphs or deployments
- inspect schema
- execute query only after identifier and schema are understood
Capability Map
- search subgraphs by keyword
- find top deployments for a contract
- inspect deployment popularity / 30-day query volume
- get schema by deployment ID
- get schema by subgraph ID
- get schema by IPFS hash
- execute GraphQL query by deployment ID
- execute GraphQL query by subgraph ID
- execute GraphQL query by IPFS hash
Guardrails
- - Keep automation on JSON output envelope; do not rely on
--text. - Parse stable fields first:
ok, kind, protocol, data, error. - Use
thegraph-mcp-cli as default command path. - INLINECODE24 is equivalent to
uxc https://subgraphs.mcp.thegraph.com/sse <operation> ... when the same auth binding is configured. - Use direct
uxc "<endpoint>" ... only as temporary fallback when link setup is unavailable. - Prefer discovery and schema inspection before query execution.
- For production/stable workflows, prefer deployment-oriented selection over loosely changing latest-version references.
- Keep GraphQL query scope small on first pass:
- add filters
- add limits
- fetch only required fields
- confirm
uxc auth credential info thegraph succeeds
- confirm
uxc auth binding match https://subgraphs.mcp.thegraph.com/sse resolves to
thegraph
- rerun INLINECODE30
Tested Real Scenario
The following flow was exercised successfully through uxc against the live endpoint:
- - search
uniswap subgraphs - compare candidates with INLINECODE33
- select the highest-volume candidate
- fetch schema for the chosen subgraph
- execute a minimal
_meta GraphQL query
The selected candidate in that run was:
- - subgraph ID: INLINECODE35
- deployment IPFS hash: INLINECODE36
The minimal verified query shape was:
CODEBLOCK0
References
- INLINECODE37
The Graph MCP 技能
使用此技能通过 uxc 利用原生 SSE MCP 端点运行 The Graph Subgraph MCP 操作。
复用 uxc 技能进行通用协议发现、信封解析和错误处理规则。
前提条件
- - uxc 已安装并可在 PATH 中使用。
- 可访问 https://subgraphs.mcp.thegraph.com/sse 的网络连接。
- 拥有用于认证调用的 The Graph Gateway API 密钥。
核心工作流(The Graph 专用)
最终确定前的端点候选输入:
- https://subgraphs.mcp.thegraph.com/sse
- 1. 从官方来源验证协议/路径并进行探测:
- 官方来源:https://thegraph.com/docs/en/ai-suite/subgraph-mcp/introduction/
- 使用以下命令探测候选端点:
- uxc https://subgraphs.mcp.thegraph.com/sse -h
- 确认协议为 MCP(信封中 protocol == mcp)。
- 2. 明确检测认证要求:
- 运行主机帮助或最小读取调用并检查信封。
- 此端点需要以 Authorization: Bearer
形式发送 The Graph Gateway API 密钥。
- 3. 默认注册凭据并使用固定链接命令:
- uxc auth credential set thegraph --secret-env THEGRAPHAPIKEY
- uxc auth binding add --id thegraph-sse --host subgraphs.mcp.thegraph.com --path-prefix /sse --scheme https --credential thegraph --priority 100
- command -v thegraph-mcp-cli
- 如果缺失,则创建:
- uxc link thegraph-mcp-cli https://subgraphs.mcp.thegraph.com/sse
- thegraph-mcp-cli -h
- 如果检测到命令冲突且无法安全复用,则停止并请技能维护者选择其他固定命令名称。
- 4. 执行前检查操作模式:
- thegraph-mcp-cli -h
- thegraph-mcp-cli -h
- 5. 优先使用发现/模式操作:
- 查找候选子图或部署
- 检查模式
- 仅在理解标识符和模式后执行查询
能力图谱
- 按关键词搜索子图
- 查找合约的顶级部署
- 检查部署流行度/30天查询量
- 按部署ID获取模式
- 按子图ID获取模式
- 按IPFS哈希获取模式
- 按部署ID执行GraphQL查询
- 按子图ID执行GraphQL查询
- 按IPFS哈希执行GraphQL查询
防护措施
- - 保持自动化使用JSON输出信封;不依赖 --text。
- 首先解析稳定字段:ok、kind、protocol、data、error。
- 使用 thegraph-mcp-cli 作为默认命令路径。
- 当配置相同认证绑定时,thegraph-mcp-cli ... 等同于 uxc https://subgraphs.mcp.thegraph.com/sse ...。
- 仅在链接设置不可用时,临时使用直接 uxc ... 作为后备方案。
- 在查询执行前优先进行发现和模式检查。
- 对于生产/稳定工作流,优先选择面向部署的选择,而非频繁变化的版本引用。
- 首次通过时保持GraphQL查询范围较小:
- 添加过滤器
- 添加限制
- 仅获取必要字段
- 确认 uxc auth credential info thegraph 成功
- 确认 uxc auth binding match https://subgraphs.mcp.thegraph.com/sse 解析为 thegraph
- 重新运行 thegraph-mcp-cli -h
测试过的真实场景
以下流程已通过 uxc 针对实时端点成功执行:
- - 搜索 uniswap 子图
- 使用 getdeployment30dayquerycounts 比较候选
- 选择最高流量的候选
- 获取所选子图的模式
- 执行最小化的 _meta GraphQL查询
该次运行中选择的候选是:
- - 子图ID:5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV
- 部署IPFS哈希:QmTZ8ejXJxRo7vDBS4uwqBeGoxLSWbhaA7oXa1RvxunLy7
已验证的最小查询格式为:
graphql
{
_meta {
deployment
hasIndexingErrors
}
}
参考
- references/usage-patterns.md