Subgraph registry

From jiayaoqijia/cryptoskill · View interactive version

Subgraph registry is an AI agent skill from the GitHub repository jiayaoqijia/cryptoskill. Use to discover The Graph subgraphs by chain, protocol, entity or contract and turn a goal into a bounded GraphQL query. Bring-your-own Studio key (set up by a human operator) for execution; discovery never executes queries or signs payments, and x402 is an explicitly paid external option.

How to use this skill

Skill file

Subgraph Registry

Same abilities as graphops/subgraph-mcp (hosted SSE https://subgraphs.mcp.thegraph.com/sse), better discovery. Search/recommend/semantic stay DISCOVERY — they never execute GraphQL. Schema and execute are opt-in and use the same tool names as official so an agent can swap connectors. Volume is already on every search hit (query_volume_30d) — skip official's extra get_deployment_30day_query_counts round-trip. Official that tool has been observed returning 0 for ENS/Lido/Uniswap; this registry does not copy those zeros. No private key. Set THE_GRAPH_STUDIO_API_KEY (or GATEWAY_API_KEY) for execute/live-schema; without a key those tools return credentials_required + both URLs and do not hang or auto-pay x402.

Agent quick path: connect → discover → prepare → opt in

  1. Connect a reviewed, pinned release. This is the canonical shareable skill;

share this file with the GitHub repository, not a second skills.md recipe.

For a stdio MCP host, start with this keyless configuration:

```json

{"mcpServers":{"subgraph-registry":{"command":"npx","args":["-y","subgraph-registry-mcp@0.13.7"]}}}

```

Inspect tools/list before calling a tool. Keyless 0.13.7 advertises 10

discovery/preparation tools; execution/schema/health tools are advertised only

when a Studio key is configured. A mounted connector can use another runtime

or corpus: do not assume installing a release updates an existing connector.

  1. Discover with explicit chain identity. For example, call

search_subgraphs({"network":"arc","include_unserved":true,"limit":3}).

This explicitly broadens discovery to zero-allocation snapshot records; it

does not probe them or establish serving health. arc is mainnet;

arc-testnet is different. Other examples: ethereum→mainnet,

arbitrum→arbitrum-one, polygon→matic, sei→sei-mainnet.

Use query:"ens" for a protocol and network for its chain. Inspect

emerging, network and testnet labels, not just reliability. If results are

empty, inspect diagnostics when available; otherwise check registry stats

and deliberately broaden the relevant include_* flag. Never interpret an

empty snapshot as proof that a chain or queryable Subgraph does not exist.

  1. Bring your own Studio key — a human handoff. Keyless discovery and query

preparation work without one. Executing queries needs the operator's own Graph

Studio API key; this server never ships or shares a key. Studio keys belong to

a Studio account managed by a person, so an agent should not create

accounts, sign up or mint keys itself. Relay this to your human (keyless

query_for_goal returns the same text as onboarding.relay_to_human):

> To let me run live queries on The Graph with your own quota: sign in to

> Subgraph Studio (https://thegraph.com/studio/apikeys/) with a Studio account

> you manage, create an API key, and add it to this MCP server's environment or

> secret manager as THE_GRAPH_STUDIO_API_KEY, then restart the server. Please

> don't paste the key into this chat.

Never ask for the key in ordinary chat or put it in tool arguments, source,

URLs or logs. A configured key is not proof that it is valid or has quota.

Official pricing advertises **100,000

free monthly queries**; check the account's current plan and remaining usage.

This is not a fresh allowance per key, and Studio development endpoints have

separate limits. See "Host configuration" below for copy-paste examples.

  1. Prepare a goal-specific query without spending. Call, for example,

query_for_goal({"goal":"Uniswap V4 pool IDs on Arc","chain":"arc","first":3}).

Read goal_mapping: the requested entity (pools, swaps, candles/OHLCV,

daily/hourly data, positions, liquidations, tokens, borrows, mints…),

confidence, rationale, unmet parts and ranked alternatives.

derived the way graph-node names it, and fields are id plus stored-starter

fields only when that starter targets the same entity. Ordering, typed

filters (time ranges, relation addresses) and aggregation intervals are

listed in unmet rather than guessed. Confidence is at most medium.

confirms the collection, fields, orderBy and where filters, then adds

goal-relevant fields and typed filters. Only then is confidence high.

If a requested address/time filter cannot be applied it appears in

filters_not_applied and execution is skipped instead of returning

unfiltered rows.

behind is skipped for the next deployment that fits the goal (at most 3

deployments and 6 requests). Read goal_mapping.skipped_deployments and

fallback_used. Reward or curation status is never treated as unhealthy.

Auth/quota errors stop without fallback.

names, implausible TVL, TVL without volume, low activity) are flagged

and, by default, moved last. Nothing is removed. Use

spam_handling:"flag_only"/"off" and trusted_tokens to adjust; still

verify contract addresses.

confidently: pick from alternatives or inspect get_subgraph_detail.

hidden_candidates lists matching deployments excluded by default filters;

opt in with include_denied / include_unserved (not queryability tests).

confidence:"generic_starter".

This goal mapping ships in 0.12.0; earlier releases return the stored

starter. With an older six-tool connector, use

recommend_subgraph / get_subgraph_detail and the stored starter instead.

  1. Execute only when requested and authorized. With a key configured,

keyed query_for_goal results include next_action.execute_call, e.g.

{"goal":…,"first":3,"validate_schema":true,"execute":true}: one schema check

plus one gateway query from the operator's own allowance, never x402. Execution

is skipped when no query mapped confidently or live validation failed.

execute_query with a reviewed query is the other opt-in path. A direct keyed

client uses the returned fixed gateway URL and

Authorization: Bearer <STUDIO_API_KEY>; never print the actual header.

  1. Read errors and evidence. HTTP 200 can contain GraphQL errors or partial

data. Report them, don't claim success from HTTP status alone. For missing

credentials follow step 3; for quota/billing errors stop rather than silently

switching to a paid route. Health observations are process-local, stale after

300 seconds, and do not prove chain-head sync. No observation means unknown.

Across ALL chains: rewards/curation eligibility, on-chain allocation counts,

query demand and actual query availability are distinct. A chain can serve data

before rewards or curation signaling are enabled. include_unserved is a legacy

flag name for including zero-allocation snapshot records, not a declaration

that those records cannot be queried. denied means the recorded deployment was

denied indexing rewards, not proof it is malicious or unavailable. The corpus

does not establish every chain's current rewards/signaling eligibility and does

not include every Studio-only deployment. See supported network modes.

Paid alternative, never a fallback without consent: external x402 clients can

sign a USDC payment authorization and retry automatically. This is a financial

capability of that external client, NOT this MCP server. Require the owner's

explicit approval of the payment/amount before using a funded signing client;

do not run the README payment example just because a free/keyed request failed.

New agent workflow (Node MCP)

Host configuration (bring your own key)

The key is read only from the server process environment

(THE_GRAPH_STUDIO_API_KEY, or GATEWAY_API_KEY). Prefer your host's secret

or environment interpolation over writing the key into a config file; never

commit a key. Restart the server after setting it, then check that tools/list

now includes execute_query (19 tools instead of 10).

resolved from the environment Cursor was launched with):

