dune-analytics-mcp
Dune Analytics MCP Server: Connect Dune data to AI models securely via MCP.

dune-analytics-mcp Solution Overview
The Dune Analytics MCP server is a crucial tool for AI developers seeking to integrate on-chain data into their models. As an MCP server, it bridges the gap between AI agents and Dune Analytics, a leading blockchain data platform. It empowers AI models to securely access and leverage Dune's extensive datasets through simple function calls.
This server offers two primary functions: get_latest_result
to fetch the most recent results of a Dune query, and run_query
to execute a Dune query and retrieve real-time data. Both functions return data in CSV format, ensuring seamless compatibility with various AI model frameworks. By using the Dune Analytics MCP server, developers can build AI applications that analyze market trends, identify anomalies, and gain valuable insights from blockchain data, all while streamlining data integration and focusing on model development. Installation is simplified through the MCP command-line tool, making it easy to deploy and integrate with Claude Desktop.
dune-analytics-mcp Key Capabilities
Fetch Latest Query Results
The get_latest_result
function allows AI models to retrieve the most recent results of a specified Dune Analytics query. It takes a query_id
as input, which identifies the specific query within the Dune Analytics platform. The function then accesses the Dune Analytics API, fetches the latest execution results for that query, and returns the data as a CSV-formatted string. This ensures that the AI model receives structured, easily parsable data. The function is particularly useful when AI models need to make decisions based on the most up-to-date information available from Dune Analytics, such as real-time market trends or the latest on-chain activity.
For example, an AI-powered trading bot could use get_latest_result
to fetch the latest trading volume of a specific token from a Dune Analytics query. The bot can then analyze this data to make informed trading decisions. The technical implementation involves making an API call to Dune Analytics using the provided query_id
and parsing the returned JSON data into a CSV string.
Execute Dune Query and Retrieve Results
The run_query
function enables AI models to execute a Dune Analytics query on demand and retrieve the results. Similar to get_latest_result
, it accepts a query_id
as input. However, instead of simply fetching the latest results, this function triggers a new execution of the specified query within Dune Analytics. Once the query execution is complete, the function retrieves the results and returns them as a CSV-formatted string. This is valuable when AI models require real-time data that is not yet available or when the existing cached results are outdated.
Consider a scenario where an AI model is monitoring the health of a decentralized finance (DeFi) protocol. The AI could use run_query
to execute a Dune Analytics query that calculates the protocol's total value locked (TVL) in real-time. The AI can then analyze the TVL data to detect any potential risks or vulnerabilities in the protocol. The technical implementation involves initiating a query execution via the Dune Analytics API, waiting for the execution to complete, and then retrieving and formatting the results into a CSV string.
Standardized CSV Output
All data returned by the dune-analytics-mcp
server is formatted as CSV (Comma Separated Values) strings. This standardization is crucial for seamless integration with AI models. CSV is a widely supported and easily parsable format, allowing AI models to quickly ingest and process the data without requiring complex data transformation steps. This simplifies the development process and reduces the computational overhead on the AI model's side. The consistent CSV output ensures that AI models can reliably extract the necessary information from Dune Analytics data, regardless of the specific query being executed.
For instance, an AI model designed to analyze on-chain voting behavior can receive voting data from Dune Analytics via the MCP server in CSV format. The AI can then easily parse the CSV data to identify voting patterns and trends. The technical implementation involves converting the JSON response from the Dune Analytics API into a CSV string before sending it to the AI model. This conversion ensures that the data is in a standardized format that the AI model can readily understand.