Skip to main content
Glama
PaulieB14

Limitless MCP

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
NameRequiredDescriptionDefault
subgraphYesWhich subgraph
queryYesGraphQL query string

Implementation Reference

  • 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);
        }
      }
    );
  • 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);
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/PaulieB14/limitless-subgraphs'

If you have feedback or need assistance with the MCP directory API, please join our Discord server