query_subgraph
Execute custom GraphQL queries on Limitless subgraphs to retrieve specific on-chain data when standard tools don't meet your needs.
Instructions
Run a raw GraphQL query against a Limitless subgraph. Escape hatch for custom queries.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| subgraph | Yes | Which subgraph | |
| query | Yes | GraphQL query string |
Implementation Reference
- mcp-server/src/index.ts:1089-1100 (handler)The handler function for the `query_subgraph` tool, which delegates to `querySimple` or `queryNegRisk`.
async ({ subgraph, query }) => { try { const data = subgraph === "simple" ? await querySimple(query) : await queryNegRisk(query); return textResult(data); } catch (e) { return errorResult(e); } } ); - mcp-server/src/index.ts:1079-1088 (registration)Registration of the `query_subgraph` tool in the MCP server.
server.registerTool( "query_subgraph", { description: "Run a raw GraphQL query against a Limitless subgraph. Escape hatch for custom queries.", inputSchema: { subgraph: z.enum(["simple", "negrisk"]).describe("Which subgraph"), query: z.string().describe("GraphQL query string"), }, }, - The underlying `querySubgraph` function and helpers (`querySimple`, `queryNegRisk`) that execute the GraphQL queries.
export async function querySubgraph( endpoint: string, query: string, variables?: Record<string, unknown> ): Promise<any> { const body: Record<string, unknown> = { query }; if (variables && Object.keys(variables).length > 0) { body.variables = variables; } const response = await fetch(endpoint, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body), }); if (!response.ok) { throw new Error(`Subgraph returned HTTP ${response.status}: ${response.statusText}`); } const json = (await response.json()) as { data?: any; errors?: any[] }; if (json.errors && json.errors.length > 0) { throw new Error(`GraphQL errors: ${JSON.stringify(json.errors)}`); } return json.data; } export async function querySimple(query: string, variables?: Record<string, unknown>) { return querySubgraph(SIMPLE_ENDPOINT, query, variables); } export async function queryNegRisk(query: string, variables?: Record<string, unknown>) { return querySubgraph(NEGRISK_ENDPOINT, query, variables); }