Skip to main content
Glama

format_sql

Read-onlyIdempotent

Reformat SQL into one clause per line with optional uppercase keywords and trailing semicolons, preserving comments. Returns formatted SQL and applied options.

Instructions

Use this when the user wants SQL pretty-printed or reformatted: one clause per line, optional upper-case keywords and trailing semicolon. Comments are preserved; unplaceable optimizer hints are refused. Returns {formatted_sql, options}.

Input Schema

NameRequiredDescriptionDefault
sqlYesThe SQL string to format
indent_sizeNoSpaces per indent level for nested blocks such as CREATE TABLE columns; clauses always start at column 0. 0 puts each statement on one line (default: 2)
add_semicolonNoAppend a trailing semicolon (default: false)
uppercase_keywordsNotrue upper-cases all SQL keywords (AND, IN, CASE, ...), but not data type names. false keeps the formatter's casing: clause keywords (SELECT, FROM, WHERE, ...) upper-case, other keywords (e.g. like) may keep their input case (default: false)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.17.0
    • changedInput schema / properties / uppercase_keywords / description
      Previous value: -"true upper-cases all SQL keywords (AND, IN, CASE, ...), but not data type names. false keeps the formatter's casing: clause keywords (SELECT, FROM, WHERE, ...) upper-case, other keywords (e.g. and, or) may keep their input case (default: false)"New value: +"true upper-cases all SQL keywords (AND, IN, CASE, ...), but not data type names. false keeps the formatter's casing: clause keywords (SELECT, FROM, WHERE, ...) upper-case, other keywords (e.g. like) may keep their input case (default: false)"
  2. Changed2 schema fields changedv1.16.1
    • changedInput schema / properties / indent_size / description
      Previous value: -"Spaces per indent level (default: 2)"New value: +"Spaces per indent level for nested blocks such as CREATE TABLE columns; clauses always start at column 0. 0 puts each statement on one line (default: 2)"
    • changedInput schema / properties / uppercase_keywords / description
      Previous value: -"Uppercase SQL keywords (default: false)"New value: +"true upper-cases all SQL keywords (AND, IN, CASE, ...), but not data type names. false keeps the formatter's casing: clause keywords (SELECT, FROM, WHERE, ...) upper-case, other keywords (e.g. and, or) may keep their input case (default: false)"
  3. First observedv1.12.1

TDQS

A4/5.0
Behavior4/5

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

Annotations already declare this as a safe, read-only, idempotent, non-destructive operation. The description adds meaningful behavior beyond annotations: comments are preserved, unplaceable optimizer hints are refused, and the return shape is {formatted_sql, options}. It does not contradict annotations.

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 compact and front-loaded with the usage trigger, followed by key formatting behavior, edge cases, and return shape. Every sentence contributes useful information without repetition.

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 fully specified input schema and annotations, the description covers the purpose, main options, edge-case behavior, and return keys. It is nearly complete, though the returned 'options' object is not expanded and there is no output schema to rely on for that detail.

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 all four parameters are already well documented in the schema. The description reinforces optional uppercase keywords and trailing semicolon behavior, but it does not mention indent_size or add meaning beyond the schema, so the baseline of 3 applies.

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 states a specific verb and resource: pretty-printing/reformatting SQL, with concrete formatting behavior. It is clearly distinguishable from siblings like lint_sql, validate_sql, and analyze_sql by being purely cosmetic, though it does not explicitly name those alternatives.

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?

It gives an explicit trigger: 'Use this when the user wants SQL pretty-printed or reformatted.' That is strong usage guidance, but it does not state when not to use it or explicitly route to validation/linting alternatives.

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