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"],
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions the export action but lacks critical behavioral details: whether this executes the query (implying read/write operations), permission requirements, rate limits, output handling (e.g., file generation or direct return), or error conditions. The description is minimal and misses key operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise—a single sentence with zero waste. It is front-loaded with the core purpose and efficiently lists the formats. Every word earns its place, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (a tool that likely executes and exports queries), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what happens (e.g., does it return a file, trigger a download, or include results in response?), success/error behaviors, or integration with siblings. More context is needed for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents both parameters (sql and format). The description adds no additional meaning beyond stating 'various formats (JSON, CSV)', which is already covered by the enum in the schema. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Export query results in various formats (JSON, CSV)'. It specifies the verb ('Export') and resource ('query results'), and distinguishes it from siblings like execute_query by focusing on export functionality. However, it doesn't explicitly differentiate from all siblings (e.g., generate_sample_queries).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing valid SQL), exclusions, or comparisons to siblings like execute_query (which might return results without export). Usage is implied but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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