Skip to main content
Glama

export_results_to_csv

Download full Dune Analytics query results to a local CSV file for analysis. Specify the job ID to retrieve and export data.

Instructions

Download full query results to local CSV.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
job_idYes

Implementation Reference

  • MCP tool handler for 'export_results_to_csv'. Fetches job results using dune_service and exports to CSV using data_processor.export_to_csv. The @mcp.tool() decorator registers it as an MCP tool.
    @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 in export_dir.
    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