Skip to main content
Glama

cross_db_query

Read-onlyIdempotent

⚠️ SQL MUST BE VALID IN EVERY DIALECT YOU TARGET — stick to ANSI-ish SELECT syntax when mixing pg/mysql/mssql. SELECT TOP 10 (mssql) or LIMIT (others) will fail on the wrong side. Run the same query across 2-4 connections in parallel; returns per-connection rows + errors for diffing. Canonical use cases: regional compare (['mssql-reporting-us', 'mssql-reporting-eu']), cross-dialect sync check (['prod-postgres-fleet', 'prod-mysql-app']), 3-env drift, 4-region compare. Resolve every connection name via list_connections first; tool fails per-connection on unknown names. Cap: 4 connections per call on every plan; to compare more, split into sequential calls of ≤4 and combine. [ARCHITECT tier]

Input Schema

NameRequiredDescriptionDefault
sqlYesSQL query to run on each connection. Must be valid in every dialect targeted — prefer ANSI SELECT syntax when mixing dialects.
connectionsYesArray of 2-4 connection NAMES (not IDs) from list_connections output. Examples: ['mssql-reporting-us', 'mssql-reporting-eu'] for regional compare, ['prod-postgres-fleet', 'prod-mysql-app'] for cross-dialect sync check.

Output Schema

