microsoft/microsoft-sql-admin
Diagnose and administer SQL Server, Azure SQL Database, Azure SQL Managed Instance, and Fabric SQL databases, including performance and wait analysis, Query Store and execution plans, blocking and deadlocks, backup and recovery, high availability and disaster recovery, security, schema health, and SQL Server Agent jobs.
Use when the user asks who is connected, which sessions are idle or hold the oldest open transaction, or how connections split by login or app. If a client can't connect, use connectivity-troubleshoot.
Use when the user asks which plaintext columns can or should use Always Encrypted, or why a column is disqualified. Eligibility only: not for listing already-encrypted columns or their keys.
Use when a login fails (18456, 'Login failed for user'), a user can't open a database, a permission is denied, or an Entra or managed identity login fails. For network errors, use connectivity-troubleshoot.
Use when the user asks for backup history, the latest backups or backup retention on Azure SQL Database or Fabric SQL Database. For SQL Server or Managed Instance, use backup-strategy-sqlserver.
Use when the user asks to review or design a SQL Server or Managed Instance backup strategy, or whether the recovery model and backup schedule meet an RPO. For Azure SQL Database, use backup-history-azuresql.
Use when the user asks what caused blocking that already ended (yesterday's incident, intermittent lock waits) or who is behind a supplied blocking chain. For blocking happening now, use check-live-blocking.
Use when queries hang right now: who is blocking, the head blocker, why a blocking DMV looks empty. Has tested queries and rules common answers miss, e.g. a sleeping head blocker is absent from sys.dm_exec_requests. For past blocking, use blocking-root-cause-analysis.
Use when the user asks to review, fix, explain or refactor T-SQL or a stored procedure without running it, incl. injection and SARGability. Has tested checks common answers miss, e.g. compile against the live schema with SET NOEXEC. For a cost-validated rewrite, use query-rewrite.
Use when a client can't connect or gets a connection error (timeout, 53/10060/10061, SQLSTATE 08001, TLS, firewall 'IP not allowed', 4060). For login or permission issues, use authentication-diagnostics.
Use when the user wants an Extended Events session to capture slow queries, deadlocks or blocking over hours or days, or an XE ring buffer stays empty. To explain a captured deadlock, use deadlock-analysis.
Use when the user asks to review an Azure SQL Database's configuration: service tier, service objective, compute tier, vCores, MAXDOP or connection string. For options like recovery model, use database-settings-review.
Use when the user asks to review a database's options: recovery model, AUTO_CLOSE, RCSI, compatibility level, Query Store, scoped configurations. For Azure SQL service tier, use database-config-azuresql.
Use when the user asks about deadlocks or deadlock history on SQL Server or Managed Instance, or to explain a supplied deadlock graph or XML. For Azure SQL Database, use deadlock-analysis-azuresql.
Use when the user asks about deadlocks, deadlock history or prevention on Azure SQL Database or Fabric SQL Database. For SQL Server, Managed Instance or a supplied deadlock XML, use deadlock-analysis.
Use when the user asks whether geo-replication or a failover group is healthy and ready for a planned failover (GO/NO_GO), or what the geo-DR RPO/RTO is. For lag happening now, use investigate-geo-dr-issues.
Use when the user wants a proactive Always On availability group health check before an audit, go-live or change: sync, listeners, failover readiness. For an active incident, use investigate-ha-issues.
Use when the user asks for a health audit of a SQL Server or Managed Instance (not Azure SQL Database): what is failing or risky now: availability, integrity, resources, storage, backups, HA, jobs, security.
Use when the user asks to optimize, tune, speed up or improve a specific SQL query ('make this faster'), with or without a plan; default when no technique is named. For a rewrite only, use query-rewrite.
Use when a geo-secondary lags behind the primary right now, a geo-replication link is suspended, or a failover group fails over unexpectedly. For a readiness check, use geo-dr-assessment-health-check.
Use when an availability group has sync or failover problems: replica suspended, NOT SYNCHRONIZING or RESOLVING, growing redo queue, lease timeout, failed seeding. For a readiness check, use ha-assessment-health-check.
Use when CPU is high on SQL Server or Azure SQL (alerts, throttling, SOS_SCHEDULER_YIELD waits) and the user wants the queries responsible. For a broad resource snapshot, use resource-usage-sqlserver.
Use when data-file reads are slow or heavy: PAGEIOLATCH waits, high read latency, many physical reads, Azure SQL data IO throttling. For WRITELOG or log latency, use investigate-sql-log-io-pressure.
Use when commits are slow or log writes lag: WRITELOG waits, high log write percent, log throughput throttling, too many VLFs. For PAGEIOLATCH or data-file reads, use investigate-sql-data-io-pressure.
Use when queries wait on memory grants (RESOURCE_SEMAPHORE), spill to tempdb, hit out-of-memory errors (701, 802, 8645), or PLE drops. For a broad resource snapshot, use resource-usage-sqlserver.
Use when row estimates are far from actual rows, statistics may be stale, or the user asks which to update or if auto-update keeps up. Has tested queries and rules common answers miss, e.g. the sqrt threshold needs compat level 130+. For missing indexes, use missing-index-analysis.
Use when the user asks about ledger tables: whether ledger fits a tamper-evidence need, creating updatable or append-only ones, or listing them and their history. SQL Server 2022+ and Azure SQL Database.
Use when the user asks which indexes are missing, whether a table needs one, or whether index suggestions are worth creating. Has tested queries and rules common answers miss, e.g. rank suggestions by seeks x cost x impact. Not for Synapse dedicated pools.
Use when the user asks about partitioned tables: skew or hot partitions, boundaries or missing future partitions, per-partition fragmentation, index alignment, or partition elimination.
Use when the user supplies an execution plan (showplan XML, .sqlplan) or asks to explain or check one: costly operators, spills, misestimates. Has tested rules common answers miss, e.g. subtree costs are inclusive. For end-to-end tuning, use improve-query-performance.
Use when the user asks about plan cache bloat, single-use or ad hoc plans, poor plan reuse, SET option pollution or parameter sniffing suspects. For one query's plans, use plan-cache-qds-bridge.
Use when the user needs one query's cached plan and Query Store history, by text, query_hash, query_id or plan handle, including a query gone from cache. For cache-wide bloat, use plan-cache-analysis.
Use when the user wants to try query hints on a slow SELECT: compare join, parallelism or cardinality estimation hints by estimated cost or measured runtime. For a hint-free rewrite, use query-rewrite.
Use when the user explicitly asks to rewrite or restructure a SQL query or predicate, e.g. make a WHERE clause SARGable, keeping results and NULL semantics. For 'make this faster', use improve-query-performance.
Use when the user asks for top or regressed queries in Query Store: what got slower since a deploy versus a baseline, or which earlier plan to force. When Query Store is off, use top-queries-noqds.
Use when queries have erratic durations in Query Store, the user wants one query_id's timeline, or suspects parameter sniffing or failing forced plans. For baseline regressions, use query-store-investigation.
Use when many queries time out under load, or SQL Server or Azure SQL is slow overall and it's unclear whether CPU, memory, IO, TempDB or disk is the cause. For one slow query, use slow-query-investigation.
Use when the user asks to design or review tables or a proposed schema: keys, constraints, normalization, computed columns, full-text, DDL validation. For heaps or disabled indexes, use table-health-check.
Use when one specific query got slow, changed plans, or swings from seconds to minutes with the same parameters. Has tested queries and rules common answers miss, e.g. Query Store averages need execution weighting. For many slow queries, use resource-usage-sqlserver.
Use only when the user asks for estate-wide migration readiness across many Azure Arc SQL Server instances: dashboards, totals, coverage. For one instance or generic results, use sql-admin-get-migration-assessment.
Use when the user wants to run, rerun or refresh an Azure Arc SQL Server migration assessment for fresh readiness and SKU results. To read existing results, use sql-admin-get-migration-assessment.
Use when the user asks about existing Azure Arc SQL Server migration assessment results (readiness, SKUs, costs), including supplied JSON. For a new run, use sql-admin-evaluate-azure-migration-assessment.
Use when a SQL Server Agent job failed, was canceled, keeps retrying, is stuck running or missed its schedule, and the user wants the failing step and error. SQL Server and Managed Instance only.
Use when the SQL Tools MCP server from the microsoft-sql-admin plugin must be set up, enabled, connected or repaired: no mssql_* tools listed, no connections, CONNECTION_STRING or the .NET SDK and dnx missing, or a skill reports no SQL tool. Asks before changing anything; not for diagnostics.
Use when the user asks which tables are most read, written or scanned, which are unused, or whether anything still touches a table. Has tested queries and rules common answers miss, e.g. index rebuilds no longer reset usage counters. For table health, use table-health-check.
Use when the user asks about table corruption, consistency errors, suspect pages, repair, or structural issues: heaps, no primary key, disabled or fragmented indexes. For table activity, use table-access-analysis.
Use when the user wants top CPU or most expensive queries, or queries with several cached plans, and Query Store is off or unavailable (DMVs only). With Query Store on, use query-store-investigation.
Use when the user asks why queries are slow in terms of waits: which wait categories (lock, CPU, IO, memory, network) dominate now or recently. Requires Query Store with wait stats capture.