Skip to main content
Glama
HatriGt

HANA Cloud MCP Server

by HatriGt

hana_execute_query

Execute custom SQL queries on HANA Cloud database to retrieve, analyze, or modify data through prepared statements.

Instructions

Execute a custom SQL query against the HANA database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe SQL query to execute
parametersNoOptional parameters for the query (for prepared statements)

Implementation Reference

  • The main handler function QueryTools.executeQuery that validates input, executes the SQL query using QueryExecutor, formats results, and handles errors.
    static async executeQuery(args) {
      logger.tool('hana_execute_query', args);
      
      const { query, parameters = [] } = args || {};
      
      // Validate required parameters
      const validation = Validators.validateRequired(args, ['query'], 'hana_execute_query');
      if (!validation.valid) {
        return Formatters.createErrorResponse('Error: query parameter is required', validation.error);
      }
      
      // Validate query
      const queryValidation = Validators.validateQuery(query);
      if (!queryValidation.valid) {
        return Formatters.createErrorResponse('Invalid query', queryValidation.error);
      }
      
      // Validate parameters
      const paramValidation = Validators.validateParameters(parameters);
      if (!paramValidation.valid) {
        return Formatters.createErrorResponse('Invalid parameters', paramValidation.error);
      }
      
      try {
        const results = await QueryExecutor.executeQuery(query, parameters);
        const formattedResults = Formatters.formatQueryResults(results, query);
        
        return Formatters.createResponse(formattedResults);
      } catch (error) {
        logger.error('Query execution failed:', error.message);
        return Formatters.createErrorResponse('Query execution failed', error.message);
      }
    }
  • The input schema definition for the hana_execute_query tool, specifying the query parameter as required and parameters as optional array.
      name: "hana_execute_query",
      description: "Execute a custom SQL query against the HANA database",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "The SQL query to execute"
          },
          parameters: {
            type: "array",
            description: "Optional parameters for the query (for prepared statements)",
            items: {
              type: "string"
            }
          }
        },
        required: ["query"]
      }
    }
  • The TOOL_IMPLEMENTATIONS object that registers 'hana_execute_query' mapped to QueryTools.executeQuery for execution via ToolRegistry.
    const TOOL_IMPLEMENTATIONS = {
      hana_show_config: ConfigTools.showConfig,
      hana_test_connection: ConfigTools.testConnection,
      hana_show_env_vars: ConfigTools.showEnvVars,
      hana_list_schemas: SchemaTools.listSchemas,
      hana_list_tables: TableTools.listTables,
      hana_describe_table: TableTools.describeTable,
      hana_list_indexes: IndexTools.listIndexes,
      hana_describe_index: IndexTools.describeIndex,
      hana_execute_query: QueryTools.executeQuery
    };
Behavior2/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 states the tool executes a custom SQL query but lacks critical details: it doesn't specify if this is read-only or can perform mutations, potential risks like data modification or deletion, authentication requirements, or response handling (e.g., result format, error messages). This is inadequate for a tool that could have significant side effects.

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 that directly states the tool's function without unnecessary words. It is front-loaded and appropriately sized, 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 of executing custom SQL queries (which could involve reads, writes, or schema changes), no annotations, and no output schema, the description is insufficient. It doesn't address behavioral traits, return values, or error conditions, leaving significant gaps for an AI agent to understand how to use the tool safely and 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, clearly documenting both parameters ('query' and 'parameters'). The description adds no additional meaning beyond this, such as query syntax examples or parameter usage details. According to the rules, with high schema coverage, the baseline is 3 even without param info in the description.

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 action ('Execute') and target resource ('custom SQL query against the HANA database'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like hana_describe_table or hana_list_tables, which might also involve database queries but for specific purposes.

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, such as needing a valid database connection, or contrast it with sibling tools like hana_list_tables for metadata queries versus this for custom SQL execution, leaving the agent to infer usage context.

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/HatriGt/hana-mcp-server'

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