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
| Name | Type | Required | Description |
|---|---|---|---|
subgraph_id | string | yes | Subgraph deployment ID (look up at thegraph.com/explorer; e.g., Uniswap v3 Ethereum is “5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV”) |
query | string | yes | GraphQL query string |
variables | object | no | Optional 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
| Field | Type | Description |
|---|---|---|
subgraph_id | string | Subgraph deployment ID provided in the query |
data | unknown | GraphQL query result data block, or null if not returned |
errors | array | Array 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.