Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
dd98b33
Claude initial draft
MichaelMacaulay May 9, 2025
ebafea3
Initial structure
MichaelMacaulay May 9, 2025
d60f8d6
Updating & scaffolding
MichaelMacaulay May 12, 2025
780b7df
Latest edits
MichaelMacaulay May 13, 2025
0223551
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay May 14, 2025
01809b1
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay May 14, 2025
847714c
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay May 14, 2025
bd33950
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay May 14, 2025
11d5213
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay May 14, 2025
683b76c
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay May 14, 2025
bfc1e9a
Update website/src/pages/en/subgraphs/mcp/claude.mdx
MichaelMacaulay May 14, 2025
a819891
Update website/src/pages/en/subgraphs/mcp/cursor.mdx
MichaelMacaulay May 14, 2025
12aecba
Update website/src/pages/en/subgraphs/mcp/cursor.mdx
MichaelMacaulay May 14, 2025
f1b3419
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay May 14, 2025
babe814
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay May 14, 2025
f1726e7
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay May 14, 2025
c371fb6
Update website/src/pages/en/subgraphs/mcp/claude.mdx
MichaelMacaulay May 14, 2025
0250363
Update website/src/pages/en/subgraphs/mcp/claude.mdx
MichaelMacaulay May 14, 2025
4e9ccc8
Update website/src/pages/en/subgraphs/mcp/claude.mdx
MichaelMacaulay May 14, 2025
77ef47f
Edits
MichaelMacaulay May 14, 2025
9dfb8f3
Latest updates
MichaelMacaulay May 14, 2025
43d9dc5
Final tweak
MichaelMacaulay May 14, 2025
64c454c
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay May 14, 2025
b460b6e
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay May 14, 2025
6796735
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay May 14, 2025
cc380a4
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay May 14, 2025
f2e1bb7
Update website/src/pages/en/subgraphs/mcp/claude.mdx
MichaelMacaulay May 14, 2025
ed669c4
Update website/src/pages/en/subgraphs/mcp/claude.mdx
MichaelMacaulay May 14, 2025
2c3a32d
Edits
MichaelMacaulay May 14, 2025
010631d
Merge branch 'Subgraph-MCP' of https://github.com/graphprotocol/docs …
MichaelMacaulay May 14, 2025
4aa4bd4
Edits
MichaelMacaulay May 14, 2025
83759e5
Update website/src/pages/en/subgraphs/mcp/cline.mdx
MichaelMacaulay May 14, 2025
d81bb7f
Update website/src/pages/en/subgraphs/mcp/cursor.mdx
MichaelMacaulay May 14, 2025
696f5b7
Check fix
MichaelMacaulay May 14, 2025
2521141
Fix build
benface May 14, 2025
5154ab1
Merge branch 'main' into Subgraph-MCP
MichaelMacaulay May 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions website/src/pages/en/resources/_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export default {
roles: titles.roles,
'migration-guides': titles['migration-guides'],
'subgraph-studio-faq': '',
'claud-mcp': '',
}
112 changes: 112 additions & 0 deletions website/src/pages/en/resources/claud-mcp.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
title: Claude MCP
---

This guide walks you through configuring Claude Desktop to use The Graph ecosystem's Model Context Protocol (MCP) resources: Token API and Subgraph. These integrations allow you to interact with blockchain data through natural language conversations with Claude.

## What You Can Do

With these integrations, you can:

- **Token API**: Access token and wallet information across multiple blockchains
- **Subgraph**: Find relevant Subgraphs for specific keywords and contracts, explore Subgraph schemas, and execute GraphQL queries

## Prerequisites

