---
title: Cursor
---

This guide walks you through the integration of Subgraph [Model Context Protocol](https://modelcontextprotocol.io/introduction) (MCP) to access Subgraph data through natural language conversations with Cline.

## Prerequisites

- [Cursor](https://www.cursor.com/) installed (latest version)
- A Gateway API key from [Subgraph Studio](https://thegraph.com/studio/)
- [`npx`](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) or [`bunx`](https://bun.sh/) installed and available in your path

## Configuration Steps

### 1. Open Configuration File

Create or edit your `~/.cursor/mcp.json` file.

> **Cursor Settings** > **MCP** > **Add new global MCP Server**

### 2. Add Configuration

```json
{
  "mcpServers": {
    "subgraph": {
      "command": "npx",
      "args": ["mcp-remote", "--header", "Authorization:${AUTH_HEADER}", "https://subgraphs.mcp.thegraph.com/sse"],
      "env": {
        "AUTH_HEADER": "Bearer GATEWAY_API_KEY"
      }
    }
  }
}
```

### 3. Add Your API Key

Replace `GATEWAY_API_KEY` with your API key from Subgraph Studio.

### 4. Restart Cursor

Restart Cursor, and start a new chat.

## Available Subgraph Tools and Usage

The Subgraph MCP provides several tools for interacting with Subgraphs:

### Schema Retrieval Tools

- **Get schema by deployment ID**: Access the GraphQL schema using a deployment ID (0x...)
- **Get schema by Subgraph ID**: Access the schema for the current deployment of a Subgraph (5zvR82...)
- **Get schema by IPFS hash**: Access the schema using a Subgraph's IPFS manifest hash (Qm...)

### Query Execution Tools

- **Execute query by deployment ID**: Run GraphQL queries against specific, immutable deployments
- **Execute query by Subgraph ID**: Run GraphQL queries against the latest version of a Subgraph

### Discovery Tools

- **Get top Subgraph deployments**: Find the top 3 Subgraph deployments indexing a specific contract on a particular chain

## Benefits of Natural Language Queries

One of the most powerful features of the Subgraph MCP integration is the ability to ask questions in natural language. Cursor will:

1. Understand your goal (lookup, find Subgraphs, query, get schema)
2. Find relevant deployments if needed
3. Fetch and interpret the Subgraph schema
4. Convert your question into an appropriate GraphQL query
5. Execute the query and present the results in a readable format

### Example Natural Language Queries

```
What are the pairs with maximum volume on deployment 0xde0a7b5368f846f7d863d9f64949b688ad9818243151d488b4c6b206145b9ea3?
```

```
Which tokens have the highest market cap in this Subgraph?
```

```
Show me the most recent 5 swaps for the USDC/ETH pair
```

## Key Identifier Types

When working with Subgraphs, you'll encounter different types of identifiers:

- **Subgraph ID** (e.g., `5zvR82...`): Logical identifier for a Subgraph
- **Deployment ID** (e.g., `0x4d7c...`): Identifier for a specific, immutable deployment
- **IPFS Hash** (e.g., `QmTZ8e...`): Identifier for the manifest of a specific deployment
