Skip to main content
Glama

mssql_run_query

Executes T-SQL queries against an active connection and returns compact CSV or JSON; in default read-only mode, write, DDL, and EXEC statements are blocked.

Instructions

Executes a T-SQL query against an active connectionId and returns compact CSV (default) or JSON. In --readonly mode (default), write/DDL/EXEC statements are blocked.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "connectionId": "<connectionId>",
      "query": "<query>"
    },
    "name": "mssql_run_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
queryYesThe T-SQL query to execute.
formatNoOutput format: 'csv' (default) or 'json'.csv
queryTypesNoOptional query classification (e.g. SELECT, DDL, DML).
queryIntentNoBrief intent description for audit logging.
connectionIdYesThe connectionId returned by mssql_connect.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4/5.0
Behavior4/5

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

Beyond the bare readOnlyHint=false annotation, the description discloses that readonly is the default mode and that write/DDL/EXEC statements are blocked there, plus the default return format. It stops short of explaining what happens on a blocked statement (error vs. silent) or whether a non-readonly path exists. No contradiction: readOnlyHint=false is consistent with a tool that can write when readonly mode is off.

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?

Two tight sentences with the action and default output first, then the safety constraint. No filler or restated field names.

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?

For a 5-param query executor with no output schema, this covers the essentials: how to connect, what comes back, and the default write restriction. It leaves out error behavior when a write is blocked, result-size limits, and how to turn off readonly mode.

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 coverage is 100%, so all five parameters are already documented in the input schema. The description adds only mild context (connectionId must come from an active connection, format is CSV/JSON) and says nothing extra about queryTypes or queryIntent beyond the schema's own audit-logging note.

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 ("Executes a T-SQL query") plus the scope (requires an active connectionId) and the return shape (CSV by default, JSON optionally). This clearly separates it from the mssql_list_*/mssql_connect siblings, which enumerate metadata or manage connections rather than run queries.

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

Usage Guidelines3/5

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

Usage is only implied: "against an active connectionId" hints that mssql_connect must run first, and the readonly note implies writes will fail by default. It never explicitly says when to use this tool versus the list_* siblings or how to disable readonly mode to run DDL/DML.

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