|
| 1 | +--- |
| 2 | +title: Claude MCP |
| 3 | +--- |
| 4 | + |
| 5 | +This guide walks you through configuring Claude Desktop to use The Graph ecosystem's [Model Context Protocol](https://modelcontextprotocol.io/introduction) (MCP) resources: Token API and Subgraph. These integrations allow you to interact with blockchain data through natural language conversations with Claude. |
| 6 | + |
| 7 | +## What You Can Do |
| 8 | + |
| 9 | +With these integrations, you can: |
| 10 | + |
| 11 | +- **Token API**: Access token and wallet information across multiple blockchains |
| 12 | +- **Subgraph**: Find relevant Subgraphs for specific keywords and contracts, explore Subgraph schemas, and execute GraphQL queries |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +- [Node.js](https://nodejs.org/en/download/) installed and available in your path |
| 17 | +- [Claude Desktop](https://claude.ai/download) installed |
| 18 | +- API keys: |
| 19 | + - Token API key from [The Graph Market](https://thegraph.market/) |
| 20 | + - Gateway API key from [Subgraph Studio](https://thegraph.com/studio/apikeys/) |
| 21 | + |
| 22 | +## Configuration Steps |
| 23 | + |
| 24 | +### 1. Open Configuration File |
| 25 | + |
| 26 | +Navigate to your `claude_desktop_config.json` file: |
| 27 | + |
| 28 | +> **Claude Desktop** > **Settings** > **Developer** > **Edit Config** |
| 29 | +
|
| 30 | +Paths by operating system: |
| 31 | + |
| 32 | +- OSX: `~/Library/Application Support/Claude/claude_desktop_config.json` |
| 33 | +- Windows: `%APPDATA%\Claude\claude_desktop_config.json` |
| 34 | +- Linux: `.config/Claude/claude_desktop_config.json` |
| 35 | + |
| 36 | +### 2. Add Configuration |
| 37 | + |
| 38 | +Replace the contents of the existing config file with: |
| 39 | + |
| 40 | +```json |
| 41 | +{ |
| 42 | + "mcpServers": { |
| 43 | + "token-api": { |
| 44 | + "command": "npx", |
| 45 | + "args": ["@pinax/mcp", "--sse-url", "https://token-api.thegraph.com/sse"], |
| 46 | + "env": { |
| 47 | + "ACCESS_TOKEN": "ACCESS_TOKEN" |
| 48 | + } |
| 49 | + }, |
| 50 | + "subgraph": { |
| 51 | + "command": "npx", |
| 52 | + "args": ["mcp-remote", "--header", "Authorization:${AUTH_HEADER}", "https://subgraphs.mcp.thegraph.com/sse"], |
| 53 | + "env": { |
| 54 | + "AUTH_HEADER": "Bearer GATEWAY_API_KEY" |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | +### 3. Add Your API Keys |
| 62 | + |
| 63 | +Replace: |
| 64 | + |
| 65 | +- `ACCESS_TOKEN` with your Token API key from [The Graph Market](https://thegraph.market/) |
| 66 | +- `GATEWAY_API_KEY` with your Gateway API key from [Subgraph Studio](https://thegraph.com/studio/apikeys/) |
| 67 | + |
| 68 | +### 4. Save and Restart |
| 69 | + |
| 70 | +- Save the configuration file |
| 71 | +- Restart Claude Desktop |
| 72 | + |
| 73 | +### 5. Add The Graph Resources in Claude |
| 74 | + |
| 75 | +After configuration: |
| 76 | + |
| 77 | +1. Start a new conversation in Claude Desktop |
| 78 | +2. Click on the context menu (top right) |
| 79 | +3. Add "Subgraph Server Instructions" as a resource by entering `graphql://subgraph` for Subgraph MCP |
| 80 | + |
| 81 | +> **Important**: You must manually add The Graph resources to your chat context for each conversation where you want to use them. |
| 82 | +
|
| 83 | +### 6. Run Queries |
| 84 | + |
| 85 | +Here are some example queries you can try after setting up the resources: |
| 86 | + |
| 87 | +### Subgraph Queries |
| 88 | + |
| 89 | +``` |
| 90 | +What are the top pools in Uniswap? |
| 91 | +``` |
| 92 | + |
| 93 | +``` |
| 94 | +Who are the top Delegators of The Graph Protocol? |
| 95 | +``` |
| 96 | + |
| 97 | +``` |
| 98 | +Please make a bar chart for the number of active loans in Compound for the last 7 days |
| 99 | +``` |
| 100 | + |
| 101 | +### Token API Queries |
| 102 | + |
| 103 | +``` |
| 104 | +Show me the current price of ETH |
| 105 | +``` |
| 106 | + |
| 107 | +``` |
| 108 | +What are the top tokens by market cap on Ethereum? |
| 109 | +``` |
| 110 | + |
| 111 | +``` |
| 112 | +Analyze this wallet address: 0x... |
| 113 | +``` |
| 114 | + |
| 115 | +## Troubleshooting |
| 116 | + |
| 117 | +If you encounter issues: |
| 118 | + |
| 119 | +1. **Verify Node.js Installation**: Ensure Node.js is correctly installed by running `node -v` in your terminal |
| 120 | +2. **Check API Keys**: Verify that your API keys are correctly entered in the configuration file |
| 121 | +3. **Enable Verbose Logging**: Add `--verbose true` to the args array in your configuration to see detailed logs |
| 122 | +4. **Restart Claude Desktop**: After making changes to the configuration, always restart Claude Desktop |
0 commit comments