MCP server exposing SQL Server database tools for schema inspection, query execution, validation, and performance analysis
SqlToAi demonstrates solid tool design with 17 well-named, verb-prefixed tools covering SQL discovery, schema inspection, query execution, and performance analysis. All tools have descriptions (avg ~150 chars) and explicit input schemas with typed parameters. However, output schemas are not documented in the visible code, parameter descriptions vary in completeness, and error handling guidance is minimal. Tool composition is strong, each tool has a single responsibility and names clearly distinguish similar operations (e.g., sql_get_schema vs sql_get_schema_foreign_keys). Security is well-handled with read-only operations and transaction controls. The main gaps are missing output schema documentation and limited error recovery guidance.
Benchmarks two query versions to measure optimization impact: compares results, measures performance of both, and returns detailed metrics including execution time deltas and improvement percentages.
Compares two SQL queries side-by-side: validates both, executes them, and returns a detailed comparison report including row counts, execution times, and sample differences.
Executes a local .sql file with multi-batch support and returns a structured Markdown report with transaction mode, metrics, results, and diagnostics.
Executes a single read-only SELECT statement inside a rollback transaction and returns the results as JSON lines, followed by an "Execution Info: X rows returned in Y ms | cpu: Z ms | logical reads: W." line (server-side cpu_time_ms/logical_reads via SET STATISTICS IO/TIME, measured on every call, no parameter needed; Y is the client round-trip of the query itself). String columns are anonymized when the database access level requires it.
Returns all objects that reference or are referenced by the specified table or view.
Returns all parameters (name, type, direction) of a stored procedure or function.
Output schemas not documented. Tool descriptions state what is returned (e.g., 'Markdown document', 'JSON lines', 'comparison report') but the actual field structure, types, and pagination behavior are not formally specified in visible code. LLMs cannot reliably extract fields or plan downstream tool calls without documented output schemas.
Error handling lacks recovery guidance. Tool descriptions do not explain what errors can occur, how to interpret them, or what the LLM should do next (retry, ask user, try alternative tool). E.g., sql_execute_query may fail on invalid SQL, permission denied, or timeout, but no guidance is provided.
| Scored | Grade | Overall | Spec posture | Rubric |
|---|---|---|---|---|
| 2026-09-23 | D | 55 | 2026-07-28+ | v2 |
Returns the primary schema of a table, view, procedure, or function as a Markdown document, enriched with metadata descriptions.
Returns all Default and Check constraints including their definition texts for a table.
Returns all inbound and outbound foreign keys for a table as a Markdown table.
Returns all indexes (PK, Unique, Non-Clustered) including key and included columns for a table.
Returns the full CREATE TRIGGER DDL definition of a DML trigger.
Lists all databases on the SQL Server that are permitted by the server's whitelist configuration.
Measures query performance by executing it multiple times with warmup runs, capturing execution time, CPU time, logical reads, and optionally analyzing the execution plan.
Filters the list of allowed databases by a partial search term.
Searches for database objects (tables, views, procedures, triggers) by name using LIKE.
Analyzes a query's execution plan and suggests indexes that could improve performance, including index key columns and included columns.
Validates SQL syntax and object references via PARSEONLY without executing the query.
Parameter descriptions for 'parameters' object lack detail. Tools like sql_execute_query accept an optional 'parameters' dict with typed SQL parameters, but the description does not explain the expected structure (e.g., {"CustomerId": 42} vs {"val": {"value": "123", "dbType": "AnsiString"}}). LLMs may struggle to construct valid parameter objects.
No pagination or result-limit documentation for discovery tools. sql_search_objects accepts max_results, but sql_list_databases and sql_search_databases do not. If these return large result sets, context window exhaustion is possible. Descriptions should state default and maximum limits.
Tool annotations (readOnlyHint, destructiveHint, idempotentHint) not visible in code. While most tools are read-only and sql_execute_file is destructive, these hints are not explicitly declared in the McpServerToolCreateOptions. Explicit annotations improve agent safety and planning.