```json

{"mcpServers":{"subgraph-registry":{"command":"npx","args":["-y","subgraph-registry-mcp@0.13.7"],"env":{"THE_GRAPH_STUDIO_API_KEY":"${env:THE_GRAPH_STUDIO_API_KEY}"}}}}

```

claude mcp add --env THE_GRAPH_STUDIO_API_KEY="$THE_GRAPH_STUDIO_API_KEY" --transport stdio subgraph-registry -- npx -y subgraph-registry-mcp@0.13.7,

which stores the expanded value in ~/.claude.json):

```json

{"mcpServers":{"subgraph-registry":{"command":"npx","args":["-y","subgraph-registry-mcp@0.13.7"],"env":{"THE_GRAPH_STUDIO_API_KEY":"${THE_GRAPH_STUDIO_API_KEY}"}}}}

```

host has no secret/interpolation support, the env value is stored as plain

text in that local config file: only do this on a machine you control, and

keep the file out of version control.

```json

{"mcpServers":{"subgraph-registry":{"command":"npx","args":["-y","subgraph-registry-mcp@0.13.7"],"env":{"THE_GRAPH_STUDIO_API_KEY":"<your Studio API key>"}}}}

```

Direct HTTP, with the key taken from the environment (never inline it):

curl -sS -X POST "https://gateway.thegraph.com/api/subgraphs/id/<SUBGRAPH_ID>" \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $THE_GRAPH_STUDIO_API_KEY" \
  --data '{"query":"{ pools(first: 3) { id } }"}'

Tools

Discovery (local index, no gateway)

Official-name tools (swap-in for graphops/subgraph-mcp)

Query paths

Every discovery result ships with two URLs in payment_options (neither is labelled recommended — pick by what you have):

Optional next step after discovery: execute_query_by_subgraph_id (or execute_query) with the id and GraphQL, if a Studio key is in env.

Requirements

Install

Pin a known-good version. Audit the source on GitHub before installing if you

plan to ship this in an autonomous-agent runtime.

# Always pin the exact published version; an unpinned package name would
# resolve to whatever is newest at install time.
npx -y subgraph-registry-mcp@0.13.7

Network & Data Behavior

Verifying the registry

The npm package version 0.13.7 ships with this expected hash:

SHA-256(registry.db) = 9e2f608003fc403f9143417f40300f4a5769275dcc8f1982f60473b05ff23dce

This hash is hard-coded in src/index.js (EXPECTED_DB_SHA256). On every run,

the server checks the bundled (or explicitly downloaded) registry.db against it. If

the hashes don't match — which would happen if the GitHub-hosted file were

swapped, or your local cache were tampered with — the server **refuses to load

the database** and exits with an error. The bad file is deleted; reinstall the pinned package

to restore it.

Verify manually:

shasum -a 256 ~/.npm/_npx/*/node_modules/subgraph-registry-mcp/data/registry.db
# (path varies by npx cache layout; the file is the one referenced as
# `data/registry.db` inside the package)

If you intentionally rebuilt the DB locally (using the optional Python

crawler), the hash will not match. Set SUBGRAPH_REGISTRY_SKIP_VERIFY=1 to

bypass — never set this in an agent-runtime default config.

When the registry is regenerated, the maintainer bumps the npm version and

updates the hash constant atomically — so a given npm version uniquely

corresponds to a known DB.

Use Cases

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.