-
Notifications
You must be signed in to change notification settings - Fork 151
Subgraph mcp #949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subgraph mcp #949
Changes from 4 commits
dd98b33
ebafea3
d60f8d6
780b7df
0223551
01809b1
847714c
bd33950
11d5213
683b76c
bfc1e9a
a819891
12aecba
f1b3419
babe814
f1726e7
c371fb6
0250363
4e9ccc8
77ef47f
9dfb8f3
43d9dc5
64c454c
b460b6e
6796735
cc380a4
f2e1bb7
ed669c4
2c3a32d
010631d
4aa4bd4
83759e5
d81bb7f
696f5b7
2521141
5154ab1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
--- | ||
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. | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## What You Can Do | ||
|
||
With these integrations, you can: | ||
|
||
- **Token API**: Access token and wallet information across multiple blockchains | ||
- **Subgraph**: Explore Subgraph schemas, execute GraphQL queries, and find relevant Subgraphs for specific contracts | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## 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 | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Follow these steps to configure both Token API and Subgraph MCP in Claude Desktop: | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Step 1: Open Configuration File | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Edit your `claude_desktop_config.json` file: | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
> **Claude Desktop** > **Settings** > **Developer** > **Edit Config** | ||
|
||
File locations by operating system: | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- OSX: `~/Library/Application Support/Claude/claude_desktop_config.json` | ||
- Windows: `%APPDATA%\Claude\claude_desktop_config.json` | ||
- Linux: `.config/Claude/claude_desktop_config.json` | ||
|
||
### Step 2: Add Configuration | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Replace the existing configuration with this template: | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```json | ||
{ | ||
"mcpServers": { | ||
"token-api": { | ||
"command": "npx", | ||
"args": ["@pinax/mcp", "--sse-url", "https://token-api.thegraph.com/sse"], | ||
"env": { | ||
"ACCESS_TOKEN": "ACCESS_TOKEN" | ||
} | ||
}, | ||
"subgraph": { | ||
"command": "npx", | ||
"args": [ | ||
"mcp-remote", | ||
"--header", | ||
"Authorization: Bearer GATEWAY_API_KEY", | ||
"https://subgraph-ai.graphops.xyz/sse" | ||
] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Step 3: Add Your API Keys | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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/) | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Step 4: Save and Restart | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Save the configuration file and restart Claude Desktop. | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Using The Graph Resources in Claude | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 and/or `token-api://token-api` for Token API | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
**Important**: You must manually add The Graph resources to your chat context for each conversation where you want to use them. | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Example Queries | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Here are some example queries you can try after setting up the resources: | ||
|
||
### Subgraph Queries | ||
|
||
``` | ||
What are the top pools in Uniswap? | ||
``` | ||
benface marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
``` | ||
Top delegators of The Graph Protocol? | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
``` | ||
Number of active loans in Compound for the last 7 days? Please make it a bar chart | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
### 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 | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default { | ||
claude: '', | ||
cline: '', | ||
cursor: '', | ||
} |
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
--- | ||
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 explore Subgraph schemas, execute GraphQL queries, and find relevant Subgraphs for specific contracts—all through natural language conversations with Claude. | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## What You Can Do | ||
|
||
With the Subgraph MCP integration, you can: | ||
|
||
- Access the GraphQL schema for any Subgraph on The Graph Network | ||
- Execute GraphQL queries against any Subgraph deployment | ||
- Find top Subgraph deployments for a contract address on a specific chain | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- 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 | ||
- A Gateway API key from [Subgraph Studio](https://thegraph.com/studio/) | ||
|
||
## Configuration | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Edit 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` | ||
|
||
Paste the following settings into your config file: | ||
|
||
```json label="claude_desktop_config.json" | ||
{ | ||
"mcpServers": { | ||
"subgraph": { | ||
"command": "npx", | ||
"args": [ | ||
"mcp-remote", | ||
"--header", | ||
"Authorization: Bearer GATEWAY_API_KEY", | ||
"https://subgraph-ai.graphops.xyz/sse" | ||
] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Replace `GATEWAY_API_KEY` with your API key from [Subgraph Studio](https://thegraph.com/studio/). | ||
|
||
Once you've entered your Gateway API key into your settings, you can save the file, and restart Claude desktop. | ||
|
||
## 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. | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Troubleshooting | ||
|
||
To enable logs for the MCP, add the `--verbose true` option to your args array. | ||
|
||
## Available Tools and Usage | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Natural Language Queries | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
--- | ||
title: Cline | ||
--- | ||
|
||
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. | ||
|
||
## Prerequisites | ||
|
||
- [Cline](https://cline.bot/) 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 | ||
|
||
Create or edit your `cline_mcp_settings.json` file. | ||
|
||
> **MCP Servers** > **Installed** > **Configure MCP Servers** | ||
|
||
```json label="cline_mcp_settings.json" | ||
{ | ||
"mcpServers": { | ||
"subgraph": { | ||
"command": "npx", | ||
"args": [ | ||
"mcp-remote", | ||
"--header", | ||
"Authorization: Bearer GATEWAY_API_KEY", | ||
"https://subgraph-ai.graphops.xyz/sse" | ||
] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Replace `GATEWAY_API_KEY` with your API key from Subgraph Studio. | ||
|
||
## Using Both Token API MCP and Subgraph MCP Together | ||
|
||
You can configure Cline to use both the Token API MCP and Subgraph MCP simultaneously: | ||
|
||
```json label="cline_mcp_settings.json" | ||
{ | ||
"mcpServers": { | ||
"token-api": { | ||
"command": "npx", | ||
"args": ["@pinax/mcp", "--sse-url", "https://token-api.thegraph.com/sse"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We've updated this endpoint to be @0237h , could you please also update the repo with this new endpoint? Also, @MichaelMacaulay , we're doing the same for GraphOps (which doesn't have a thegraph.com domain yet). This is taking a bit longer than expected as we ran into some issues, but I can update the docs team once that's done. |
||
"env": { | ||
"ACCESS_TOKEN": "ACCESS_TOKEN" | ||
} | ||
}, | ||
"subgraph": { | ||
"command": "npx", | ||
"args": [ | ||
"mcp-remote", | ||
"--header", | ||
"Authorization: Bearer GATEWAY_API_KEY", | ||
"https://subgraph-ai.graphops.xyz/sse" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MichaelMacaulay , we'll have https://subgraphs.mcp.thegraph.com very very soon |
||
] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
- 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/) | ||
|
||
## Using The Graph Resource in Cline | ||
|
||
After configuring Cline: | ||
|
||
1. Restart Cline | ||
2. Start a new conversation | ||
3. Enable the Subgraph MCP from the context menu | ||
4. Add "The Graph" resource to your chat context | ||
|
||
## Available 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 | ||
|
||
## Natural Language Queries | ||
|
||
One of the most powerful features of the Subgraph MCP integration is the ability to ask questions in natural language. Cline 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 | ||
``` | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## 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 |
Uh oh!
There was an error while loading. Please reload this page.