Skip to main content
Glama
PiyapatRag

MS SQL Server MCP Server

by PiyapatRag

mssql_query

Read-onlyIdempotent

Execute read-only SQL queries on Microsoft SQL Server, supporting SELECT, temp table batches, and whitelisted stored procedures. Returns data as JSON or Markdown.

Instructions

Execute a read-only SQL query against the MS SQL Server database. Accepts: a single SELECT / WITH...SELECT; a multi-statement batch led by DECLARE, INSERT, or CREATE TABLE # that writes ONLY to session-local #temp tables or @table variables (global ##temp is never allowed); or EXEC of a whitelisted stored procedure whose definition does not write to a persistent table. Writes to real tables, DDL on persistent objects, dynamic SQL, EXEC inside batches, and DBCC are blocked (server runs with MSSQL_READ_ONLY=true). Returns results as JSON or Markdown.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe SQL to execute. Must be read-only: a SELECT/WITH query, a DECLARE batch using only #temp/@table targets, or EXEC of an allowed read-only stored procedure.
offsetNoRow offset for pagination (default: 0)
maxRowsNoMaximum number of rows to return per page (default: 100, max: 1000)
response_formatNoResponse format: 'json' for machine-readable, 'markdown' for human-readable (default: json)json
Behavior5/5

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

The description adds substantial behavioral context beyond annotations (readOnlyHint, idempotentHint, destructiveHint), explaining allowed query patterns, blocked operations, server configuration (MSSQL_READ_ONLY=true), and response formats. No contradiction with annotations.

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?

The description is a single dense paragraph that front-loads the main purpose. It is informative but could be more concise by splitting into bullet points or shortening examples. Nonetheless, every sentence adds value.

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 complexity of SQL execution and no output schema, the description covers allowed queries, blocked operations, and response formats. It lacks details on error handling or pagination behavior, which would improve completeness.

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?

With 100% schema coverage, the baseline is 3. The description reinforces the query parameter's allowed forms, adding detail beyond the schema's brief description. However, it does not add new semantics for offset, maxRows, or response_format beyond what the schema provides.

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?

The description clearly states the tool executes a read-only SQL query against MS SQL Server, and distinguishes it from sibling tools by specifying exact allowed query types (SELECT, WITH...SELECT, temp-table batches, whitelisted procs) and blocked operations (writes, DDL, dynamic SQL).

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 explicitly details when to use (read-only queries) and when not (writes, DDL, dynamic SQL, DBCC), providing clear constraints. It implicitly guides the agent to select this tool for read queries versus sibling tools for schema or analysis.

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/PiyapatRag/mssql-mcp-server'

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