Skip to main content
Glama
mssql-dba-mcp

mssql-dba-mcp

by shadow-dba

mssql-dba-mcp is an MCP server. It gives Claude Code, Claude Desktop, Cursor, VS Code and other MCP clients 42 tools to look at a SQL Server the way a DBA does: health checks, wait stats, slow queries and their plans, blocking, indexes, backups, CHECKDB, Agent jobs, the error log, configuration, security and schema design.

It only looks. The AI can suggest a fix (an index, a setting, a script), but you decide whether to run it.

Quick start

You need Node.js 20.12 or later and a SQL Server 2016+, Azure SQL Managed Instance or Azure SQL Database.

1. Create a read-only login. Run the setup script as a sysadmin. The server refuses to start with sa or any other admin login.

2. Add the server to your MCP client. Claude Code:

claude mcp add mssql-dba \
  -e DB_AUTH_TYPE=sql -e DB_HOST=localhost -e DB_NAME=master \
  -e DB_USER=shadow-dba -e DB_PASSWORD='YourStrongPasswordHere' \
  -- npx -y @shadow-dba/mssql-dba-mcp

Other clients (Claude Desktop, Cursor, VS Code) use the same command in their JSON config:

{
  "mcpServers": {
    "mssql-dba": {
      "command": "npx",
      "args": ["-y", "@shadow-dba/mssql-dba-mcp"],
      "env": {
        "DB_AUTH_TYPE": "sql",
        "DB_HOST": "localhost",
        "DB_NAME": "master",
        "DB_USER": "shadow-dba",
        "DB_PASSWORD": "YourStrongPasswordHere"
      }
    }
  }
}

To keep the password out of the client config, leave out env and put the same values in a .env file in the folder the client starts the server from (see .env.example). The server reads ./.env itself.

3. Ask. For example: "Run a health check on this server", "Why is the server slow right now?" or "Which indexes on dbo.Posts in StackOverflow are never used?"

Want ready-made DBA skills (health check, plan analysis, index review) on top of these tools? Use the shadow-dba CLI: npx shadow-dba workspace init sets up a Claude Code workspace with this server and the skills.

Related MCP server: Microsoft SQL Server MCP Server

Safety: read-only in three layers

  1. A read-only login, checked at startup. The setup script grants only VIEW permissions and SELECT on a few msdb tables; nothing that can write, and nothing that reads rows from your own tables. At startup the server checks the login and refuses to run if it is a member of sysadmin, has CONTROL SERVER, or is db_owner in DB_NAME. This is the real guarantee: SQL Server itself blocks every change, whatever the AI sends.

  2. Tools that only read. 41 of the 42 tools run fixed SQL written in this repo. They read system views and DMVs. They never run DBCC CHECKDB, never run the query behind a plan, and never change a setting.

  3. A strict check on the AI's own SQL. mssql_run_select runs a query the AI writes. A lexer checks it first: exactly one statement, it must start with SELECT or WITH, and any word that writes, runs code or changes the session (INSERT, UPDATE, EXEC, SET, USE, SELECT INTO, DBCC, BACKUP, ...) rejects it. Strings, quoted names and comments cannot hide code. This matters because tool output contains text other people control (query text from the plan cache, error-log lines, object names), and a prompt injection in that text could ask the AI to send a crafted query.

Layer 3 is a second line of defense, not the guarantee. If you run with a privileged login (MSSQL_ALLOW_PRIVILEGED_LOGIN=true), a bypass of layer 3 could change your data. Found a bypass? See SECURITY.md.

What the AI can see: metadata (names of databases, tables, columns, indexes, logins, jobs), server settings, query text in the plan cache and running requests (it can contain literal values), error-log lines and Agent job messages. By default it cannot read rows from your own tables, and it cannot see job step commands in msdb, which can hold passwords. Giving it table data is a separate decision with real consequences: see Business data.

Tools

Every tool is read-only. Output is Markdown, capped at 200 rows per table and 40,000 characters per reply, with a "Showing N of M" note when something was cut. Database tools take an optional databaseName (default: DB_NAME).

