You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Using Claude Desktop to Access Subgraphs via MCP
5
+
The Subgraph Model Context Protocol (MCP) server enables Claude to interact directly with Subgraphs on The Graph Network. This integration allows you to explore Subgraph schemas, execute GraphQL queries, and find relevant Subgraphs for specific contracts—all through natural language conversations with Claude.
6
6
7
-
The Subgraph Model Context Protocol (MCP) server enables Claude to interact directly with subgraphs on The Graph Network. This integration allows you to explore subgraph schemas, execute GraphQL queries, and find relevant subgraphs for specific contracts—all through natural language conversations with Claude.
8
-
9
-
### What You Can Do
7
+
## What You Can Do
10
8
11
9
With the Subgraph MCP integration, you can:
12
10
13
-
- Access the GraphQL schema for any subgraph on The Graph Network
14
-
- Execute GraphQL queries against any subgraph deployment
15
-
- Find top subgraph deployments for a contract address on a specific chain
16
-
- Ask natural language questions about subgraph data without writing GraphQL queries manually
17
-
18
-
### Requirements
19
-
20
-
Before setting up the Subgraph MCP server, make sure you have:
21
-
22
-
-**Claude Desktop**: Latest version installed
23
-
-**Rust**: Latest stable version (1.75+)
24
-
-**Gateway API key**: An API key from The Graph Network
11
+
- Access the GraphQL schema for any Subgraph on The Graph Network
12
+
- Execute GraphQL queries against any Subgraph deployment
13
+
- Find top Subgraph deployments for a contract address on a specific chain
14
+
- Ask natural language questions about Subgraph data without writing GraphQL queries manually
25
15
26
-
## Installation
16
+
## Prerequisites
27
17
28
-
### Step 1: Install Rust (if not already installed)
After building the project, you need to specify the absolute path to the compiled binary:
76
-
77
-
1. Navigate to your `subgraph-mcp` directory in the terminal
78
-
2. Run `pwd` to get the full path to the directory
79
-
3. Add `/target/release/subgraph-mcp` to that path
80
-
81
-
For example, if `pwd` outputs `/Users/username/subgraph-mcp`, your full command path would be: `/Users/username/subgraph-mcp/target/release/subgraph-mcp`
82
-
83
-
### Troubleshooting Installation
84
-
85
-
If you encounter issues with the setup:
86
-
87
-
1. Clean any existing build and rebuild:
77
+
- For Token API access tokens, visit [The Graph Market](https://thegraph.com/explorer)
78
+
- For Subgraph Gateway API keys, visit [Subgraph Studio](https://thegraph.com/studio/)
88
79
89
-
```bash
90
-
cd subgraph-mcp
91
-
cargo clean
92
-
cargo build --release
93
-
```
80
+
## Troubleshooting
94
81
95
-
2. Ensure the executable has proper permissions:
96
-
```bash
97
-
chmod +x target/release/subgraph-mcp
98
-
```
82
+
To enable logs for the MCP, add the `--verbose true` option to your args array.
99
83
100
84
## Using The Graph Resource in Claude
101
85
@@ -110,91 +94,47 @@ After configuring Claude Desktop:
110
94
111
95
## Available Tools and Usage
112
96
113
-
The Subgraph MCP provides several tools for interacting with subgraphs:
97
+
The Subgraph MCP provides several tools for interacting with Subgraphs:
114
98
115
99
### Schema Retrieval Tools
116
100
117
101
-**Get schema by deployment ID**: Access the GraphQL schema using a deployment ID (0x...)
118
-
-**Get schema by subgraph ID**: Access the schema for the current deployment of a subgraph (5zvR82...)
119
-
-**Get schema by IPFS hash**: Access the schema using a subgraph's IPFS manifest hash (Qm...)
102
+
-**Get schema by Subgraph ID**: Access the schema for the current deployment of a Subgraph (5zvR82...)
103
+
-**Get schema by IPFS hash**: Access the schema using a Subgraph's IPFS manifest hash (Qm...)
120
104
121
105
### Query Execution Tools
122
106
123
107
-**Execute query by deployment ID**: Run GraphQL queries against specific, immutable deployments
124
-
-**Execute query by subgraph ID**: Run GraphQL queries against the latest version of a subgraph
108
+
-**Execute query by Subgraph ID**: Run GraphQL queries against the latest version of a Subgraph
125
109
126
110
### Discovery Tools
127
111
128
-
-**Get top subgraph deployments**: Find the top 3 subgraph deployments indexing a specific contract on a particular chain
112
+
-**Get top Subgraph deployments**: Find the top 3 Subgraph deployments indexing a specific contract on a particular chain
129
113
130
114
## Natural Language Queries
131
115
132
116
One of the most powerful features of the Subgraph MCP integration is the ability to ask questions in natural language. Claude will:
133
117
134
-
1. Understand your goal (lookup, find subgraphs, query, get schema)
118
+
1. Understand your goal (lookup, find Subgraphs, query, get schema)
135
119
2. Find relevant deployments if needed
136
-
3. Fetch and interpret the subgraph schema
120
+
3. Fetch and interpret the Subgraph schema
137
121
4. Convert your question into an appropriate GraphQL query
138
122
5. Execute the query and present the results in a readable format
139
123
140
124
### Example Natural Language Queries
141
125
142
126
```
143
-
What are the pairs with maximum volume on 0xde0a7b5368f846f7d863d9f64949b688ad9818243151d488b4c6b206145b9ea3?
127
+
What are the pairs with maximum volume on deployment 0xde0a7b5368f846f7d863d9f64949b688ad9818243151d488b4c6b206145b9ea3?
144
128
145
-
Which tokens have the highest market cap in this subgraph?
129
+
Which tokens have the highest market cap in this Subgraph?
146
130
147
131
Show me the most recent 5 swaps for the USDC/ETH pair
148
132
```
149
133
150
-
## Using Both Token API MCP and Subgraph MCP Together
151
-
152
-
You can configure Claude Desktop to use both the Token API MCP and Subgraph MCP simultaneously:
For Token API access tokens, visit [The Graph Market](https://thegraph.com/explorer). For Subgraph Gateway API keys, visit [Subgraph Studio](https://thegraph.com/studio/).
175
-
176
134
## Key Identifier Types
177
135
178
-
When working with subgraphs, you'll encounter different types of identifiers:
136
+
When working with Subgraphs, you'll encounter different types of identifiers:
179
137
180
-
-**Subgraph ID** (e.g., `5zvR82...`): Logical identifier for a subgraph
138
+
-**Subgraph ID** (e.g., `5zvR82...`): Logical identifier for a Subgraph
181
139
-**Deployment ID** (e.g., `0x4d7c...`): Identifier for a specific, immutable deployment
182
140
-**IPFS Hash** (e.g., `QmTZ8e...`): Identifier for the manifest of a specific deployment
183
-
184
-
## Example Interactions
185
-
186
-
Here are some examples of how you can interact with Claude once the Subgraph MCP is set up:
187
-
188
-
```
189
-
Get the schema for subgraph deployment 0xYourDeploymentIdHere
190
-
191
-
Run this query against subgraph 5zvR82YourSubgraphIdHere: { users(first: 1) { id } }
192
-
193
-
Find the top subgraphs for contract 0x1f98431c8ad98523631ae4a59f267346ea31f984 on arbitrum-one
Copy file name to clipboardExpand all lines: website/src/pages/en/subgraphs/mcp/cline.mdx
+117Lines changed: 117 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,3 +2,120 @@
2
2
title: Cline
3
3
---
4
4
5
+
The Subgraph Model Context Protocol (MCP) server enables Cline to interact directly with Subgraphs on The Graph Network. This integration allows you to explore Subgraph schemas, execute GraphQL queries, and find relevant Subgraphs for specific contracts—all through natural language conversations with Cline.
0 commit comments