- [Node.js](https://nodejs.org/en/download/) installed and available in your path
- [Claude Desktop](https://claude.ai/download) installed
- API keys:
- Token API key from [The Graph Market](https://thegraph.market/)
- Gateway API key from [Subgraph Studio](https://thegraph.com/studio/apikeys/)

## Configuration Steps

### 1. Open Configuration File

Navigate to your `claude_desktop_config.json` file:

> **Claude Desktop** > **Settings** > **Developer** > **Edit Config**
Paths by operating system:

- OSX: `~/Library/Application Support/Claude/claude_desktop_config.json`
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
- Linux: `.config/Claude/claude_desktop_config.json`

### 2. Add Configuration

Replace the existing configuration with this template:

```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 Keys

1. Replace `ACCESS_TOKEN` with your Token API key from [The Graph Market](https://thegraph.market/)
2. Replace `GATEWAY_API_KEY` with your Gateway API key from [Subgraph Studio](https://thegraph.com/studio/apikeys/)

### 4. Save and Restart

Save the configuration file and restart Claude Desktop.

## Using The Graph Resources in Claude

After configuration:

1. Start a new conversation in Claude Desktop
2. Click on the context menu (top right)
3. Add "The Graph" resource by entering `graphql://subgraph` for Subgraph MCP

**Important**: You must manually add The Graph resources to your chat context for each conversation where you want to use them.

## Example Queries

Here are some example queries you can try after setting up the resources:

### Subgraph Queries

```
What are the top pools in Uniswap?
```

```
Who are the top delegators of The Graph Protocol?
```

```
Please make a bar chart for the number of active loans in Compound for the last 7 days
```

### Token API Queries

```
Show me the current price of ETH
```

```
What are the top tokens by market cap on Ethereum?
```

```
Analyze this wallet address: 0x...
```

## Troubleshooting

If you encounter issues:

1. **Verify Node.js Installation**: Ensure Node.js is correctly installed by running `node -v` in your terminal
2. **Check API Keys**: Verify that your API keys are correctly entered in the configuration file
3. **Enable Verbose Logging**: Add `--verbose true` to the args array in your configuration to see detailed logs
4. **Restart Claude Desktop**: After making changes to the configuration, always restart Claude Desktop
3 changes: 2 additions & 1 deletion website/src/pages/en/subgraphs/_meta-titles.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"querying": "Querying",
"developing": "Developing",
"guides": "How-to Guides",
"best-practices": "Best Practices"
"best-practices": "Best Practices",
"mcp": "MCP"
}
1 change: 1 addition & 0 deletions website/src/pages/en/subgraphs/_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default {
querying: titles.querying,
developing: titles.developing,
billing: '',
mcp: titles.mcp,
guides: titles.guides,
'best-practices': titles['best-practices'],
}
5 changes: 5 additions & 0 deletions website/src/pages/en/subgraphs/mcp/_meta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
claude: '',
cline: '',
cursor: '',
}
180 changes: 180 additions & 0 deletions website/src/pages/en/subgraphs/mcp/claude.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
---
title: Claude Desktop
---

The Subgraph Model Context Protocol (MCP) server enables Claude to interact directly with Subgraphs on The Graph Network. This integration allows you to find relevant Subgraphs for specific keywords and contracts, explore Subgraph schemas, and execute GraphQL queries—all through natural language conversations with Claude.

## What You Can Do

The Subgraph MCP integration enables you to:

- Access the GraphQL schema for any Subgraph on The Graph Network
- Execute GraphQL queries against any Subgraph deployment
- Find top Subgraph deployments for a given keyword or contract address
- Get 30-day query volume for Subgraph deployments
- Ask natural language questions about Subgraph data without writing GraphQL queries manually

## Prerequisites

- [Node.js](https://nodejs.org/en) installed and available in your path
- [Claude Desktop](https://claude.ai/download) installed (latest version)
- A Gateway API key from [Subgraph Studio](https://thegraph.com/studio/)

## Installation Options

### Option 1: Using npx (Recommended)

#### Configuration Steps using npx

#### 1. Open Configuration File

Navigate to your `claude_desktop_config.json` file:

> **Settings** > **Developer** > **Edit Config**

- OSX: `~/Library/Application Support/Claude/claude_desktop_config.json`
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
- Linux: `.config/Claude/claude_desktop_config.json`

#### 2. Add Configuration

Paste the following settings into your config file:

```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 Gateway API Key

Replace `GATEWAY_API_KEY` with your API key from [Subgraph Studio](https://thegraph.com/studio/).

#### 4. Save and Restart

Once you've entered your Gateway API key into your settings, save the file and restart Claude Desktop.

### Option 2: Building from Source

#### Requirements

- Rust (latest stable version recommended: 1.75+)
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
Follow the on-screen instructions. For other platforms, see the [official Rust installation guide](https://www.rust-lang.org/tools/install).

#### Installation Steps

1. **Clone and Build the Repository**

```bash
git clone [email protected]:graphops/subgraph-mcp.git
cd subgraph-mcp
cargo build --release
```

2. **Find the Command Path**

After building, the executable will be located at `target/release/subgraph-mcp` inside your project directory.

- Navigate to your `subgraph-mcp` directory in terminal
- Run `pwd` to get the full path
- Combine the output with `/target/release/subgraph-mcp`

3. **Configure Claude Desktop**

Open your `claude_desktop_config.json` file as described above and add:

```json
{
"mcpServers": {
"subgraph": {
"command": "/path/to/your/subgraph-mcp/target/release/subgraph-mcp",
"env": {
"GATEWAY_API_KEY": "your-api-key-here"
}
}
}
}
```

Replace `/path/to/your/subgraph-mcp/target/release/subgraph-mcp` with the actual path to the compiled binary.

## Using The Graph Resource in Claude

After configuring Claude Desktop:

1. Restart Claude Desktop
2. Start a new conversation
3. Click on the context menu (top right)
4. Add "The Graph" resource by adding `graphql://subgraph` to your chat context

**Important**: Claude Desktop may not automatically utilize the Subgraph MCP. You must manually add "The Graph" resource to your chat context for each conversation where you want to use it.

## Troubleshooting

To enable logs for the MCP when using the npx option, add the `--verbose true` option to your args array.

## 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/IPFS hash**: Run GraphQL queries against specific, immutable deployments
- **Execute query by Subgraph ID**: Run GraphQL queries against the latest version of a Subgraph

### Discovery Tools

- **Search subgraphs by keyword**: Find subgraphs by keyword in their display names, ordered by signal
- **Get deployment 30-day query counts**: Get aggregate query count over the last 30 days for multiple subgraph deployments
- **Get top Subgraph deployments for a contract**: Find the top 3 Subgraph deployments indexing a specific contract on a particular chain, ordered by query fees

## Key Identifier Types

- **Subgraph ID** (e.g., `5zvR82...`): Logical identifier for a subgraph. Use `execute_query_by_subgraph_id` or `get_schema_by_subgraph_id`.
- **Deployment ID** (e.g., `0x4d7c...`): Identifier for a specific, immutable deployment. Use `execute_query_by_deployment_id` or `get_schema_by_deployment_id`.
- **IPFS Hash** (e.g., `QmTZ8e...`): Identifier for the manifest of a specific, immutable deployment. Use `execute_query_by_deployment_id` (the gateway treats it like a deployment ID for querying) or `get_schema_by_ipfs_hash`.

## Natural Language Queries

One of the most powerful features of the Subgraph MCP integration is the ability to ask questions in natural language. Claude 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
```

```
Find the top subgraphs for contract 0x1f98431c8ad98523631ae4a59f267346ea31f984 on arbitrum-one
```
Loading
Loading