Start here

Tool

What it returns

mssql_server_version

Version, edition, patch level, collation, HADR, licensing. First call in a health check.

mssql_wait_stats

Top wait types. sampleSeconds=5 shows what the server waits on right now.

mssql_top_queries

Top queries by CPU, reads, memory grant, spills, duration or executions, with plan handles.

mssql_run_select

One read-only SELECT the AI writes (system views, DMVs). Max 500 rows.

Performance, now

Tool

What it returns

mssql_execution_plan

Cached plan XML for a plan handle (never runs the query).

mssql_running_requests

Active requests: CPU, reads, waits, blocking, statement.

mssql_blocking

Blocked sessions and who blocks them.

mssql_memory_pressure

Page Life Expectancy.

mssql_buffer_hit_ratio

Buffer cache hit ratio.

mssql_disk_io_latency

Read/write latency per database file, rated.

mssql_tempdb_health

TempDB files, space use, top sessions.

Instance health

Tool

What it returns

mssql_server_timezone

Server time, UTC offset.

mssql_storage_capacity

Drives with less than 10% free space.

mssql_server_config

sp_configure settings with risky values flagged.

mssql_error_log

SQL Server or Agent error log, filtered, newest first.

mssql_all_db_info

Every database: state, recovery model, compatibility, size.

mssql_offline_db

Databases that are not ONLINE.

mssql_db_config_health

Risky database settings (auto shrink, page verify, Query Store, ...).

mssql_db_owners

Databases not owned by sa, orphaned owners.

mssql_recent_backups

Latest Full, Diff and Log backup per database.

mssql_checkdb_status

Last good CHECKDB per database, suspect pages.

mssql_vlf_counts

Databases with too many virtual log files.

mssql_autogrowth_issues

Files with percent, tiny or disabled autogrowth.

mssql_agent_jobs

SQL Agent jobs, schedules, last run.

mssql_agent_failed_jobs

Agent jobs that failed in the last 7 days.

mssql_agent_alerts

Alerts for errors 823/824/825 and severities 19-25, operators.

mssql_privileged_logins

Members of sysadmin and securityadmin.

One database

Tool

What it returns

mssql_db_info

State, recovery model, compatibility, size.

mssql_db_collation

Default collation.

mssql_db_collation_mismatches

Columns with a different collation.

mssql_db_tables

Every table: rows, size, keys, index health, workload.

mssql_db_index_health

Every index: usage, fragmentation, fill factor, maintenance script.

mssql_db_missing_indexes

Missing-index suggestions, ranked.

mssql_db_backup_history

Backups of the last 7 days.

mssql_db_table_keys

Heaps, tables without a primary key.

mssql_db_foreign_keys

Untrusted, disabled or unindexed foreign keys, likely missing ones.

mssql_db_check_constraints

Untrusted or disabled check constraints, with the fix.

mssql_db_identity_headroom

Identity columns close to their type limit.

mssql_db_column_design_issues

Deprecated and risky column types, too-wide rows.

mssql_table_info

Details for the given tables (tableNames).

mssql_table_index_health

Index health for the given tables.

mssql_table_missing_indexes

Missing indexes for the given tables.

Permissions

Run one of these scripts as a sysadmin. Each creates the login and grants what the tools need. Permissions are server-wide: database tools can look at any database, including ones created later. The scripts can run again: an existing login or user is kept (with its password) and only the grants are applied.

SQL Server login (DB_AUTH_TYPE=sql)

USE [master];
GO
IF SUSER_ID(N'shadow-dba') IS NULL
  CREATE LOGIN [shadow-dba] WITH PASSWORD = 'YourStrongPasswordHere';
GO
GRANT VIEW SERVER STATE    TO [shadow-dba];
GRANT VIEW ANY DEFINITION  TO [shadow-dba];
GRANT CONNECT ANY DATABASE TO [shadow-dba];
-- Error log access. SQL Server 2022+ and Managed Instance have a permission for it;
-- 2016-2019 need EXECUTE on the procedure that reads the log (it only reads).
IF CAST(SERVERPROPERTY('ProductMajorVersion') AS INT) >= 16
   OR SERVERPROPERTY('EngineEdition') = 8
  EXEC (N'GRANT VIEW ANY ERROR LOG TO [shadow-dba];');
