
Dbatools Mcp Server
- 4 repo stars
- Updated July 25, 2026
- dataplat/dbatools-mcp-server
io.github.dataplat/dbatools-mcp-server is an MCP server that exposes dbatools SQL Server management commands to AI coding agents over stdio.
About
io.github.dataplat/dbatools-mcp-server is a stdio MCP bridge that wraps the popular dbatools PowerShell module so Claude Code, Cursor, and similar agents can invoke SQL Server administration without you hand-rolling scripts each time. developers and small teams who already run SQL Server on Azure, on-prem, or containers can register the npm package, point the agent at pwsh, and ask for instance metadata, backup status, or diagnostic queries in natural language. Safe mode is on by default, which matches how most developers should start: exploration and reporting before any migration or change window. When you need controlled writes, you flip DBATOOLS_SAFE_MODE after reviewing what the agent will run. Row limits and per-command timeouts keep runaway tool loops from flooding context or hanging sessions. It is a task integration, not a full database design skill—pair it with your own migration checklists and testing before production changes.
- Exposes dbatools SQL Server management as MCP tools over stdio npm package dbatools-mcp-server v0.5.0
- DBATOOLS_SAFE_MODE defaults to true so write/destructive ops stay off until you explicitly set false
- Output caps via MAX_OUTPUT_ROWS (default 100, range 1–10000) and COMMAND_TIMEOUT_SECONDS (default 60, range 5–3600)
- Configurable PWSH_EXE for PowerShell execution on Windows or cross-platform pwsh
- GitHub source at dataplat/dbatools-mcp-server with dbatools.io branding assets
Dbatools Mcp Server by the numbers
- Data as of Jul 26, 2026 (Skillselion catalog sync)
claude mcp add --env DBATOOLS_SAFE_MODE=YOUR_DBATOOLS_SAFE_MODE --env MAX_OUTPUT_ROWS=YOUR_MAX_OUTPUT_ROWS --env COMMAND_TIMEOUT_SECONDS=YOUR_COMMAND_TIMEOUT_SECONDS --env PWSH_EXE=YOUR_PWSH_EXE dbatools-mcp-server -- npx -y dbatools-mcp-serverAdd your badge
Show developers this MCP server is listed on Skillselion. Paste this into your README.
| repo stars | ★ 4 |
|---|---|
| Package | dbatools-mcp-server |
| Transport | STDIO |
| Auth | None |
| Last updated | July 25, 2026 |
| Repository | dataplat/dbatools-mcp-server ↗ |
What it does
Let your coding agent run read-only (or gated) dbatools commands against SQL Server for health checks, inventory, and DBA tasks from the IDE.
Who is it for?
Best when you're on SQL Server and want agent-driven inventory and diagnostics with read-only defaults.
Skip if: Greenfield projects on Postgres-only stacks or anyone who refuses to install PowerShell and dbatools on the host.
What you get
After you register the server, your agent can run bounded, timeout-limited dbatools operations with safe mode controlling write access.
- MCP-callable dbatools command results capped by MAX_OUTPUT_ROWS
- Configurable read-only or write-enabled SQL Server operations via DBATOOLS_SAFE_MODE
- Timeout-bounded command execution per COMMAND_TIMEOUT_SECONDS
By the numbers
- Server schema version 0.5.0
- DBATOOLS_SAFE_MODE defaults to true (read-only safe mode)
- MAX_OUTPUT_ROWS defaults to 100 (allowed 1–10000)
README.md
dbatools-mcp-server
A Model Context Protocol (MCP) server for the dbatools PowerShell module.
Exposes dbatools commands as MCP tools so AI assistants (GitHub Copilot, Claude, etc.) can discover, explain, and execute dbatools commands directly — with all metadata sourced from dbatools' own comment-based help.
Features
list_dbatools_commands— search commands by verb, noun, keyword, or risk levelget_dbatools_command_help— full normalized help (synopsis, parameters, examples) fromGet-Help -Fullinvoke_dbatools_command— execute any dbatools command with safe parameter validation, risk gating, and structured JSON outputcheck_dbatools_environment— verify PowerShell + dbatools installation, index freshness, and version alignment- Version mismatch detection — warns when installed dbatools version differs from the indexed version
- Safe mode — non-readonly commands require explicit
confirm: trueto execute - SQL Authentication support — pass
SqlCredential: { username, password }for SQL auth instances
Prerequisites
- Node.js 20+
- PowerShell 7+ (
pwsh) - dbatools PowerShell module
Install-Module dbatools -Scope CurrentUser
Quick Start
# 1. Clone the repo
git clone https://github.com/Dataplat/dbatools-mcp-server.git
cd dbatools-mcp-server
# 2. Install Node dependencies
npm install
# 3. Generate the help index from your local dbatools installation
npm run refresh-help
# 4. Build
npm run build
Then open the folder in VS Code — the .vscode/mcp.json file automatically registers the MCP server.
Connecting to VS Code
The included .vscode/mcp.json registers the server as a local STDIO MCP server.
Open this folder in VS Code and the server will appear in the GitHub Copilot MCP panel.
{
"servers": {
"dbatools": {
"type": "stdio",
"command": "node",
"args": ["${workspaceFolder}/dist/server.js"],
"env": {
"DBATOOLS_SAFE_MODE": "true",
"MAX_OUTPUT_ROWS": "100",
"COMMAND_TIMEOUT_SECONDS": "60"
}
}
}
}
Configuration
All settings are controlled via environment variables (set in .vscode/mcp.json or your shell):
| Variable | Default | Description |
|---|---|---|
PWSH_EXE |
pwsh |
Path to PowerShell executable |
DBATOOLS_SAFE_MODE |
true |
When true, non-readonly commands require confirm: true |
MAX_OUTPUT_ROWS |
100 |
Maximum rows returned per command execution |
COMMAND_TIMEOUT_SECONDS |
60 |
Seconds before PowerShell process is killed |
Refreshing the Help Index
The help index (generated/dbatools-help.json) is generated from your locally installed dbatools module.
Re-run whenever dbatools is updated:
Update-Module dbatools -Scope CurrentUser
npm run refresh-help
The server detects version mismatches at runtime and warns you when the index is stale.
Risk Levels
Commands are automatically classified by verb:
| Risk Level | Verbs | Behavior |
|---|---|---|
readonly |
Get, Test, Find, Compare, … | Always allowed |
change |
Set, New, Add, Copy, Enable, … | Requires confirm: true in safe mode |
destructive |
Remove, Drop, Disable, Reset, … | Requires confirm: true in safe mode |
SQL Authentication
For SQL-auth-only instances (e.g. Docker), pass credentials via the SqlCredential parameter:
{
"SqlInstance": "localhost,1433",
"SqlCredential": { "username": "<SqlLogin>", "password": "YourPassword" }
}
Project Structure
dbatools-mcp-server/
├── src/
│ ├── server.ts # MCP server entry point, tool definitions
│ ├── powershell.ts # PowerShell process runner, health checks, version detection
│ ├── help-indexer.ts # Help manifest loader and command search
│ ├── tool-registry.ts # Risk classification, safe argument builder
│ └── types.ts # Shared TypeScript interfaces
├── scripts/
│ └── refresh-help.ps1 # Generates generated/dbatools-help.json
├── generated/ # Help index (gitignored, generated locally)
├── .vscode/
│ └── mcp.json # VS Code MCP local server registration
└── dist/ # Compiled output (gitignored)
Contributing
Contributions are welcome! Please open an issue first for significant changes.
This project follows the same community spirit as dbatools.
License
MIT — © 2026 DataPlat contributors
Recommended MCP Servers
How it compares
SQL Server MCP integration over dbatools, not a schema migration framework or ORM skill.
FAQ
Who is io.github.dataplat/dbatools-mcp-server for?
Developers and small ops-minded developers who manage SQL Server and want those workflows callable from Claude Code, Cursor, or Codex via MCP.
When should I use io.github.dataplat/dbatools-mcp-server?
Use it during Operate when you need agent-assisted instance checks, reporting, or approved maintenance commands instead of manual PowerShell sessions.
How do I add io.github.dataplat/dbatools-mcp-server to my agent?
Add the npm stdio server dbatools-mcp-server to your MCP config, set PWSH_EXE if needed, optionally tune DBATOOLS_SAFE_MODE and MAX_OUTPUT_ROWS, then restart the agent.