Skip to main content
Glama

TheGraph MCP Server

An MCP server that powers AI agents with indexed blockchain data from The Graph.

GitHub License GitHub Last Commit Python Version

Available Tools

1. getSubgraphSchema

Fetches the schema of a specified subgraph, providing AI agents with the context needed to generate GraphQL queries.

Parameters:

  • subgraphId: The subgraph ID (e.g., "QmZBQcF...")

  • asText: Output format flag

    • true: Returns human-readable GraphQL schema

    • false: Returns JSON schema (default)

2. querySubgraph

Executes GraphQL queries against a specified subgraph. While queries are typically generated by AI, you can also manually craft your own.

Parameters:

  • subgraphId: The subgraph ID

  • query: GraphQL query string

Related MCP server: Subgraph Registry MCP

Installation

  1. Clone the Repository

    git clone https://github.com/kukapay/thegraph-mcp.git
  2. Client Configuration

    {
      "mcpServers": {
        "thegraph-mcp": {
          "command": "uv",
          "args": ["--directory", "path/to/thegraph-mcp", "run", "main.py"],
          "env": {
            "THEGRAPH_API_KEY": "your_api_key_here"
          }
        }
      }
    }

Example Prompts

Here are some natural language prompts to trigger the tools:

Schema Queries

  • "Show me the schema for subgraph QmZBQcF... in a readable format"

  • "What's the structure of the QmZBQcF... subgraph? Please display it in GraphQL format"

  • "I need to understand the data model of subgraph QmZBQcF..., can you fetch its schema?"

Data Queries

  • "Find the top 5 tokens by trading volume in the last 24 hours from subgraph QmZBQcF..."

  • "Show me all pairs with liquidity greater than 1 million USD in subgraph QmZBQcF..."

  • "Get the latest 10 swap events from the QmZBQcF... subgraph, including token symbols and amounts"

Analysis Tasks

  • "Analyze the trading volume of USDT pairs in the last week using subgraph QmZBQcF..."

  • "Compare the liquidity of ETH and USDC pairs in subgraph QmZBQcF..."

  • "Find unusual trading patterns in the last 24 hours from subgraph QmZBQcF..."

Combined Tasks

  • "First get the schema of QmZBQcF..., then help me write a query to find high-value transactions"

  • "Check the schema of QmZBQcF... and tell me what fields are available for querying token prices"

  • "Using subgraph QmZBQcF..., analyze the market impact of large trades by first understanding the schema and then querying relevant events"

License

This project is licensed under the MIT License. See the LICENSE file for details.

Available Tools

2 tools
getSubgraphSchemaA

Fetch the schema of a specified subgraph using GraphQL introspection.

Args: subgraphId (str): The ID of the subgraph to query. asText (bool): If True, return schema as GraphQL text; otherwise, return JSON.

Returns: str: Schema in JSON or GraphQL text format, or an error message.

ParametersJSON Schema
NameRequiredDescriptionDefault
subgraphIdYes
asTextNo

TDQS

A4/5.0
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses the return format options (JSON or GraphQL text) and mentions error messages, but lacks details about authentication requirements, rate limits, or what happens with invalid subgraph IDs.

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

Conciseness4/5

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

The description is well-structured with a clear purpose statement followed by Args and Returns sections. It's appropriately sized, though the 'Args' and 'Returns' labels could be more integrated with the flow rather than section headers.

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

Completeness4/5

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

For a tool with 2 parameters, no annotations, and no output schema, the description provides good coverage of purpose, parameters, and return behavior. It could be more complete by addressing authentication or error scenarios, but covers the essentials adequately.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by clearly explaining both parameters: 'subgraphId' specifies which subgraph to query, and 'asText' controls the return format (text vs JSON). This adds essential meaning beyond the bare schema.

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 clearly states the specific action ('Fetch the schema') and resource ('specified subgraph using GraphQL introspection'), distinguishing it from the sibling 'querySubgraph' which presumably executes queries rather than fetching schema metadata.

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

Usage Guidelines3/5

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

The description implies usage for obtaining schema information via introspection, but does not explicitly state when to use this tool versus the sibling 'querySubgraph' or provide any exclusions or prerequisites for usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

querySubgraphA

Execute a GraphQL query against a specified subgraph.

Args: subgraphId (str): The ID of the subgraph to query. query (str): The GraphQL query string to execute.

Returns: str: Query result in JSON format, or an error message.

ParametersJSON Schema
NameRequiredDescriptionDefault
subgraphIdYes
queryYes

TDQS

A4.1/5.0
Behavior3/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool executes queries and returns results or errors, which covers basic functionality. However, it doesn't mention authentication requirements, rate limits, timeout behavior, or whether queries are read-only or can mutate data. The description adds some value but lacks comprehensive behavioral context.

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?

The description is perfectly structured with a clear purpose statement followed by well-organized sections for Args and Returns. Every sentence earns its place, with no redundant information. The formatting with clear headings makes it easy to parse while remaining extremely concise.

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

Completeness3/5

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

Given the complexity of GraphQL query execution and the lack of both annotations and output schema, the description provides adequate but minimal information. It covers the basic purpose and parameters but doesn't explain the format of query results beyond 'JSON format', nor does it address error handling, authentication, or other operational considerations that would be helpful for an AI agent.

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?

With 0% schema description coverage, the description must compensate for the lack of parameter documentation in the schema. It clearly explains that 'subgraphId' identifies which subgraph to query and 'query' is the GraphQL query string to execute, providing essential semantic meaning beyond the bare schema. However, it doesn't specify format requirements or constraints for these parameters.

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 clearly states the specific action ('Execute a GraphQL query') and resource ('against a specified subgraph'), distinguishing it from the sibling tool 'getSubgraphSchema' which presumably retrieves schema information rather than executing queries. The verb+resource combination is precise and unambiguous.

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 implies usage context by specifying it's for executing GraphQL queries against subgraphs, but doesn't explicitly state when to use this tool versus alternatives like 'getSubgraphSchema' or other query methods. It provides clear context but lacks explicit comparison or exclusion guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A3.9/5.0
Disambiguation5/5

The two tools have clearly distinct purposes: getSubgraphSchema retrieves schema information via introspection, while querySubgraph executes actual GraphQL queries. There is no overlap in functionality, making it easy for an agent to select the correct tool based on the need for metadata versus data retrieval.

Naming Consistency5/5

Both tools follow a consistent verb_noun pattern (getSubgraphSchema, querySubgraph) using camelCase, which is predictable and readable. The naming convention is uniform across all tools, with no deviations or mixed styles.

Tool Count2/5

With only 2 tools, the server feels thin for interacting with The Graph protocol, which typically involves more operations like listing subgraphs, managing deployments, or handling subscriptions. This limited set may restrict agents from performing comprehensive tasks in the domain.

Completeness2/5

The tool surface is severely incomplete for a The Graph server, lacking essential operations such as listing available subgraphs, creating or updating subgraphs, and handling mutations or subscriptions. Agents will face dead ends when trying to perform basic lifecycle management or discover subgraphs beyond a known ID.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

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/kukapay/thegraph-mcp'

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