Skip to main content
Glama
turbot
by turbot

steampipe_query

Query cloud infrastructure, SaaS, APIs, and code using SQL to analyze data from multiple sources with PostgreSQL syntax.

Instructions

Query cloud infrastructure, SaaS, APIs, code and more with SQL.

Queries are read-only and must use PostgreSQL syntax.

For best performance: limit columns requested, use materialized CTEs instead of joins. Trust the search path unless sure you need to specify a schema.

Check available tables and columns before querying using steampipe_table_list and steampipe_table_show.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYesThe SQL query to execute. Must use PostgreSQL syntax and be read-only.

Implementation Reference

  • The main handler function for the steampipe_query tool. It executes the provided SQL query using DatabaseService.executeQuery and returns the results as JSON string or an error message.
    handler: async (db: DatabaseService | undefined, args: { sql: string }) => {
      if (!db) {
        return {
          content: [{ type: "text", text: "Database not available" }],
          isError: true,
        };
      }
    
      try {
        const rows = await db.executeQuery(args.sql);
        return {
          content: [{ type: "text", text: JSON.stringify(rows) }],
          isError: false
        };
      } catch (error) {
        logger.error('Error executing query:', error);
        return {
          content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
          isError: true
        };
      }
    }
  • The input schema defining the required 'sql' parameter as a string for the SQL query.
    inputSchema: {
      type: "object",
      properties: {
        sql: {
          type: "string",
          description: "The SQL query to execute. Must use PostgreSQL syntax and be read-only."
        }
      },
      required: ["sql"],
      additionalProperties: false
    },
  • Registration of the steampipe_query tool in the central tools export object, which is used by setupTools to register with the MCP server.
    export const tools = {
      steampipe_query: queryTool as DbTool,
      steampipe_table_list: tableListTool as DbTool,
      steampipe_table_show: tableShowTool as DbTool,
      steampipe_plugin_list: pluginListTool as DbTool,
      steampipe_plugin_show: pluginShowTool as DbTool,
    } as const;
Behavior4/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 describes key traits: queries are 'read-only,' must use 'PostgreSQL syntax,' and includes performance tips (limit columns, use CTEs, trust search path). This covers safety, syntax, and optimization, though it lacks details on error handling or output format.

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 well-structured and front-loaded, starting with the core purpose. Each sentence adds value: purpose, constraints, performance tips, and sibling tool references. There is no wasted text, making it efficient and easy to parse.

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 (querying multiple data sources) and lack of annotations/output schema, the description does a good job covering key aspects: purpose, constraints, performance, and sibling tool integration. However, it doesn't explain return values or error cases, leaving some gaps for a tool with no output schema.

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 schema description coverage is 100%, with the parameter 'sql' fully documented in the schema. The description adds minimal semantics beyond this, only reiterating that SQL must be 'read-only' and use 'PostgreSQL syntax,' which is already in the schema. This meets the baseline for high schema coverage.

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: 'Query cloud infrastructure, SaaS, APIs, code and more with SQL.' It specifies the verb ('query') and resources, but doesn't explicitly differentiate from sibling tools like steampipe_table_list/show, which are mentioned for checking tables rather than querying. This makes it clear but not fully sibling-distinguished.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool vs alternatives: it instructs to 'Check available tables and columns before querying using steampipe_table_list and steampipe_table_show.' This clearly defines a usage sequence and distinguishes it from sibling tools, offering practical 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/turbot/steampipe-mcp'

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