ELSE
BEGIN
  IF USER_ID(N'shadow-dba') IS NULL
    EXEC (N'CREATE USER [shadow-dba] FOR LOGIN [shadow-dba];');
  EXEC (N'GRANT EXECUTE ON xp_readerrorlog TO [shadow-dba];');
END;
GO

-- msdb: SELECT on exactly the tables the tools read. No Agent roles: SQLAgentReaderRole
-- can create and change jobs.
USE [msdb];
GO
IF USER_ID(N'shadow-dba') IS NULL
  CREATE USER [shadow-dba] FOR LOGIN [shadow-dba];
GO
GRANT SELECT ON dbo.backupset         TO [shadow-dba];
GRANT SELECT ON dbo.backupmediafamily TO [shadow-dba];
GRANT SELECT ON dbo.suspect_pages     TO [shadow-dba];
GRANT SELECT ON dbo.sysjobs           TO [shadow-dba];
GRANT SELECT ON dbo.sysjobhistory     TO [shadow-dba];
GRANT SELECT ON dbo.sysjobschedules   TO [shadow-dba];
GRANT SELECT ON dbo.sysschedules      TO [shadow-dba];
GRANT SELECT ON dbo.sysalerts         TO [shadow-dba];
GRANT SELECT ON dbo.sysoperators      TO [shadow-dba];
GRANT EXECUTE ON dbo.agent_datetime   TO [shadow-dba];
-- Job step commands can hold passwords. Not granted; the DENY keeps them hidden even if
-- someone later adds a wider grant such as SELECT ALL USER SECURABLES.
DENY SELECT ON dbo.sysjobsteps        TO [shadow-dba];
GO

Then set DB_USER=shadow-dba and DB_PASSWORD=YourStrongPasswordHere.

Windows login (DB_AUTH_TYPE=windows)

Same script with CREATE LOGIN [DOMAIN\shadow-dba] FROM WINDOWS; instead of the CREATE LOGIN line, and [DOMAIN\shadow-dba] instead of [shadow-dba] everywhere (MACHINE\shadow-dba for a local account). Set DB_USER and DB_PASSWORD to that account's name and password (NTLM cannot reuse your logged-in session), and DB_DOMAIN for a domain account.

Azure SQL Database

There are no server permissions and no msdb. Run this in the database you set as DB_NAME (a contained user, so use DB_AUTH_TYPE=sql):

IF USER_ID(N'shadow-dba') IS NULL
  CREATE USER [shadow-dba] WITH PASSWORD = 'YourStrongPasswordHere';
GRANT VIEW DATABASE STATE TO [shadow-dba];
GRANT VIEW DEFINITION     TO [shadow-dba];

What each permission is for

Permission

Used for

VIEW SERVER STATE

Instance DMVs: waits, requests, memory, blocking, I/O, plan cache, VLFs.

VIEW ANY DEFINITION

Schema and index metadata in every database; the full member list for mssql_privileged_logins.

CONNECT ANY DATABASE

Enter every database (current and future) without a user in each one.

VIEW ANY ERROR LOG

mssql_error_log (SQL Server 2022+ and Managed Instance).

EXECUTE on xp_readerrorlog (master)

mssql_error_log on SQL Server 2016-2019. The procedure only reads the log files.

msdb DENY SELECT on sysjobsteps

Hides Agent job step commands, which can hold passwords, even if a wider grant is added later.

msdb SELECT on 9 tables

Backups and suspect pages (backupset, backupmediafamily, suspect_pages), Agent jobs (sysjobs, sysjobhistory, sysjobschedules, sysschedules), alerts (sysalerts, sysoperators).

msdb EXECUTE on agent_datetime

Converts Agent run dates and times. A plain function that reads nothing; the same login works for the shadow-dba agent.

None of these can change data, schema or settings, and none of them reads rows from your own tables.

Limits (on purpose)

