query_subgraph

Pack: the-graph · Endpoint: https://gateway.pipeworx.io/the-graph/mcp

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.

Parameters

NameTypeRequiredDescription
subgraph_idstringyesSubgraph deployment ID (look up at thegraph.com/explorer; e.g., Uniswap v3 Ethereum is “5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV”)
querystringyesGraphQL query string
variablesobjectnoOptional GraphQL variables object

Example call

Arguments

{
  "subgraph_id": "5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV",
  "query": "{ pools(first: 5) { id feeTier liquidity } }"
}

curl

curl -X POST https://gateway.pipeworx.io/the-graph/mcp \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"query_subgraph","arguments":{"subgraph_id":"5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV","query":"{ pools(first: 5) { id feeTier liquidity } }"}}}'

TypeScript (@pipeworx/sdk)

import { Pipeworx } from '@pipeworx/sdk';
const pipeworx = new Pipeworx();

const result = await pipeworx.call('query_subgraph', {
  "subgraph_id": "5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV",
  "query": "{ pools(first: 5) { id feeTier liquidity } }"
});

More examples

{
  "subgraph_id": "5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV",
  "query": "query GetPoolData($poolId: String!) { pool(id: $poolId) { id feeTier liquidity volume } }",
  "variables": {
    "poolId": "0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8"
  }
}

Response shape

Always returns: subgraph_id, data, errors

FieldTypeDescription
subgraph_idstringSubgraph deployment ID provided in the query
dataunknownGraphQL query result data block, or null if not returned
errorsarrayArray of GraphQL errors, if any
Full JSON Schema
{
  "type": "object",
  "properties": {
    "subgraph_id": {
      "type": "string",
      "description": "Subgraph deployment ID provided in the query"
    },
    "data": {
      "description": "GraphQL query result data block, or null if not returned"
    },
    "errors": {
      "type": "array",
      "description": "Array of GraphQL errors, if any",
      "items": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "Error message"
          },
          "locations": {
            "description": "Error location information"
          },
          "path": {
            "description": "Path to the field that caused the error"
          }
        }
      }
    }
  },
  "required": [
    "subgraph_id",
    "data",
    "errors"
  ]
}

Connect

Add this to your MCP client config, or use one-click install buttons:

{
  "mcpServers": {
    "the-graph": {
      "url": "https://gateway.pipeworx.io/the-graph/mcp"
    }
  }
}

See Getting Started for client-specific install steps.

Regenerated from source · build July 6, 2026