-
Notifications
You must be signed in to change notification settings - Fork 155
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
Merged
Merged
Subgraph mcp #949
Changes from 22 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
dd98b33
Claude initial draft
MichaelMacaulay ebafea3
Initial structure
MichaelMacaulay d60f8d6
Updating & scaffolding
MichaelMacaulay 780b7df
Latest edits
MichaelMacaulay 0223551
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay 01809b1
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay 847714c
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay bd33950
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay 11d5213
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay 683b76c
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay bfc1e9a
Update website/src/pages/en/subgraphs/mcp/claude.mdx
MichaelMacaulay a819891
Update website/src/pages/en/subgraphs/mcp/cursor.mdx
MichaelMacaulay 12aecba
Update website/src/pages/en/subgraphs/mcp/cursor.mdx
MichaelMacaulay f1b3419
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay babe814
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay f1726e7
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay c371fb6
Update website/src/pages/en/subgraphs/mcp/claude.mdx
MichaelMacaulay 0250363
Update website/src/pages/en/subgraphs/mcp/claude.mdx
MichaelMacaulay 4e9ccc8
Update website/src/pages/en/subgraphs/mcp/claude.mdx
MichaelMacaulay 77ef47f
Edits
MichaelMacaulay 9dfb8f3
Latest updates
MichaelMacaulay 43d9dc5
Final tweak
MichaelMacaulay 64c454c
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay b460b6e
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay 6796735
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay cc380a4
Update website/src/pages/en/resources/claud-mcp.mdx
MichaelMacaulay f2e1bb7
Update website/src/pages/en/subgraphs/mcp/claude.mdx
MichaelMacaulay ed669c4
Update website/src/pages/en/subgraphs/mcp/claude.mdx
MichaelMacaulay 2c3a32d
Edits
MichaelMacaulay 010631d
Merge branch 'Subgraph-MCP' of https://github.com/graphprotocol/docs …
MichaelMacaulay 4aa4bd4
Edits
MichaelMacaulay 83759e5
Update website/src/pages/en/subgraphs/mcp/cline.mdx
MichaelMacaulay d81bb7f
Update website/src/pages/en/subgraphs/mcp/cursor.mdx
MichaelMacaulay 696f5b7
Check fix
MichaelMacaulay 2521141
Fix build
benface 5154ab1
Merge branch 'main' into Subgraph-MCP
MichaelMacaulay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
MichaelMacaulay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
## 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: | ||
MichaelMacaulay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
```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/) | ||
MichaelMacaulay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
### 4. Save and Restart | ||
|
||
Save the configuration file and restart Claude Desktop. | ||
MichaelMacaulay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
## Using The Graph Resources in Claude | ||
MichaelMacaulay marked this conversation as resolved.
Outdated
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 | ||
MichaelMacaulay marked this conversation as resolved.
Outdated
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.
Outdated
Show resolved
Hide resolved
|
||
|
||
## Example Queries | ||
MichaelMacaulay marked this conversation as resolved.
Outdated
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
|
||
|
||
``` | ||
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 | ||
MichaelMacaulay marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
MichaelMacaulay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
## 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 | ||
MichaelMacaulay marked this conversation as resolved.
Outdated
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 | ||
``` | ||
|
||
``` | ||
Find the top subgraphs for contract 0x1f98431c8ad98523631ae4a59f267346ea31f984 on arbitrum-one | ||
``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.