Lifting these would need permissions that are not read-only, or that expose your data, so the scripts do not grant them.

  • mssql_checkdb_status on builds older than SQL Server 2016 SP2 / 2017 CU9 can only read the date from the database header (DBCC DBINFO, needs sysadmin or db_owner). Those databases show UNKNOWN.

  • mssql_run_select cannot read rows from your tables. System views and DMVs are enough for most DBA work, and this keeps business data away from the AI. To allow it for a specific task, read Business data first.

  • Azure SQL Database sees only the database in DB_NAME. Instance tools (Agent, backups, error log, CHECKDB, logins) say they are not available there.

Business data (optional, read before you grant)

The setup script does not let the AI read rows from your tables. mssql_run_select can query system views and DMVs, which is enough for most DBA work. Sometimes a DBA needs the data itself: the values behind a slow query, a skewed column, a count of rows that match a filter. You can grant that, but it is a decision about your data, not about this tool, and it is not reversible for data the AI has already seen.

What happens when you grant it

  • Every row the AI selects leaves SQL Server and goes to the model as tool output. Depending on your MCP client and AI provider, it may be sent to a third party, stored in chat history and logs, and kept under that provider's retention terms. Check those terms before you grant anything.

  • The AI chooses which tables to query. Tool output contains text other people control (query text, object names, error-log lines). A prompt injection in that text can ask the AI to read and repeat sensitive rows. The read-only guarantee stops changes; it does not stop reading.

  • Tables often hold more than you remember: personal data, health and payment data, credentials, API keys, salaries, legal documents. A server-wide grant covers all of them, in every database, including databases created later.

Privacy and legal. Personal data in your tables is regulated (GDPR, UK GDPR, CCPA/CPRA, HIPAA, PCI DSS, and local laws). Sending it to an AI provider is a disclosure to a processor: you may need a data processing agreement with that provider, a lawful basis, an updated record of processing, a data protection impact assessment, and the approval of your data protection officer or legal team. Customer and vendor contracts can forbid it outright. If you cannot say who can see the data after it leaves SQL Server, do not grant this. You are responsible for that check; this project cannot make it for you.

If you decide to grant it

  1. Prefer the smallest grant: one table or schema, in one database, over a server-wide grant.

  2. Prefer a masked or anonymised copy, a non-production environment, or a view that hides sensitive columns. Dynamic Data Masking and Row-Level Security still apply to this login (it has no UNMASK), but only if you set them up.

  3. Grant it for one task and revoke it when the task is done. Do not leave it in place.

  4. Turn on SQL Server Audit for the login so you know what was read.

  5. Tell the people whose data it is, if your policies or the law require it.

Smallest grant (one table or schema, one database):

USE [YourDatabase];
IF USER_ID(N'shadow-dba') IS NULL
  CREATE USER [shadow-dba] FOR LOGIN [shadow-dba];
GRANT SELECT ON dbo.Posts TO [shadow-dba];          -- one table
-- GRANT SELECT ON SCHEMA::dbo TO [shadow-dba];     -- or one schema

Widest grant (every user table and view, in every database, now and in the future; SQL Server 2014+ and Managed Instance):

USE [master];
GRANT SELECT ALL USER SECURABLES TO [shadow-dba];

Azure SQL Database (one database, every table and view):

ALTER ROLE db_datareader ADD MEMBER [shadow-dba];

Revoke with the same statement and REVOKE instead of GRANT (ALTER ROLE db_datareader DROP MEMBER on Azure SQL Database). The login is still read-only with any of these grants: it cannot change a row. Job step commands in msdb (sysjobsteps) stay hidden; the setup script denies them because they can hold passwords.

Other optional grants

Not part of the setup script. Each one is still read-only, but each one also exposes data, so the warnings above apply. Grant it for one task and revoke it after.

Grant

What it allows

GRANT VIEW SERVER SECURITY AUDIT TO [shadow-dba]; (master, SQL Server 2022+ / Managed Instance)

