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. 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"
      +]
  2. 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"
      +}
  3. First observed

TDQS

A4.5/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, openWorldHint, idempotentHint, and destructiveHint=false, covering the safety profile. The description adds valuable behavioral context beyond annotations: it states the API key requirement ('Requires your own The Graph API key'), clarifies the subgraph_id format, and explains the return value ('Returns the GraphQL data block plus any errors'). This is solid transparency for a networked read operation.

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

Conciseness5/5

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

Three sentences, each earning its place: the first states the action, the second clarifies the critical identifier format, and the third covers return behavior and the prerequisite. Information is front-loaded and there is no redundant or filler content.

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

Completeness5/5

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

The tool has 4 parameters with 100% schema coverage, a rich output schema, and annotations covering read-only, idempotent, open-world, and non-destructive behavior. The description adds the operational context an agent needs: API key ownership, subgraph ID format, and return shape. Nothing essential for selecting and invoking the tool correctly is missing.

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

Parameters4/5

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

Schema description coverage is 100%, so the baseline is 3. The description adds meaning beyond the schema by explaining that subgraph_id is a deployment hash with two possible formats (Qm... or 0x...) and by reinforcing that _apiKey is user-supplied and not provisioned by Pipeworx. These details help the agent form correct calls beyond what the schema already states.

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

Purpose5/5

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

The description opens with a specific verb and resource: 'Run a GraphQL query against a subgraph on The Graph network.' It also clarifies the return shape (data block plus errors) and the required API key. This is clearly distinct from the sibling tools, none of which describe GraphQL subgraph querying.

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

Usage Guidelines4/5

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

The description gives clear context for when the tool applies: querying a subgraph on The Graph with a specific deployment ID and a user-supplied API key. It does not explicitly name alternatives or exclusions, but the uniqueness of the tool among siblings makes the intended use unambiguous. A prerequisite is clearly stated, which is useful guidance.

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.