Skip to main content
Glama

export_results_to_csv

Download full query results from Dune Analytics to a local CSV file for analysis and reporting.

Instructions

Download full query results to local CSV.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
job_idYes

Implementation Reference

  • Handler function for 'export_results_to_csv' tool. Registered via @mcp.tool() decorator. Fetches job results using dune_service and exports via data_processor.export_to_csv.
    @mcp.tool() def export_results_to_csv(job_id: str) -> str: """ Download full query results to local CSV. """ try: raw_result = dune_service.get_result(job_id) path = data_processor.export_to_csv(raw_result, job_id) return f"Success! Data saved to: {path}" except Exception as e: return f"Error exporting data: {str(e)}"
  • Supporting method in DataProcessor class that converts Dune results to pandas DataFrame and saves as CSV file.
    def export_to_csv(self, result_data: Any, job_id: str) -> str: """ Exports full results to CSV. """ try: rows = result_data.result.rows except AttributeError: rows = result_data if isinstance(result_data, list) else [] if not rows: return "No data to export" df = pd.DataFrame(rows) filename = f"dune_results_{job_id}.csv" filepath = os.path.join(self.export_dir, filename) df.to_csv(filepath, index=False) return filepath

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nice-bills/dune-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server