Read SQL Server Audit files with sys.fn_get_audit_file and the audit specifications. Audit records contain the statements users ran, with literal values. On 2016-2019 this needs CONTROL SERVER, which is not read-only: do not grant it.

In one database: CREATE USER [shadow-dba] FOR LOGIN [shadow-dba]; GRANT SELECT ON SCHEMA::cdc TO [shadow-dba];

Read Change Data Capture tables in that database (who changed which rows, and when). These tables hold copies of the changed rows. SELECT ALL USER SECURABLES does not cover them.

Revoke with the same statement and REVOKE instead of GRANT.

Configuration

Variable

Default

Description

DB_AUTH_TYPE

(required)

sql or windows (NTLM).

DB_HOST

(required)

Server name or IP.

DB_NAME

(required)

Database to connect to. Database tools default to it.

DB_USER

(required)

Login name.

DB_PASSWORD

(required)

Login password.

DB_PORT

1433

Server port.

DB_DOMAIN

Windows auth with a domain account only.

ENCRYPT

true

Encrypt the connection. false only if the server has no TLS.

TRUST_SERVER_CERTIFICATE

false

true accepts a self-signed certificate. Only on a trusted network.

REQUEST_TIMEOUT

30000

Query timeout in ms.

MAX_POOL / MIN_POOL / IDLE

10 / 0 / 30000

Connection pool size and idle timeout (ms).

MSSQL_ALLOW_PRIVILEGED_LOGIN

false

true lets the server run with a sysadmin, CONTROL SERVER or db_owner login, with a warning. Not recommended.

Values come from the MCP client's env block, or from ./.env in the server's working directory. The client's values win.

Development

npm install
npm test          # unit tests, no database needed
npm run build     # compiles to build/
npm run smoke     # calls every tool once against the server in .env (after build)
                  # and checks the bypass payloads are rejected

See CONTRIBUTING.md. Report security problems privately, as described in SECURITY.md.

License

MIT © shadow-dba

Available Tools

42 tools
mssql_agent_alertsGet SQL Agent Alerts HealthA
Read-onlyIdempotent

SQL Agent alerts: checks alerts for corruption errors 823/824/825 and severities 19-25 and whether an enabled operator gets them, and lists all alerts and operators. Missing corruption alerts become CRITICAL when msdb.dbo.suspect_pages has rows. Not available on Azure SQL Database.

Inputs: no named parameters.

mssql_agent_failed_jobsGet Failed SQL Agent JobsA
Read-onlyIdempotent

SQL Agent failed jobs: jobs that failed in the last 7 days, with date, time and error message. Not available on Azure SQL Database.

Inputs: no named parameters.

mssql_agent_jobsGet SQL Agent Scheduled JobsA
Read-onlyIdempotent

SQL Agent jobs: every job with its schedule, frequency, interval and last run status. Not available on Azure SQL Database.

Inputs: no named parameters.

mssql_all_db_infoGet All Databases InfoB
Read-onlyIdempotent

All databases on the instance: state, recovery model, compatibility level, data and log size, read-only, auto close, auto shrink, page verify, create date.

Inputs: no named parameters.

mssql_autogrowth_issuesGet File Autogrowth IssuesA
Read-onlyIdempotent

Autogrowth issues: data and log files with percent growth, tiny growth (1 MB or less) or autogrowth off, largest files first. Not available on Azure SQL Database.

Inputs: no named parameters.

mssql_blockingGet Current Blocking and LockingA
Read-onlyIdempotent

Blocking and locking now: blocked sessions with the blocking session, wait type, wait time and query text. An empty result means no blocking.

Inputs: no named parameters.

mssql_buffer_hit_ratioGet Buffer Cache Hit RatioB
Read-onlyIdempotent

Buffer cache hit ratio (%). Below 95% suggests too little memory for the workload.

Inputs: no named parameters.

mssql_checkdb_statusGet DBCC CHECKDB StatusA
Read-onlyIdempotent

CHECKDB and corruption: the last known good DBCC CHECKDB date per online database (flags never, or more than 7 days ago) and the rows in msdb.dbo.suspect_pages (corruption already found). Never runs CHECKDB. Databases the login cannot read show UNKNOWN. Not available on Azure SQL Database.

