Skip to main content
Glama
smith-nathanh

Oracle MCP Server

export_query_results

Execute SQL queries and export results in JSON or CSV format for data analysis and reporting.

Instructions

Export query results in various formats (JSON, CSV)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoExport formatjson
sqlYesSQL query to execute and export

Implementation Reference

  • Handler for 'export_query_results' tool: executes SQL query using QueryExecutor, then exports results as CSV or JSON based on format parameter.
    elif name == "export_query_results": sql = arguments.get("sql") format_type = arguments.get("format", "json") result = await self.executor.execute_query(sql) if format_type == "csv": # Convert to CSV format csv_lines = [] csv_lines.append(",".join(result["columns"])) for row in result["rows"]: csv_row = [] for value in row: if value is None: csv_row.append("") else: # Escape commas and quotes str_value = str(value) if "," in str_value or '"' in str_value: str_value = ( '"' + str_value.replace('"', '""') + '"' ) csv_row.append(str_value) csv_lines.append(",".join(csv_row)) csv_content = "\n".join(csv_lines) return [ TextContent( type="text", text=f"CSV Export ({result['row_count']} rows):\n\n{csv_content}", ) ] else: return [ TextContent( type="text", text=json.dumps(result, indent=2, default=str), ) ]
  • Registration of 'export_query_results' tool in list_tools handler, including input schema definition.
    Tool( name="export_query_results", description="Export query results in various formats (JSON, CSV)", inputSchema={ "type": "object", "properties": { "sql": { "type": "string", "description": "SQL query to execute and export", }, "format": { "type": "string", "enum": ["json", "csv"], "description": "Export format", "default": "json", }, }, "required": ["sql"], }, ),
  • Input schema for 'export_query_results' tool defining sql (required) and format (json/csv, default json).
    Tool( name="export_query_results", description="Export query results in various formats (JSON, CSV)", inputSchema={ "type": "object", "properties": { "sql": { "type": "string", "description": "SQL query to execute and export", }, "format": { "type": "string", "enum": ["json", "csv"], "description": "Export format", "default": "json", }, }, "required": ["sql"], }, ),

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/smith-nathanh/oracle-mcp-server'

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