home / mcp / dune analytics mcp server

Dune Analytics MCP Server

A mcp server that bridges Dune Analytics data to AI agents.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "kukapay-dune-analytics-mcp": {
      "command": "mcp",
      "args": [
        "dev",
        "main.py"
      ],
      "env": {
        "DUNE_API_KEY": "YOUR_API_KEY_HERE"
      }
    }
  }
}

Dune Analytics MCP Server bridges Dune Analytics data to AI agents. It exposes tools that fetch or run Dune queries and returns results as CSV strings for easy downstream processing.

How to use

You interact with the Dune Analytics MCP Server through an MCP client. The server provides two core tools that return results as CSV text, making it straightforward to feed data into agents or pipelines: the get_latest_result tool and the run_query tool.

How to install

Prerequisites you need before running the server:

- Python 3.10+

- A valid Dune Analytics API key (you obtain this from Dune Analytics)

How to install

Install via MCP client (CLI) to run the server in Claude Desktop or similar environments.

mcp dev main.py

How to install

Install for Claude Desktop as a service

mcp install main.py --name "Dune Analytics"

Additional setup notes

Create an environment file at the project root or set an environment variable for the Dune API key.

DUNE_API_KEY=your_api_key_here

Tool usage

The server exposes two main tools. Use them by calling the tool names with the required query IDs. Each tool returns a CSV-formatted string.

1) get_latest_result(query_id) retrieves the latest results for a given Dune query.

2) run_query(query_id) executes a Dune query and returns the results.

get_latest_result(query_id=4853921)
run_query(query_id=1215383)

Example commands in Claude Desktop

You could say commands in natural language such as: "Get latest results for dune query 1215383" or "Run dune query 1215383" to trigger the corresponding MCP tool.

Available tools

get_latest_result

Fetches the latest results of a specified Dune query by its ID and returns the data as a CSV-formatted string.

run_query

Executes a Dune query by its ID and returns the results as a CSV-formatted string.