Skip to main content
MCP (Model Context Protocol) is an open standard for connecting AI applications to external systems. Dune MCP is Dune’s official remote MCP server. It gives your agent direct, structured access to Dune workflows: discover relevant datasets, create and run SQL queries, inspect execution results, manage visualizations, and build dashboards — all in the same conversation. This is the fastest way to move from prompt to reliable onchain analysis. See also Agents on dune.com.

Setup and Usage

Authentication

To connect, sign in with your Dune account. You do not need an API key. Most agents only need:
  • Name: Dune
  • url: https://api.dune.com/mcp/v1
When you add the server, your agent opens the Dune sign-in page in your browser. After you sign in, you go back to your agent and it is ready to use. This sign-in uses OAuth 2.0. The technical details are in Connection Details. If your agent runs where it cannot open a browser, see Headless and CI environments.

Setup examples

Claude Code

Then run /mcp in Claude Code and select dune to sign in.

Claude Desktop

OpenCode

Connect opencode to Dune MCP Once added run opencode mcp auth Dune and it will open up a browser where you can log into Dune.

Codex

Known issue: “Transport closed” errors during long-running queriesCodex’s MCP client has a default tool timeout of 60 seconds. When getExecutionResults polls for a query that takes longer than this, Codex terminates the connection. Due to a known Codex bug, the MCP transport does not auto-reconnect after a timeout - all subsequent tool calls will fail with Transport closed until you start a new session.Workaround: Increase the Codex tool timeout in your config:

Cursor

tl:dr; Add this configuration to your Cursor settings, then sign in with your Dune account when Cursor asks:

Headless and CI environments

Use this only when your agent runs where it cannot sign in with a browser, for example in CI. In all other cases, sign in with your Dune account as shown above. Send your Dune API key in the x-dune-api-key header. Do not put the key in the URL.
For clients that use a JSON config:

Tools and Resources Inventory

Tools

Resources

Server Details

  • Server name: dune
  • Remote MCP URL: https://api.dune.com/mcp/v1
  • Tagline: Query, analyze, and visualize onchain data from Dune directly inside your MCP-compatible AI client.
  • Primary use cases:
    • Discover datasets and docs relevant to a protocol, contract, or chain
    • Create, update, execute, and troubleshoot Dune SQL queries
    • Turn query results into charts/tables/counters without leaving your chat
    • Create and manage full dashboards from natural language prompts
    • Materialize query results into reusable tables and keep them fresh on a schedule
    • Track account credit usage while iterating on analysis

Prompt Examples

Try prompts like these in your MCP-enabled client:
  1. “Find the best Dune table for tracking Uniswap v3 swap volume on Ethereum, then create and run a daily volume query for the last 90 days.”
  2. “I have contract 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48. Find decoded tables, build a weekly transfer count query, execute it, and show the top 20 recipient wallets.”
  3. “Review query 1234567, optimize it for lower scan cost, update it in place, run it, and summarize result quality and execution credits used.”
  4. “Generate a visualization from my latest execution results: a line chart of daily active addresses and a counter for total unique users.”
  5. “Create a dashboard showing Ethereum activity in the past 30 days — include daily transactions, active addresses, and gas usage.”
  6. “Update my existing dashboard to add a new chart showing weekly DEX volume by protocol.”
  7. “Materialize my daily active addresses query into a table and refresh it every hour, then list my materialized views to confirm.”

Connection Details

Transport

  • Protocol: Remote MCP over Streamable HTTP
  • Endpoint: https://api.dune.com/mcp/v1
  • Interaction pattern:
    • POST /mcp/v1 for MCP requests
    • GET /mcp/v1 for stream resumption/event replay

OAuth 2.0 details

  • Authorization server issuer: https://dune.com/oauth/mcp
  • Discovery metadata: https://dune.com/.well-known/oauth-authorization-server/oauth/mcp
  • Authorization endpoint: https://dune.com/oauth/mcp/authorize
  • Token endpoint: https://dune.com/oauth/mcp/token
  • Dynamic client registration endpoint: https://dune.com/oauth/mcp/register
  • JWKS endpoint: https://dune.com/oauth/mcp/jwks.json
  • Grant types: authorization_code, refresh_token
  • Client auth at token endpoint: none (public clients)
  • PKCE: required (S256)
  • Scope: mcp:dune:full
  • Resource parameter for authorization requests: https://api.dune.com

Troubleshooting

  • OAuth invalid_request on authorize: Verify required params (client_id, redirect_uri, state, code_challenge, code_challenge_method=S256, resource=https://api.dune.com).
  • OAuth unsupported_grant_type on token: Use only authorization_code or refresh_token.
  • OAuth invalid_grant on token exchange: Ensure your code_verifier matches the original PKCE challenge and redirect_uri exactly matches the authorize request.
  • Unauthorized from MCP endpoint: Sign in again with your Dune account. In a headless environment, check that the x-dune-api-key header has a valid key.
  • Codex Transport closed during long polls: Increase MCP tool timeout (for example tool_timeout_sec = 300) and restart the session if the transport already closed.

Dune Skills Repository

Agent Skills for Dune — portable instruction packages that teach AI agents how to work with blockchain data using the Dune CLI.

Dune CLI & Skills Docs

Learn how to use the Dune CLI and Agent Skills as an alternative to MCP for terminal-native AI workflows.

Privacy and Support