Skip to main content
The Graph hosts an MCP server that exposes any deployed subgraph — including Nile Markets — as a tool for AI agents. Instead of typed tools, you get raw GraphQL access to all 14 indexed entities with full filtering, pagination, and aggregation.

Prerequisites

You need a Graph API key for all usage (including testnet). Create one at thegraph.com/studio.

Setup

The Graph MCP uses SSE transport, which requires mcp-remote as a local proxy. The server name (nile-graph below) is a local alias you choose — it’s how your agent identifies this MCP connection.
Add to your claude_desktop_config.json (Settings > Developer > Edit Config):
Replace YOUR_GRAPH_API_KEY with your key from Subgraph Studio, then restart Claude Desktop.
After connecting, add graphql://subgraph as a resource in your agent’s context to activate the MCP tools. You specify which subgraph to query at query time — by deployment ID, subgraph ID, or keyword search.
The Graph MCP does not support direct HTTP transport. You must use the npx mcp-remote proxy as shown above. Claude Code’s claude mcp add --transport http will not work for this server.

Available Entities

The Nile Markets subgraph indexes 13 entity types across protocol state, positions, oracle data, and analytics. Mutable entities reflect current state and are updated over time. Immutable entities are append-only event records that never change after creation.

Example Queries

Once connected, your agent can run arbitrary GraphQL against the Nile Markets subgraph. Fetch all open positions for an account:
Get current pool metrics:
Query daily stats for the past week:

Graph MCP vs Nile MCP

Both give AI agents access to Nile Markets data. They serve different use cases. Use Graph MCP when you need custom queries, cross-entity joins, or aggregations that the typed tools don’t support — for example, filtering positions by multiple criteria simultaneously or computing custom analytics across entities. Use Nile MCP when you want structured interactions with response formatting, real-time RPC data (current prices, live PnL), or write operation calldata. The Nile MCP server is at mcp.nilemarkets.com/api/mcp — see MCP Server for setup.
You can use both servers simultaneously. Use Nile MCP for standard operations and fall back to Graph MCP for custom analytics queries.