Skip to main content
Glama
smith-nathanh

Oracle MCP Server

export_query_results

Execute SQL queries and export results in JSON or CSV formats for data analysis and sharing.

Instructions

Export query results in various formats (JSON, CSV)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYesSQL query to execute and export
formatNoExport formatjson

Implementation Reference

  • The main handler for the 'export_query_results' tool within the call_tool method. It executes the provided SQL query using the QueryExecutor, then formats and returns the results as either CSV or JSON based on the specified format.
    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), ) ]
  • Registers the 'export_query_results' tool with the MCP server in the list_tools handler, including the input schema definition for parameters 'sql' and optional 'format'.
    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"], }, ),
  • The input schema for the 'export_query_results' tool, defining the expected parameters and validation rules.
    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