Inputs: no named parameters.

mssql_db_backup_historyGet DB Backup HistoryA
Read-onlyIdempotent

Backup history of one database in the last 7 days: type, start and finish, duration, size, compressed size and file location. Not available on Azure SQL Database.

Inputs: databaseName.

mssql_db_check_constraintsGet DB Check Constraint HealthA
Read-onlyIdempotent

Check constraints that are untrusted or disabled, with the ALTER TABLE ... WITH CHECK CHECK CONSTRAINT fix. The optimizer ignores untrusted constraints, and they may hide invalid rows. For foreign keys use mssql_db_foreign_keys.

Inputs: databaseName.

mssql_db_collationGet Database CollationA
Read-onlyIdempotent

Database collation: the default collation of one database. Use with mssql_db_collation_mismatches for collation conflict errors.

Inputs: databaseName.

mssql_db_collation_mismatchesGet Collation MismatchesA
Read-onlyIdempotent

Collation mismatches: columns (dbo schema) whose collation differs from the database default. A common cause of collation conflict errors in joins with temp tables.

Inputs: databaseName.

mssql_db_column_design_issuesGet DB Column Design IssuesB
Read-onlyIdempotent

Column design issues: deprecated types (text, ntext, image), risky types (datetime, float, real, sql_variant) with a suggested type, and tables whose maximum row width is over 6000 bytes (near the 8060-byte row limit).

Inputs: databaseName.

mssql_db_config_healthGet Databases Config HealthA
Read-onlyIdempotent

Database settings health for every online user database: compatibility level, recovery model, page verify, auto close, auto shrink, auto statistics, target recovery time and Query Store, with Flags for risky values. onlyFlagged=true (default) returns only flagged databases.

Inputs: onlyFlagged.

mssql_db_foreign_keysGet DB Foreign KeysA
Read-onlyIdempotent

Foreign keys review for one database: each foreign key with trusted, disabled, indexed (unindexed foreign keys slow joins and deletes) and column type or collation mismatches, plus the WITH CHECK CHECK CONSTRAINT fix; and likely missing foreign keys found by column name (for example Votes.PostId -> Posts.Id). Name matching is a guess, so confirm each one.

Inputs: onlyIssues, databaseName.

mssql_db_identity_headroomGet DB Identity HeadroomA
Read-onlyIdempotent

Identity headroom: identity columns with the % of their type range already used (tinyint to bigint, decimal), most used first. WARN at 50%, RISK at 80%: when an identity runs out, every insert fails.

Inputs: topN, databaseName, minPercentUsed.

mssql_db_index_healthGet Index HealthA
Read-onlyIdempotent

Index health for one database: every non-PK index with key and included columns, usage (never used, write-only), fragmentation, fill factor advice, size and a suggested DROP, REBUILD or REORGANIZE script to review. Reads index physical stats (LIMITED), which can be slow on very large databases; use mssql_table_index_health for a few tables.

Inputs: databaseName.

mssql_db_infoGet Database InfoA
Read-onlyIdempotent

Database info for one database: state, recovery model, compatibility level, data and log size, read-only, auto close, auto shrink, page verify, create date.

Inputs: databaseName.

mssql_db_missing_indexesGet Missing IndexesA
Read-onlyIdempotent

Missing indexes for one database, from the missing-index DMVs, ranked by improvement score: urgency, improvement %, uses, equality, inequality and included columns. Only tables with 1000+ rows and real query volume.

Inputs: databaseName.

mssql_db_ownersGet Database OwnersA
Read-onlyIdempotent

Database owners: user databases not owned by sa (SID 0x01, so a renamed sa still counts), including orphaned owners whose login no longer exists. Not available on Azure SQL Database.

Inputs: no named parameters.

mssql_db_table_keysGet DB Table KeysA
Read-onlyIdempotent

Table keys: every user table with row count, heap or clustered index, primary key and other unique indexes. Flags heaps, tables without a primary key, and tables where only the primary key is unique. onlyFlagged=true (default) returns only flagged tables.

