### Install Dune Analytics MCP Server via Smithery (Bash) Source: https://github.com/kukapay/dune-analytics-mcp/blob/main/README.md Installs the Dune Analytics MCP server for Claude Desktop using the Smithery CLI. This command automates the setup process. ```bash npx -y @smithery/cli install @kukapay/dune-analytics-mcp --client claude ``` -------------------------------- ### Smithery Installation Source: https://context7.com/kukapay/dune-analytics-mcp/llms.txt Instructions for installing the Dune Analytics MCP Server automatically using Smithery, which handles environment setup, API key management, and integration with Claude Desktop. ```APIDOC ## Installation via Smithery ### Description Automates the installation, configuration, and setup of the Dune Analytics MCP Server for Claude Desktop integration using the Smithery CLI. ### Method CLI Command ### Endpoint N/A ### Parameters N/A ### Request Example ```bash npx -y @smithery/cli install @kukapay/dune-analytics-mcp --client claude ``` ### Smithery Configuration Smithery automatically configures the following: - Python environment - API key management - Claude Desktop integration - Server startup command ``` -------------------------------- ### Dune Query Tool Examples (Python) Source: https://github.com/kukapay/dune-analytics-mcp/blob/main/README.md Examples of using the `get_latest_result` and `run_query` functions to interact with Dune Analytics. These functions accept a query ID and return results as CSV-formatted strings. ```python get_latest_result(query_id=4853921) ``` ```python run_query(query_id=1215383) ``` -------------------------------- ### Manually Install Dune Analytics MCP Server (Bash) Source: https://github.com/kukapay/dune-analytics-mcp/blob/main/README.md Guides through the manual installation of the Dune Analytics MCP server by cloning the repository and setting up environment variables. Requires Python 3.10+ and a Dune Analytics API key. ```bash git clone https://github.com/kukapay/dune-analytics-mcp.git cd dune-analytics-mcp ``` ```bash export DUNE_API_KEY="your_api_key_here" ``` -------------------------------- ### Dune Analytics MCP Server Setup and Execution Source: https://context7.com/kukapay/dune-analytics-mcp/llms.txt Commands for setting up environment variables, installing dependencies, and running the Dune Analytics MCP server in development mode or for Claude Desktop integration. Requires a Dune API key. ```bash # Set up environment variables export DUNE_API_KEY="your_dune_api_key_here" # Install dependencies pip install mcp[cli] pandas httpx python-dotenv # Run the server in development mode mcp dev main.py # Or install for Claude Desktop mcp install main.py --name "Dune Analytics" ``` -------------------------------- ### Run Dune Analytics MCP Server (Bash) Source: https://github.com/kukapay/dune-analytics-mcp/blob/main/README.md Commands to run the Dune Analytics MCP server in development mode or install it as a service for Claude Desktop. Development mode enables hot reloading. ```bash mcp dev main.py ``` ```bash mcp install main.py --name "Dune Analytics" ``` -------------------------------- ### Claude Desktop MCP Server Configuration Source: https://context7.com/kukapay/dune-analytics-mcp/llms.txt Example JSON configuration for integrating the Dune Analytics MCP server with Claude Desktop. Specifies the command to run the Python script and sets the necessary environment variables, including the Dune API key. ```json { "mcpServers": { "dune-analytics": { "command": "python", "args": ["/path/to/dune-analytics-mcp/main.py"], "env": { "DUNE_API_KEY": "your_dune_api_key_here" } } } } ``` -------------------------------- ### Direct Dune API Query with Python and httpx Source: https://context7.com/kukapay/dune-analytics-mcp/llms.txt Demonstrates a lower-level implementation for fetching query results directly from the Dune API using httpx and pandas. This function retrieves data, converts it to a pandas DataFrame, and then to a CSV-formatted string. It requires a Dune API key and handles HTTP requests with error management. ```python import httpx import pandas as pd import os DUNE_API_KEY = os.getenv("DUNE_API_KEY") BASE_URL = "https://api.dune.com/api/v1" HEADERS = {"X-Dune-API-Key": DUNE_API_KEY} # Direct API usage example (lower-level than MCP tools) def fetch_query_results(query_id: int): url = f"{BASE_URL}/query/{query_id}/results" with httpx.Client() as client: response = client.get(url, headers=HEADERS, timeout=300) response.raise_for_status() data = response.json() # Convert to DataFrame and CSV result_data = data.get("result", {}).get("rows", []) df = pd.DataFrame(result_data) return df.to_csv(index=False) # Usage csv_data = fetch_query_results(4853921) print(csv_data) ``` -------------------------------- ### Execute and Retrieve Dune Query Results with Python Source: https://context7.com/kukapay/dune-analytics-mcp/llms.txt Executes a Dune Analytics query by ID, polls for completion, and returns the results. This tool triggers a fresh query execution, useful when you need the most up-to-date data or when working with parameterized queries that need to be run with specific inputs. Requires connection to the MCP server. ```python from mcp.client import Client import time # Connect to the MCP server client = Client("dune-analytics-mcp") # Execute a DeFi TVL query response = client.call_tool("run_query", { "query_id": 1215383 }) # Response includes execution status and CSV results print(response) # Output: # protocol,tvl_usd,chain,last_updated # Uniswap,4250000000,ethereum,2026-01-01 # Aave,3890000000,ethereum,2026-01-01 # Curve,2340000000,ethereum,2026-01-01 # Compound,1680000000,ethereum,2026-01-01 ``` -------------------------------- ### Execute Dune Query with Polling - Python Source: https://context7.com/kukapay/dune-analytics-mcp/llms.txt Executes a Dune Analytics query and polls for completion using Python's httpx library. It handles the asynchronous nature of query execution by repeatedly checking the status until the query is COMPLETED, then fetches and returns the results. Dependencies include httpx and time. ```python import httpx import time def execute_and_wait(query_id: int): with httpx.Client() as client: # Start execution url = f"{BASE_URL}/query/execute/{query_id}" response = client.post(url, headers=HEADERS, timeout=300) execution_id = response.json().get("execution_id") # Poll for completion status_url = f"{BASE_URL}/execution/{execution_id}/status" while True: status = client.get(status_url, headers=HEADERS).json() state = status.get("state") if state == "COMPLETED": break elif state in ["EXECUTING", "PENDING"]: time.sleep(5) else: raise Exception(f"Execution failed: {state}") # Fetch results results_url = f"{BASE_URL}/execution/{execution_id}/results" results = client.get(results_url, headers=HEADERS).json() return results # Execute query and get results results = execute_and_wait(1215383) ``` -------------------------------- ### Query Execution with Polling Source: https://context7.com/kukapay/dune-analytics-mcp/llms.txt This API endpoint allows for the asynchronous execution of a Dune Analytics query and provides a polling mechanism to wait for the query's completion before returning the results. It handles the asynchronous nature of Dune's query execution by first initiating the query, then periodically checking its status, and finally fetching the results once completed. ```APIDOC ## POST /query/execute/{query_id} ### Description Initiates the execution of a specified Dune Analytics query and polls for its completion status. ### Method POST ### Endpoint `/query/execute/{query_id}` ### Parameters #### Path Parameters - **query_id** (integer) - Required - The unique identifier of the Dune query to execute. #### Request Body This endpoint does not require a request body. ### Request Example ```json { "query_id": 1215383 } ``` ### Response #### Success Response (200) - **execution_id** (string) - The ID for tracking the execution status and retrieving results. #### Response Example ```json { "execution_id": "some_execution_id_string" } ``` --- ## GET /execution/{execution_id}/status ### Description Retrieves the current status of a query execution. ### Method GET ### Endpoint `/execution/{execution_id}/status` ### Parameters #### Path Parameters - **execution_id** (string) - Required - The ID of the execution to check the status for. #### Query Parameters This endpoint does not require query parameters. ### Request Example ```json { "execution_id": "some_execution_id_string" } ``` ### Response #### Success Response (200) - **state** (string) - The current state of the execution (e.g., "PENDING", "EXECUTING", "COMPLETED", "FAILED"). #### Response Example ```json { "state": "COMPLETED" } ``` --- ## GET /execution/{execution_id}/results ### Description Fetches the results of a completed query execution. ### Method GET ### Endpoint `/execution/{execution_id}/results` ### Parameters #### Path Parameters - **execution_id** (string) - Required - The ID of the execution whose results are to be fetched. #### Query Parameters This endpoint does not require query parameters. ### Request Example ```json { "execution_id": "some_execution_id_string" } ``` ### Response #### Success Response (200) - **results** (object) - A JSON object containing the query results. The structure of this object depends on the query itself (e.g., rows, columns, data types). #### Response Example ```json { "results": { "columns": [ {"name": "column1", "type": "string"}, {"name": "column2", "type": "number"} ], "rows": [ {"column1": "value1", "column2": 100}, {"column1": "value2", "column2": 200} ] } } ``` ``` -------------------------------- ### Fetch Latest Dune Query Results with Python Source: https://context7.com/kukapay/dune-analytics-mcp/llms.txt Retrieves the most recent cached execution results for a specified Dune Analytics query by ID. This tool is ideal for frequently-run queries where the latest cached data is sufficient, avoiding the overhead of re-executing the query. Requires connection to the MCP server. ```python from mcp.client import Client # Connect to the MCP server client = Client("dune-analytics-mcp") # Fetch latest results for ETH price query response = client.call_tool("get_latest_result", { "query_id": 4853921 }) # Response is CSV-formatted string print(response) # Output: # timestamp,price_usd,volume_24h # 2026-01-01 12:00:00,3845.67,2500000000 # 2026-01-01 11:00:00,3842.13,2450000000 # 2026-01-01 10:00:00,3850.92,2600000000 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.