Skip to main content
Glama
tannerpace

Oracle Database MCP Server

query_database

Execute read-only SQL SELECT queries against Oracle databases to retrieve data, column names, and execution metrics for analysis.

Instructions

Execute a read-only SQL SELECT query against the Oracle database. Returns rows, column names, and execution metrics.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe SQL query to execute (SELECT statements only)
maxRowsNoMaximum number of rows to return (optional)
timeoutNoQuery timeout in milliseconds (optional)

Implementation Reference

  • The core handler function implementing the logic for the 'query_database' MCP tool. Validates input, executes the SQL query using executeQuery, logs activity, and returns structured success/error response.
    export async function queryDatabase(input: QueryDatabaseInput) {
      try {
        // Validate input
        const validated = QueryDatabaseSchema.parse(input);
    
        logger.info('Executing query via MCP tool', {
          queryLength: validated.query.length,
          maxRows: validated.maxRows,
        });
    
        // Execute the query
        const result = await executeQuery(validated.query, {
          maxRows: validated.maxRows,
          timeout: validated.timeout,
        });
    
        return {
          success: true,
          data: result,
        };
      } catch (err: any) {
        logger.error('Query database tool failed', { error: err.message });
    
        return {
          success: false,
          error: err.message || 'Unknown error occurred',
        };
      }
    }
  • Zod input validation schema for the 'query_database' tool, defining query (required string), maxRows, and timeout (optional numbers).
    export const QueryDatabaseSchema = z.object({
      query: z.string().min(1, 'Query cannot be empty'),
      maxRows: z.number().int().positive().optional(),
      timeout: z.number().int().positive().optional(),
    });
  • src/server.ts:90-101 (registration)
    Dispatch logic in MCP server for handling 'tools/call' requests for 'query_database'. Parses arguments, calls the handler, and returns MCP-formatted text response.
    if (name === 'query_database') {
      const validated = QueryDatabaseSchema.parse(args);
      const result = await queryDatabase(validated);
    
      return {
        content: [
          {
            type: 'text' as const,
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
  • src/server.ts:38-60 (registration)
    Tool metadata registration for 'query_database' used in MCP 'tools/list' response, including JSON Schema matching the Zod schema.
    {
      name: 'query_database',
      description:
        'Execute a read-only SQL SELECT query against the Oracle database. Returns rows, column names, and execution metrics.',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'The SQL query to execute (SELECT statements only)',
          },
          maxRows: {
            type: 'number',
            description: 'Maximum number of rows to return (optional)',
          },
          timeout: {
            type: 'number',
            description: 'Query timeout in milliseconds (optional)',
          },
        },
        required: ['query'],
      },
    },
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively states the tool is 'read-only', which implies safety from mutations, and mentions return types and execution metrics, adding useful context. However, it lacks details on permissions, rate limits, error handling, or database-specific constraints, which are important for a database query tool.

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 front-loaded and concise, consisting of two sentences that efficiently convey the tool's purpose, constraints, and outputs without any wasted words. Every sentence earns its place by providing essential information, making it easy to understand at a glance.

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

Completeness4/5

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

Given the tool's complexity (database querying with multiple parameters) and the absence of annotations and output schema, the description does a good job by specifying the query type, database, and return data. However, it could be more complete by including details on output format, error responses, or connection requirements, which would help an agent use it more effectively.

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, so the schema already documents all parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema, such as query syntax examples or default values for optional parameters. This meets the baseline score of 3, 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.

Purpose5/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 with specific verbs ('Execute a read-only SQL SELECT query') and resources ('against the Oracle database'), and distinguishes it from potential siblings by specifying it's for SELECT queries only. It explicitly mentions what it returns ('rows, column names, and execution metrics'), making the purpose unambiguous and comprehensive.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool by specifying 'read-only SQL SELECT query' and 'SELECT statements only', which implicitly guides usage for data retrieval rather than modifications. However, it does not explicitly mention when not to use it or name alternatives like 'get_database_schema' for schema queries, leaving some room for improvement in sibling differentiation.

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/tannerpace/mcp-oracle-database'

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