Inputs: onlyFlagged, databaseName.

mssql_db_tablesGet All Tables InfoA
Read-onlyIdempotent

Tables overview for one database: every table with row count, size, primary key, index counts (unused, fragmented, missing), index health, read/write workload and access pattern, largest first. Reads index physical stats (LIMITED), which can be slow on very large databases; use mssql_table_info for a few tables.

Inputs: databaseName.

mssql_disk_io_latencyGet Disk I/O LatencyA
Read-onlyIdempotent

Disk I/O latency per database file: reads, writes, average read and write stall (ms) and a rating from Exceptional to Critical. Use to find slow storage.

Inputs: no named parameters.

mssql_error_logRead SQL Server Error LogA
Read-onlyIdempotent

Error log: read the SQL Server ERRORLOG (or SQL Server Agent log) via sp_readerrorlog. Optionally filter to lines containing one or two search strings (e.g. "Backup", "3013") and select an archived log file. Returns newest entries first. Needs VIEW ANY ERROR LOG (SQL Server 2022+ / Managed Instance) or securityadmin. Not available on Azure SQL Database.

Inputs: logType, maxRows, search1, search2, +1 more.

mssql_execution_planGet Execution PlanA
Read-onlyIdempotent

Execution plan (showplan XML) of a cached query, by plan handle. Reads the plan cache only; never runs the query. Get the Plan Handle from mssql_top_queries. Large plans are cut at 35,000 characters.

Inputs: queryPlanHandle (required).

mssql_memory_pressureGet Memory PressureA
Read-onlyIdempotent

Memory pressure: Page Life Expectancy (PLE) from the Buffer Manager. PLE below 300 signals memory pressure; below 1000 on modern servers is worth a look.

Inputs: no named parameters.

mssql_offline_dbGet Offline DatabasesA
Read-onlyIdempotent

Offline databases: databases that are not ONLINE (OFFLINE, RESTORING, RECOVERING, SUSPECT, EMERGENCY). Any row needs attention.

Inputs: no named parameters.

mssql_privileged_loginsGet Privileged LoginsA
Read-onlyIdempotent

