Skip to main content
Glama

Query Subgraph

query_subgraph
Read-onlyIdempotent

Run a GraphQL query against a subgraph on The Graph network. subgraph_id is the deployment hash (starts with "Qm..." or the new "0x..." subgraph ID from thegraph.com/explorer). Returns the GraphQL data block plus any errors. Requires your own The Graph API key, passed as _apiKey.

Example tool call

This call uses example arguments supplied in the tool’s input schema.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "query": "{ pools(first: 5) { id feeTier liquidity } }",
      "_apiKey": "your-thegraph-api-key",
      "subgraph_id": "5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV"
    },
    "name": "query_subgraph"
  }
}

Input Schema

NameRequiredDescriptionDefault
queryYesGraphQL query string
_apiKeyYesYour own The Graph API key (BYO, Pipeworx does not supply one). Free 100k queries/month after signup at https://thegraph.com/studio/apikeys.
variablesNoOptional GraphQL variables object
subgraph_idYesSubgraph deployment ID (look up at thegraph.com/explorer; e.g., Uniswap v3 Ethereum is "5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV")

Output Schema

NameRequiredDescriptionDefault
dataYesGraphQL query result data block, or null if not returned
errorsYesArray of GraphQL errors, if any
subgraph_idYesSubgraph deployment ID provided in the query

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / _apiKey / description
      Previous value: -"Your own The Graph API key (BYO — Pipeworx does not supply one). Free 100k queries/month after signup at https://thegraph.com/studio/apikeys."New value: +"Your own The Graph API key (BYO, Pipeworx does not supply one). Free 100k queries/month after signup at https://thegraph.com/studio/apikeys."
  2. Changed3 schema fields changed
    • changedInput schema / examples
      Previous value: -[
      -  {
      -    "query": "{ pools(first: 5) { id feeTier liquidity } }",
      -    "subgraph_id": "5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV"
      -  },
      -  {
      -    "query": "query GetPoolData($poolId: String!) { pool(id: $poolId) { id feeTier liquidity volume } }",
      -    "subgraph_id": "5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV",
      -    "variables": {
      -      "poolId": "0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8"
      -    }
      -  }
      -]New value: +[
      +  {
      +    "_apiKey": "your-thegraph-api-key",
      +    "query": "{ pools(first: 5) { id feeTier liquidity } }",
      +    "subgraph_id": "5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV"
      +  },
      +  {
      +    "_apiKey": "your-thegraph-api-key",
      +    "query": "query GetPoolData($poolId: String!) { pool(id: $poolId) { id feeTier liquidity volume } }",
      +    "subgraph_id": "5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV",
      +    "variables": {
      +      "poolId": "0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8"
      +    }
      +  }
      +]
    • addedInput schema / properties / _apiKey
      Added value: +{
      +  "description": "Your own The Graph API key (BYO — Pipeworx does not supply one). Free 100k queries/month after signup at https://thegraph.com/studio/apikeys.",
      +  "type": "string"
      +}
    • changedInput schema / required
      Previous value: -[
      -  "subgraph_id",
      -  "query"
      -]New value: +[
      +  "subgraph_id",
      +  "query",
      +  "_apiKey"
      +]
  3. Changed2 schema fields changed
    • addedInput schema / examples
      Added value: +[
      +  {
      +    "query": "{ pools(first: 5) { id feeTier liquidity } }",
      +    "subgraph_id": "5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV"
      +  },
      +  {
      +    "query": "query GetPoolData($poolId: String!) { pool(id: $poolId) { id feeTier liquidity volume } }",
      +    "subgraph_id": "5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV",
      +    "variables": {
      +      "poolId": "0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8"
      +    }
      +  }
      +]
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "properties": {
      +    "data": {
      +      "description": "GraphQL query result data block, or null if not returned"
      +    },
      +    "errors": {
      +      "description": "Array of GraphQL errors, if any",
      +      "items": {
      +        "properties": {
      +          "locations": {
      +            "description": "Error location information"
      +          },
      +          "message": {
      +            "description": "Error message",
      +            "type": "string"
      +          },
      +          "path": {
      +            "description": "Path to the field that caused the error"
      +          }
      +        },
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "subgraph_id": {
      +      "description": "Subgraph deployment ID provided in the query",
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "subgraph_id",
      +    "data",
      +    "errors"
      +  ],
      +  "type": "object"
      +}
  4. First observed

TDQS

A3.7/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already cover safety (readOnly, idempotent, non-destructive, open-world), so the description is not carrying that burden. It still adds real operational context beyond the annotations: the caller must supply their own The Graph API key, and the response surfaces the GraphQL data block plus errors.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three tight sentences with the core action front-loaded, followed by identifier format and the auth requirement. Nothing is wasted, though the ID-format sentence slightly duplicates the schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With an output schema present, the description need not explain return values, and it correctly limits itself to action, ID format, and the bring-your-own API key prerequisite. The only gap is guidance on when this tool beats its alternatives.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents query, variables, subgraph_id, and _apiKey. The description's notes on the deployment-hash versus 0x subgraph ID format largely restate the schema, landing it at the baseline rather than above it.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource: "Run a GraphQL query against a subgraph on The Graph network." That is clearly distinct from sibling names like introspect_schema or discover_tools, but the description never explicitly names an alternative or scoping boundary.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage context is implied by the GraphQL/query framing and the required API key, and the ID format hint helps an agent prepare a call. There is no explicit when-to-use or when-not-to-use guidance relative to other tools in the catalog.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.