NameRequiredDescriptionDefault
dataNo
metaNo
displayNo
summaryNo
insightsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed14 schema fields changed
    • removedInput schema / additionalProperties
      Removed value: -false
    • changedOutput schema / additionalProperties
      Previous value: -trueNew value: +{}
    • changedOutput schema / properties / data / anyOf
      Previous value: -[
      -  {
      -    "items": {
      -      "additionalProperties": true,
      -      "properties": {
      -        "connection": {
      -          "type": "string"
      -        },
      -        "error": {
      -          "type": [
      -            "string",
      -            "null"
      -          ]
      -        },
      -        "execution_ms": {
      -          "$ref": "#/properties/data/anyOf/0/items/properties/rows/anyOf/2"
      -        },
      -        "rows": {
      -          "anyOf": [
      -            {
      -              "items": {
      -                "additionalProperties": {},
      -                "type": "object"
      -              },
      -              "type": "array"
      -            },
      -            {
      -              "type": "null"
      -            },
      -            {
      -              "type": [
      -                "number",
      -                "string"
      -              ]
      -            }
      -          ]
      -        },
      -        "sample": {
      -          "items": {
      -            "additionalProperties": {},
      -            "type": "object"
      -          },
      -          "type": "array"
      -        }
      -      },
      -      "required": [
      -        "connection"
      -      ],
      -      "type": "object"
      -    },
      -    "type": "array"
      -  },
      -  {
      -    "additionalProperties": true,
      -    "properties": {
      -      "code": {
      -        "type": "string"
      -      },
      -      "details": {
      -        "additionalProperties": {},
      -        "type": "object"
      -      },
      -      "error": {
      -        "type": "string"
      -      },
      -      "internal_code": {
      -        "type": "string"
      -      },
      -      "message": {
      -        "type": "string"
      -      },
      -      "retry_after_s": {
      -        "type": "number"
      -      },
      -      "retryable": {
      -        "type": "boolean"
      -      }
      -    },
      -    "required": [
      -      "error"
      -    ],
      -    "type": "object"
      -  }
      -]New value: +[
      +  {
      +    "items": {
      +      "additionalProperties": {},
      +      "properties": {
      +        "connection": {
      +          "type": "string"
      +        },
      +        "error": {
      +          "type": [
      +            "string",
      +            "null"
      +          ]
      +        },
      +        "execution_ms": {
      +          "type": [
      +            "number",
      +            "string"
      +          ]
      +        },
      +        "rows": {
      +          "anyOf": [
      +            {
      +              "items": {
      +                "additionalProperties": {},
      +                "propertyNames": {
      +                  "type": "string"
      +                },
      +                "type": "object"
      +              },
      +              "type": "array"
      +            },
      +            {
      +              "type": "null"
      +            },
      +            {
      +              "type": [
      +                "number",
      +                "string"
      +              ]
      +            }
      +          ]
      +        },
      +        "sample": {
      +          "items": {
      +            "additionalProperties": {},
      +            "propertyNames": {
      +              "type": "string"
      +            },
      +            "type": "object"
      +          },
      +          "type": "array"
      +        }
      +      },
      +      "required": [
      +        "connection"
      +      ],
      +      "type": "object"
      +    },
      +    "type": "array"
      +  },
      +  {
      +    "additionalProperties": {},
      +    "properties": {
      +      "code": {
      +        "type": "string"
      +      },
      +      "details": {
      +        "additionalProperties": {},
      +        "propertyNames": {
      +          "type": "string"
      +        },
      +        "type": "object"
      +      },
      +      "error": {
      +        "type": "string"
      +      },
      +      "internal_code": {
      +        "type": "string"
      +      },
      +      "message": {
      +        "type": "string"
      +      },
      +      "retry_after_s": {
      +        "type": "number"
      +      },
      +      "retryable": {
      +        "type": "boolean"
      +      }
      +    },
      +    "required": [
      +      "error"
      +    ],
      +    "type": "object"
      +  }
      +]
    • changedOutput schema / properties / display / additionalProperties
      Previous value: -trueNew value: +{}
    • changedOutput schema / properties / display / properties / chart / additionalProperties
      Previous value: -trueNew value: +{}
    • changedOutput schema / properties / display / properties / code / additionalProperties
      Previous value: -trueNew value: +{}
    • changedOutput schema / properties / display / properties / map / additionalProperties
      Previous value: -trueNew value: +{}
    • changedOutput schema / properties / display / properties / metric / additionalProperties
      Previous value: -trueNew value: +{}
    • changedOutput schema / properties / insights / items / additionalProperties
      Previous value: -trueNew value: +{}
    • changedOutput schema / properties / meta / additionalProperties
      Previous value: -trueNew value: +{}
    • removedOutput schema / properties / meta / properties / executionTimeMs / $ref
      Removed value: -"#/properties/data/anyOf/0/items/properties/rows/anyOf/2"
    • addedOutput schema / properties / meta / properties / executionTimeMs / type
      Added value: +[
      +  "number",
      +  "string"
      +]
    • removedOutput schema / properties / meta / properties / rowCount / $ref
      Removed value: -"#/properties/data/anyOf/0/items/properties/rows/anyOf/2"
    • addedOutput schema / properties / meta / properties / rowCount / type
      Added value: +[
      +  "number",
      +  "string"
      +]
  2. Changed4 schema fields changed
    • changedOutput schema / properties / data / anyOf
      Previous value: -[
      -  {
      -    "items": {
      -      "additionalProperties": true,
      -      "properties": {
      -        "connection": {
      -          "type": "string"
      -        },
      -        "error": {
      -          "type": [
      -            "string",
      -            "null"
      -          ]
      -        },
      -        "execution_ms": {
      -          "$ref": "#/properties/data/anyOf/0/items/properties/rows/anyOf/2"
      -        },
      -        "rows": {
      -          "anyOf": [
      -            {
      -              "items": {
      -                "additionalProperties": {},
      -                "type": "object"
      -              },
      -              "type": "array"
      -            },
      -            {
      -              "type": "null"
      -            },
      -            {
      -              "type": [
      -                "number",
      -                "string"
      -              ]
      -            }
      -          ]
      -        },
      -        "sample": {
      -          "items": {
      -            "additionalProperties": {},
      -            "type": "object"
      -          },
      -          "type": "array"
      -        }
      -      },
      -      "required": [
      -        "connection"
      -      ],
      -      "type": "object"
      -    },
      -    "type": "array"
      -  },
      -  {
      -    "additionalProperties": true,
      -    "properties": {
      -      "code": {
      -        "type": "string"
      -      },
      -      "details": {
      -        "additionalProperties": {},
      -        "type": "object"
      -      },
      -      "error": {
      -        "type": "string"
      -      },
      -      "internal_code": {
      -        "type": "string"
      -      },
      -      "message": {
      -        "type": "string"
      -      },
      -      "retry_after_s": {
      -        "type": "number"
      -      }
      -    },
      -    "required": [
      -      "error"
      -    ],
      -    "type": "object"
      -  }
      -]New value: +[
      +  {
      +    "items": {
      +      "additionalProperties": true,
      +      "properties": {
      +        "connection": {
      +          "type": "string"
      +        },
      +        "error": {
      +          "type": [
      +            "string",
      +            "null"
      +          ]
      +        },
      +        "execution_ms": {
      +          "$ref": "#/properties/data/anyOf/0/items/properties/rows/anyOf/2"
      +        },
      +        "rows": {
      +          "anyOf": [
      +            {
      +              "items": {
      +                "additionalProperties": {},
      +                "type": "object"
      +              },
      +              "type": "array"
      +            },
      +            {
      +              "type": "null"
      +            },
      +            {
      +              "type": [
      +                "number",
      +                "string"
      +              ]
      +            }
      +          ]
      +        },
      +        "sample": {
      +          "items": {
      +            "additionalProperties": {},
      +            "type": "object"
      +          },
      +          "type": "array"
      +        }
      +      },
      +      "required": [
      +        "connection"
      +      ],
      +      "type": "object"
      +    },
      +    "type": "array"
      +  },
      +  {
      +    "additionalProperties": true,
      +    "properties": {
      +      "code": {
      +        "type": "string"
      +      },
      +      "details": {
      +        "additionalProperties": {},
      +        "type": "object"
      +      },
      +      "error": {
      +        "type": "string"
      +      },
      +      "internal_code": {
      +        "type": "string"
      +      },
      +      "message": {
      +        "type": "string"
      +      },
      +      "retry_after_s": {
      +        "type": "number"
      +      },
      +      "retryable": {
      +        "type": "boolean"
      +      }
      +    },
      +    "required": [
      +      "error"
      +    ],
      +    "type": "object"
      +  }
      +]
    • addedOutput schema / properties / meta / properties / maskedCells
      Added value: +{
      +  "type": "number"
      +}
    • addedOutput schema / properties / meta / properties / maskedColumns
      Added value: +{
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / meta / properties / rowCapReached
      Added value: +{
      +  "type": "boolean"
      +}
  3. Changed1 schema field changed
    • changedOutput schema / properties / data / anyOf
      Previous value: -[
      -  {
      -    "items": {
      -      "additionalProperties": true,
      -      "properties": {
      -        "connection": {
      -          "type": "string"
      -        },
      -        "error": {
      -          "type": [
      -            "string",
      -            "null"
      -          ]
      -        },
      -        "execution_ms": {
      -          "$ref": "#/properties/data/anyOf/0/items/properties/rows/anyOf/2"
      -        },
      -        "rows": {
      -          "anyOf": [
      -            {
      -              "items": {
      -                "additionalProperties": {},
      -                "type": "object"
      -              },
      -              "type": "array"
      -            },
      -            {
      -              "type": "null"
      -            },
      -            {
      -              "type": [
      -                "number",
      -                "string"
      -              ]
      -            }
      -          ]
      -        },
      -        "sample": {
      -          "items": {
      -            "additionalProperties": {},
      -            "type": "object"
      -          },
      -          "type": "array"
      -        }
      -      },
      -      "required": [
      -        "connection"
      -      ],
      -      "type": "object"
      -    },
      -    "type": "array"
      -  },
      -  {
      -    "additionalProperties": true,
      -    "properties": {
      -      "code": {
      -        "type": "string"
      -      },
      -      "details": {
      -        "additionalProperties": {},
      -        "type": "object"
      -      },
      -      "error": {
      -        "type": "string"
      -      },
      -      "internal_code": {
      -        "type": "string"
      -      },
      -      "message": {
      -        "type": "string"
      -      },
      -      "retry_after_s": {
      -        "type": "number"
      -      }
      -    },
      -    "type": "object"
      -  }
      -]New value: +[
      +  {
      +    "items": {
      +      "additionalProperties": true,
      +      "properties": {
      +        "connection": {
      +          "type": "string"
      +        },
      +        "error": {
      +          "type": [
      +            "string",
      +            "null"
      +          ]
      +        },
      +        "execution_ms": {
      +          "$ref": "#/properties/data/anyOf/0/items/properties/rows/anyOf/2"
      +        },
      +        "rows": {
      +          "anyOf": [
      +            {
      +              "items": {
      +                "additionalProperties": {},
      +                "type": "object"
      +              },
      +              "type": "array"
      +            },
      +            {
      +              "type": "null"
      +            },
      +            {
      +              "type": [
      +                "number",
      +                "string"
      +              ]
      +            }
      +          ]
      +        },
      +        "sample": {
      +          "items": {
      +            "additionalProperties": {},
      +            "type": "object"
      +          },
      +          "type": "array"
      +        }
      +      },
      +      "required": [
      +        "connection"
      +      ],
      +      "type": "object"
      +    },
      +    "type": "array"
      +  },
      +  {
      +    "additionalProperties": true,
      +    "properties": {
      +      "code": {
      +        "type": "string"
      +      },
      +      "details": {
      +        "additionalProperties": {},
      +        "type": "object"
      +      },
      +      "error": {
      +        "type": "string"
      +      },
      +      "internal_code": {
      +        "type": "string"
      +      },
      +      "message": {
      +        "type": "string"
      +      },
      +      "retry_after_s": {
      +        "type": "number"
      +      }
      +    },
      +    "required": [
      +      "error"
      +    ],
      +    "type": "object"
      +  }
      +]
  4. Changed2 schema fields changed
    • addedInput schema / properties / connections / items / maxLength
      Added value: +256
    • addedInput schema / properties / sql / maxLength
      Added value: +50000
  5. Changed2 schema fields changed
    • addedOutput schema / properties / display / properties / map
      Added value: +{
      +  "additionalProperties": true,
      +  "properties": {
      +    "label": {
      +      "type": "string"
      +    },
      +    "lat": {
      +      "type": "string"
      +    },
      +    "lon": {
      +      "type": "string"
      +    },
      +    "title": {
      +      "type": "string"
      +    }
      +  },
      +  "type": "object"
      +}
    • changedOutput schema / properties / display / properties / type / anyOf
      Previous value: -[
      -  {
      -    "enum": [
      -      "table",
      -      "chart",
      -      "metric",
      -      "code",
      -      "text",
      -      "list"
      -    ],
      -    "type": "string"
      -  },
      -  {
      -    "type": "string"
      -  }
      -]New value: +[
      +  {
      +    "enum": [
      +      "table",
      +      "chart",
      +      "metric",
      +      "code",
      +      "text",
      +      "list",
      +      "map"
      +    ],
      +    "type": "string"
      +  },
      +  {
      +    "type": "string"
      +  }
      +]
  6. Changed1 schema field changed
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "http://json-schema.org/draft-07/schema#",
      +  "additionalProperties": true,
      +  "properties": {
      +    "data": {
      +      "anyOf": [
      +        {
      +          "items": {
      +            "additionalProperties": true,
      +            "properties": {
      +              "connection": {
      +                "type": "string"
      +              },
      +              "error": {
      +                "type": [
      +                  "string",
      +                  "null"
      +                ]
      +              },
      +              "execution_ms": {
      +                "$ref": "#/properties/data/anyOf/0/items/properties/rows/anyOf/2"
      +              },
      +              "rows": {
      +                "anyOf": [
      +                  {
      +                    "items": {
      +                      "additionalProperties": {},
      +                      "type": "object"
      +                    },
      +                    "type": "array"
      +                  },
      +                  {
      +                    "type": "null"
      +                  },
      +                  {
      +                    "type": [
      +                      "number",
      +                      "string"
      +                    ]
      +                  }
      +                ]
      +              },
      +              "sample": {
      +                "items": {
      +                  "additionalProperties": {},
      +                  "type": "object"
      +                },
      +                "type": "array"
      +              }
      +            },
      +            "required": [
      +              "connection"
      +            ],
      +            "type": "object"
      +          },
      +          "type": "array"
      +        },
      +        {
      +          "additionalProperties": true,
      +          "properties": {
      +            "code": {
      +              "type": "string"
      +            },
      +            "details": {
      +              "additionalProperties": {},
      +              "type": "object"
      +            },
      +            "error": {
      +              "type": "string"
      +            },
      +            "internal_code": {
      +              "type": "string"
      +            },
      +            "message": {
      +              "type": "string"
      +            },
      +            "retry_after_s": {
      +              "type": "number"
      +            }
      +          },
      +          "type": "object"
      +        }
      +      ]
      +    },
      +    "display": {
      +      "additionalProperties": true,
      +      "properties": {
      +        "chart": {
      +          "additionalProperties": true,
      +          "properties": {
      +            "chartType": {
      +              "type": "string"
      +            },
      +            "color": {
      +              "type": "string"
      +            },
      +            "title": {
      +              "type": "string"
      +            },
      +            "x": {
      +              "type": "string"
      +            },
      +            "xLabel": {
      +              "type": "string"
      +            },
      +            "y": {
      +              "anyOf": [
      +                {
      +                  "type": "string"
      +                },
      +                {
      +                  "items": {
      +                    "type": "string"
      +                  },
      +                  "type": "array"
      +                }
      +              ]
      +            },
      +            "yLabel": {
      +              "type": "string"
      +            }
      +          },
      +          "type": "object"
      +        },
      +        "code": {
      +          "additionalProperties": true,
      +          "properties": {
      +            "executable": {
      +              "type": "boolean"
      +            },
      +            "language": {
      +              "anyOf": [
      +                {
      +                  "enum": [
      +                    "sql",
      +                    "json",
      +                    "bash",
      +                    "typescript"
      +                  ],
      +                  "type": "string"
      +                },
      +                {
      +                  "type": "string"
      +                }
      +              ]
      +            },
      +            "title": {
      +              "type": "string"
      +            }
      +          },
      +          "type": "object"
      +        },
      +        "metric": {
      +          "additionalProperties": true,
      +          "properties": {
      +            "label": {
      +              "type": "string"
      +            },
      +            "status": {
      +              "anyOf": [
      +                {
      +                  "enum": [
      +                    "good",
      +                    "warning",
      +                    "critical"
      +                  ],
      +                  "type": "string"
      +                },
      +                {
      +                  "type": "string"
      +                }
      +              ]
      +            },
      +            "trend": {
      +              "anyOf": [
      +                {
      +                  "enum": [
      +                    "up",
      +                    "down",
      +                    "neutral"
      +                  ],
      +                  "type": "string"
      +                },
      +                {
      +                  "type": "string"
      +                }
      +              ]
      +            },
      +            "trendValue": {
      +              "type": "string"
      +            },
      +            "unit": {
      +              "type": "string"
      +            },
      +            "value": {
      +              "type": [
      +                "string",
      +                "number"
      +              ]
      +            }
      +          },
      +          "type": "object"
      +        },
      +        "type": {
      +          "anyOf": [
      +            {
      +              "enum": [
      +                "table",
      +                "chart",
      +                "metric",
      +                "code",
      +                "text",
      +                "list"
      +              ],
      +              "type": "string"
      +            },
      +            {
      +              "type": "string"
      +            }
      +          ]
      +        }
      +      },
      +      "type": "object"
      +    },
      +    "insights": {
      +      "items": {
      +        "additionalProperties": true,
      +        "properties": {
      +          "column": {
      +            "type": "string"
      +          },
      +          "message": {
      +            "type": "string"
      +          },
      +          "severity": {
      +            "anyOf": [
      +              {
      +                "enum": [
      +                  "info",
      +                  "warning",
      +                  "critical"
      +                ],
      +                "type": "string"
      +              },
      +              {
      +                "type": "string"
      +              }
      +            ]
      +          },
      +          "value": {}
      +        },
      +        "required": [
      +          "severity",
      +          "message"
      +        ],
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "meta": {
      +      "additionalProperties": true,
      +      "properties": {
      +        "cacheHit": {
      +          "type": "boolean"
      +        },
      +        "connection": {
      +          "type": "string"
      +        },
      +        "dialect": {
      +          "anyOf": [
      +            {
      +              "enum": [
      +                "postgres",
      +                "mysql",
      +                "mssql"
      +              ],
      +              "type": "string"
      +            },
      +            {
      +              "type": "string"
      +            }
      +          ]
      +        },
      +        "executionTimeMs": {
      +          "$ref": "#/properties/data/anyOf/0/items/properties/rows/anyOf/2"
      +        },
      +        "plan": {},
      +        "rowCount": {
      +          "$ref": "#/properties/data/anyOf/0/items/properties/rows/anyOf/2"
      +        },
      +        "tool": {
      +          "type": "string"
      +        },
      +        "truncated": {
      +          "type": "boolean"
      +        }
      +      },
      +      "type": "object"
      +    },
      +    "summary": {
      +      "type": "string"
      +    }
      +  },
      +  "type": "object"
      +}
  7. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already declare read-only, idempotent, open-world, but the description adds genuinely non-derivable behavior: per-connection failure on unknown names, the 4-connection cap on every plan, per-connection rows and errors in the result, and dialect-specific failure modes (TOP vs LIMIT). That is exactly the operational context annotations cannot convey.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loads the highest-risk constraint (cross-dialect SQL validity) before use cases and caveats, which is the right ordering. It is dense but nearly every clause carries information; the only minor waste is restating dialect guidance already in the schema's sql description.

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

Completeness5/5

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

For a 2-param, read-only fan-out tool with an output schema present, the description covers invocation risk, prerequisites, limits, and result shape (per-connection rows + errors). Nothing an agent needs to call it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% so the baseline is 3, but the description adds real meaning: it stresses the SQL must be valid in every targeted dialect (with ANSI SELECT guidance) and clarifies connections must be NAMES, not IDs, with worked example arrays. It reinforces rather than merely repeats the schema.

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?

States a specific verb and resource with scope: 'Run the same query across 2-4 connections in parallel; returns per-connection rows + errors for diffing.' This clearly separates it from query_sql (single connection) and the fleet of schema/analysis siblings, which never fan a query out across connections.

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?

Gives concrete when-to-use scenarios (regional compare, cross-dialect sync check, 3-env drift, 4-region compare) and a prerequisite to resolve names via list_connections, plus a workaround for exceeding 4 connections. It stops short of explicitly naming query_sql as the alternative for single-connection reads, which is the main contrast an agent needs.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources