Skip to main content
Glama
smith-nathanh

Oracle MCP Server

generate_sample_queries

Create sample SQL queries for database tables to facilitate data exploration and analysis in Oracle environments.

Instructions

Generate sample SQL queries for a given table to help with exploration

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYesName of the table to generate queries for
ownerNoSchema owner (optional)

Implementation Reference

  • The main handler function for the 'generate_sample_queries' tool within the call_tool method. It fetches table columns, generates sample SQL queries based on column types (select all, count, distinct values, stats, date ranges), and returns them as JSON.
    elif name == "generate_sample_queries":
        table_name = arguments.get("table_name")
        owner = arguments.get("owner")
    
        columns = await self.inspector.get_table_columns(table_name, owner)
    
        # Generate sample queries
        table_ref = f"{owner}.{table_name}" if owner else table_name
    
        queries = [
            f"-- Basic select all\nSELECT * FROM {table_ref} WHERE ROWNUM <= 10;",
            f"-- Count total rows\nSELECT COUNT(*) FROM {table_ref};",
        ]
    
        # Add column-specific queries
        for col in columns[:5]:  # Limit to first 5 columns
            col_name = col["column_name"]
    
            if col["data_type"] in ["VARCHAR2", "CHAR", "CLOB"]:
                queries.append(
                    f"-- Find distinct values for {col_name}\nSELECT DISTINCT {col_name} FROM {table_ref} WHERE {col_name} IS NOT NULL AND ROWNUM <= 20;"
                )
            elif col["data_type"] in ["NUMBER", "INTEGER"]:
                queries.append(
                    f"-- Statistics for {col_name}\nSELECT MIN({col_name}), MAX({col_name}), AVG({col_name}) FROM {table_ref};"
                )
            elif col["data_type"] in ["DATE", "TIMESTAMP"]:
                queries.append(
                    f"-- Date range for {col_name}\nSELECT MIN({col_name}), MAX({col_name}) FROM {table_ref};"
                )
    
        result = {"table_name": table_name, "sample_queries": queries}
    
        return [
            TextContent(
                type="text", text=json.dumps(result, indent=2, default=str)
            )
        ]
  • Input schema definition for the 'generate_sample_queries' tool, specifying required 'table_name' and optional 'owner' parameters.
        "type": "object",
        "properties": {
            "table_name": {
                "type": "string",
                "description": "Name of the table to generate queries for",
            },
            "owner": {
                "type": "string",
                "description": "Schema owner (optional)",
                "default": None,
            },
        },
        "required": ["table_name"],
    },
  • Registration of the 'generate_sample_queries' tool in the list_tools handler, including name, description, and input schema.
    Tool(
        name="generate_sample_queries",
        description="Generate sample SQL queries for a given table to help with exploration",
        inputSchema={
            "type": "object",
            "properties": {
                "table_name": {
                    "type": "string",
                    "description": "Name of the table to generate queries for",
                },
                "owner": {
                    "type": "string",
                    "description": "Schema owner (optional)",
                    "default": None,
                },
            },
            "required": ["table_name"],
        },
    ),
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 of behavioral disclosure. It states the tool generates queries but doesn't describe key behaviors: what types of queries are generated (e.g., SELECT, JOIN), how many queries are produced, whether they include sample data or are template-based, or if there are any limitations (e.g., rate limits or permissions required). This leaves significant gaps for an agent to understand the tool's operation.

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 a single, efficient sentence: 'Generate sample SQL queries for a given table to help with exploration.' It is front-loaded with the core purpose and wastes no words, making it highly concise and well-structured for quick understanding.

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 lack of annotations and output schema, the description is incomplete for a tool that generates queries. It doesn't explain what the output looks like (e.g., a list of query strings, formatted results), any behavioral constraints, or how it integrates with sibling tools. For a tool with 2 parameters and no structured output documentation, more context is needed to guide 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?

The input schema has 100% description coverage, with clear documentation for both parameters ('table_name' and 'owner'). The description adds no additional parameter semantics beyond what the schema provides, such as format examples or usage tips. According to the rules, with high schema coverage (>80%), the baseline is 3, which is appropriate here 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: 'Generate sample SQL queries for a given table to help with exploration.' It specifies the verb ('generate'), resource ('sample SQL queries'), and target ('given table'), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'describe_table' or 'explain_query', which prevents a perfect score.

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 mentions 'to help with exploration,' but doesn't specify scenarios where this is preferred over tools like 'describe_table' for understanding table structure or 'execute_query' for running actual queries. There are no explicit when/when-not instructions or named alternatives.

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