Security: members of the sysadmin and securityadmin server roles, each marked Expected (in expectedAccounts), Built-in (sa, NT SERVICE*, NT AUTHORITY\SYSTEM, ##...##) or REVIEW. Needs VIEW ANY DEFINITION to see all members. Not available on Azure SQL Database.

Inputs: expectedAccounts.

mssql_recent_backupsGet Most Recent BackupsA
Read-onlyIdempotent

Backups: the most recent Full, Differential and Log backup per database in the last 30 days. Databases with no backup show NULL dates. For one database's history use mssql_db_backup_history. Not available on Azure SQL Database.

Inputs: no named parameters.

mssql_running_requestsGet Running RequestsA
Read-onlyIdempotent

Running requests now: active user sessions with status, command, CPU, reads, elapsed time, wait type, blocking session, open transactions and the current statement. includeSleeping=true also lists idle sessions that hold an open transaction. For blocked sessions only, use mssql_blocking.

Inputs: includeSleeping.

mssql_run_selectRun SELECT QueryA
Read-onlyIdempotent

Run one read-only SELECT (or WITH ... SELECT) query: ad-hoc analysis of system views and DMVs when no other tool fits. One statement only; INSERT, UPDATE, EXEC, SET, USE, SELECT INTO and anything else that writes or changes the session are rejected. Use databaseName instead of USE to run in another database. Returns at most 500 rows; add TOP, WHERE or GROUP BY to narrow.

Inputs: selectQuery (required), databaseName.

mssql_server_configGet Server ConfigurationA
Read-onlyIdempotent

Server configuration (sp_configure, sys.configurations) with a Flag for risky values: max server memory not capped, cost threshold for parallelism at 5, MAXDOP 0, priority boost, optimize for ad hoc workloads off, xp_cmdshell on, and more. onlyFlagged=true (default) returns only flagged settings.

Inputs: onlyFlagged.

mssql_server_timezoneGet Server TimezoneA
Read-onlyIdempotent

Server time and timezone: local time, UTC time and UTC offset. Use for time-related job, backup or replication problems.

Inputs: no named parameters.

mssql_server_versionGet Server VersionA
Read-onlyIdempotent

Server version, edition, patch level (CU), collation, clustering/HADR and licensing. Call first in any health check.

Inputs: no named parameters.

mssql_storage_capacityGet Storage CapacityA
Read-onlyIdempotent

Disk space: drives with less than 10% free space. Any row is a warning. Include in every health check. Not available on Azure SQL Database.

Inputs: no named parameters.

mssql_table_index_healthGet Tables Index HealthB
Read-onlyIdempotent

Index health for the given tables: fragmentation, usage, fill factor advice and a suggested maintenance script.

Inputs: tableNames (required), databaseName.

mssql_table_infoGet Tables InfoB
Read-onlyIdempotent

Table details for the given tables: row count, size, primary key type, index counts, read/write workload, access pattern and volatility.

Inputs: tableNames (required), databaseName.

mssql_table_missing_indexesGet Tables Missing IndexesB
Read-onlyIdempotent

Missing indexes for the given tables, ranked by improvement score.

Inputs: tableNames (required), databaseName.

mssql_tempdb_healthGet TempDB HealthA
Read-onlyIdempotent

TempDB health: file layout (count, equal sizes, autogrowth), space use (user objects, internal objects, version store, free space) and the top 10 sessions using tempdb. Flags too few data files, unequal sizes and percent autogrowth.

Inputs: no named parameters.

mssql_top_queriesGet Top Resource QueriesA
Read-onlyIdempotent

Top queries by CPU, logical reads, memory grant, spills, duration or executions, from the plan cache (sys.dm_exec_query_stats), with statement text and the Plan Handle for mssql_execution_plan. topN default 25, max 100.

Inputs: topN, sortBy.

mssql_vlf_countsGet VLF CountsA
Read-onlyIdempotent

VLF count: databases whose transaction log has more virtual log files than minVlfCount (default 1000), worst first. Many VLFs slow recovery, restores and log backups. Needs SQL Server 2016 SP2 or later.

Inputs: minVlfCount.

mssql_wait_statsGet Wait StatisticsA
Read-onlyIdempotent

Wait statistics: the top wait types (what the server waits on: CPU, I/O, locks, memory), each as % of all waits, with average wait and signal (CPU) %. Idle waits are excluded. sampleSeconds=0 (default): since the last restart. sampleSeconds=5: only waits during a 5-second sample, the "what is slow right now" view.

Inputs: topN, minWaitMs, sampleSeconds.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 42 tools

    Disambiguation4/5

    Nearly all 42 tools target distinct diagnostic areas, and descriptions explicitly differentiate scope (e.g., database-wide vs table-specific). However, several scope-variant pairs (mssql_db_tables/mssql_table_info, mssql_db_index_health/mssql_table_index_health, mssql_db_missing_indexes/mssql_table_missing_indexes) could be confused if descriptions are skimmed.

    Naming Consistency5/5

    All tools use the mssql_ prefix with snake_case and descriptive noun phrases, following a highly predictable domain_topic pattern. No mixing of conventions or vague names.

    Tool Count2/5

    42 tools is well above the 25+ threshold for 'too many' in this rubric. While each tool addresses a distinct check, many are scope variants that could be consolidated into parameterized tools to reduce agent load.

    Completeness4/5

    Coverage of core DBA diagnostics—storage, memory, waits, queries, blocking, backups, CHECKDB, VLF, agent, security, database config, and index/table design—is extensive. Minor gaps remain for replication, availability group/mirroring health, and deadlock analysis.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides read-only access to Microsoft SQL Server databases using Windows Authentication, enabling AI assistants to safely explore schemas and query data with built-in security controls.
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to connect and query Microsoft SQL Server databases using natural language, executing read-only SQL queries for safe data inspection and analysis.
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to inspect schemas, analyze performance, check security, and troubleshoot SQL Server 2019+ databases through a safe, controlled interface.
      -