thegraph-mcp-skill

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

The Graph MCP Skill

The Graph MCP 技能

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.
使用本技能通过原生SSE MCP端点,借助
uxc
执行The Graph Subgraph MCP操作。
复用
uxc
技能以实现通用协议发现、信封解析和错误处理规则。

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.
  • uxc
    已安装且可在
    PATH
    中访问。
  • 可访问网络地址
    https://subgraphs.mcp.thegraph.com/sse
  • 拥有The Graph Gateway API密钥,用于认证调用。

Core Workflow (The Graph-Specific)

核心工作流(The Graph 专属)

Endpoint candidate inputs before finalizing:
  • Official remote MCP endpoint:
    • https://subgraphs.mcp.thegraph.com/sse
  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
确定最终端点前的候选输入:
  • 官方远程MCP端点:
    • 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. 显式检测认证要求:
    • 运行主机帮助命令或最小化读取调用并检查信封。
    • 此端点要求发送The Graph Gateway API密钥,格式为
      Authorization: Bearer <key>
  3. 注册凭证并默认使用固定链接命令:
    • 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
    • 如果不存在,则创建:
      • uxc link thegraph-mcp-cli https://subgraphs.mcp.thegraph.com/sse
    • thegraph-mcp-cli -h
    • 如果检测到命令冲突且无法安全复用,请停止操作并请求技能维护者选择其他固定命令名称。
  4. 执行操作前检查操作模式:
    • thegraph-mcp-cli -h
    • thegraph-mcp-cli <operation> -h
  5. 优先执行发现/模式操作:
    • 查找候选子图或部署
    • 检查模式
    • 仅在了解标识符和模式后执行查询

Capability Map

功能映射

  • Discovery:
    • search subgraphs by keyword
    • find top deployments for a contract
    • inspect deployment popularity / 30-day query volume
  • Schema:
    • get schema by deployment ID
    • get schema by subgraph ID
    • get schema by IPFS hash
  • Query execution:
    • execute GraphQL query by deployment ID
    • execute GraphQL query by subgraph ID
    • execute GraphQL query by IPFS hash
  • 发现:
    • 按关键词搜索子图
    • 查找合约的热门部署
    • 检查部署的受欢迎程度/30天查询量
  • 模式:
    • 通过部署ID获取模式
    • 通过子图ID获取模式
    • 通过IPFS哈希获取模式
  • 查询执行:
    • 通过部署ID执行GraphQL查询
    • 通过子图ID执行GraphQL查询
    • 通过IPFS哈希执行GraphQL查询

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.
  • thegraph-mcp-cli <operation> ...
    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
  • If auth fails:
    • confirm
      uxc auth credential info thegraph
      succeeds
    • confirm
      uxc auth binding match https://subgraphs.mcp.thegraph.com/sse
      resolves to
      thegraph
    • rerun
      thegraph-mcp-cli -h
  • 自动化操作基于JSON输出信封;不要依赖
    --text
    参数。
  • 优先解析稳定字段:
    ok
    ,
    kind
    ,
    protocol
    ,
    data
    ,
    error
  • 使用
    thegraph-mcp-cli
    作为默认命令路径。
  • 当配置相同的认证绑定时,
    thegraph-mcp-cli <operation> ...
    等价于
    uxc https://subgraphs.mcp.thegraph.com/sse <operation> ...
  • 仅当链接设置不可用时,才使用直接
    uxc "<endpoint>" ...
    作为临时回退方案。
  • 优先执行发现和模式检查,再执行查询。
  • 对于生产/稳定工作流,优先选择基于部署的方式,而非频繁变化的最新版本引用。
  • 首次执行时缩小GraphQL查询范围:
    • 添加过滤器
    • 添加限制条件
    • 仅获取所需字段
  • 如果认证失败:
    • 确认
      uxc auth credential info thegraph
      执行成功
    • 确认
      uxc auth binding match https://subgraphs.mcp.thegraph.com/sse
      解析为
      thegraph
    • 重新运行
      thegraph-mcp-cli -h

Tested Real Scenario

已测试的真实场景

The following flow was exercised successfully through
uxc
against the live endpoint:
  • search
    uniswap
    subgraphs
  • compare candidates with
    get_deployment_30day_query_counts
  • 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:
    5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV
  • deployment IPFS hash:
    QmTZ8ejXJxRo7vDBS4uwqBeGoxLSWbhaA7oXa1RvxunLy7
The minimal verified query shape was:
graphql
{
  _meta {
    deployment
    hasIndexingErrors
  }
}
以下流程已通过
uxc
针对实时端点成功执行:
  • 搜索
    uniswap
    子图
  • 使用
    get_deployment_30day_query_counts
    比较候选者
  • 选择查询量最高的候选者
  • 获取所选子图的模式
  • 执行最小化的
    _meta
    GraphQL查询
该次运行中选择的候选者为:
  • 子图ID:
    5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV
  • 部署IPFS哈希:
    QmTZ8ejXJxRo7vDBS4uwqBeGoxLSWbhaA7oXa1RvxunLy7
已验证的最小查询结构为:
graphql
{
  _meta {
    deployment
    hasIndexingErrors
  }
}

References

参考资料

  • Invocation patterns:
    • references/usage-patterns.md
  • 调用模式:
    • references/usage-patterns.md