SqlAugur

io.github.mbentham由 GitHub 帳號 mbentham 發布v1.3.1更新於 Oct 24, 2026

MCP server providing AI assistants with safe, read-only SQL Server access

概覽

AI 產生的概覽

本機 MCP 伺服器,讓 AI 助理以唯讀、經 AST 驗證的方式存取 SQL Server 資料庫,用於查詢、結構探索與 DBA 診斷。

可以做什麼
  • 列出已設定的伺服器及其資料庫,執行唯讀 SELECT/CTE 查詢,結果以 JSON 內嵌回傳或寫入 CSV 檔案
  • 檢視資料庫結構:Markdown 結構概覽、資料表詳細說明、可程式化物件、定義、擴充屬性與相依性圖
  • 產生 PlantUML 與 Mermaid ER 圖並存成檔案
  • 分析預估或實際的 XML 執行計畫
  • 可選擇透過 First Responder Kit、DarlingData 與 sp_WhoIsActive 預存程序執行 DBA 診斷,並自動精簡回應大小
  • 開啟漸進式探索後,可依需求探索並啟用額外工具集
適用情境
適合需要讓助理依據 SQL Server 資料回答問題、探索不熟悉的資料庫結構、產生 ER 圖,或在不授予寫入權限的前提下協助 DBA 檢視健康檢查、封鎖與計畫快取診斷的情境。
執行需求
以 .NET 10 工具形式透過 stdio 在本機執行(dotnet tool 安裝、dnx、Docker/Podman 映像或原始碼建置)。需要在 appsettings.json 設定具名 SQL Server 連線字串,放在使用者設定目錄、工作目錄、DLL 旁,或透過環境變數、Azure Key Vault 提供。DBA 工具集要求目標伺服器已安裝對應預存程序並開啟相應 Enable 旗標。
安裝前請注意
appsettings.json 或環境變數中的連線字串屬於憑證,建議使用 Windows 驗證或受控識別,並避免提交到版本庫。跨資料庫查詢依設計被允許,真正的界線是登入帳號的權限。回傳的資料可能含有針對助理的提示注入。DBA 工具集會在伺服器上執行預存程序,安全性取決於參數封鎖。結果檔案會寫入本機結果目錄,並在保留期後刪除。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 SqlAugur,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

SqlAugur

[NuGet] [NuGet Downloads] [License: MIT] [.NET 10.0]

[圖片]

An MCP server that gives AI assistants safe, read-only access to SQL Server databases. Every query is parsed into a full AST using Microsoft's official T-SQL parser — not regex — so comment injection, string literal tricks, and encoding bypasses are blocked at the syntax level.

┌──────────────┐          ┌───────────────────────────────────────────┐        ┌──────────────┐│              │  stdio   │  SqlAugur                                 │        │              ││  AI Client   │◄────────►│                                           │───────►│  SQL Server  ││              │          │  ┌────────────┐  ┌──────────────────────┐ │        │              │└──────────────┘          │  │  Query     │  │  Schema / Diagram /  │ │        └──────────────┘                          │  │  Validator │  │  DBA Services        │ │                          │  └────────────┘  └──────────────────────┘ │                          │  ┌────────────────────────────────────┐   │                          │  │  Rate Limiter                      │   │                          │  └────────────────────────────────────┘   │                          └───────────────────────────────────────────┘

Quick Start

Use this order for all install methods:

  1. Install SqlAugur
  2. Save appsettings.json in the correct location
  3. Add SqlAugur to your MCP client config
  4. Verify by asking your assistant to call list_servers

Start with Installation for exact commands and file paths.

Why This Approach

  • AST-level query validation — Most MCP database servers use keyword blocking or no validation at all. This project parses every query into a full syntax tree using Microsoft's official TSql180Parser. Comment injection, string literal tricks, and encoding bypasses are blocked at the syntax level, not with fragile regex patterns.

  • Rate limiting — Token bucket throughput limiting and concurrency control prevent runaway AI query loops from overwhelming production SQL Servers. No other MCP database server offers this.

  • DBA diagnostic tooling — Integrated support for First Responder Kit, DarlingData, and sp_WhoIsActive with parameter blocking that prevents write operations. This is an entirely new MCP capability category.

  • Response size optimisation — DBA tools exclude verbose columns (XML query plans, deadlock graphs, metric breakdowns) and truncate long strings by default, reducing response sizes by 90–99%. Use verbose and includeQueryPlans parameters to get full untruncated output when needed.

  • Progressive discovery — Up to 31 tools organized into toolsets that load on demand. Only 6 core tools are exposed initially, keeping the AI's context window small and reducing token usage. Additional toolsets are discovered and enabled as needed.

Features

Security

  • Read-only by design — only SELECT and CTE queries are permitted
  • AST-based query validation using ScriptDom (not regex)
  • Parameter blocking on all diagnostic stored procedures to prevent writes
  • Concurrency and throughput rate limiting

Database Tooling

  • Multi-server support — named connections to multiple SQL Server instances
  • Schema overview — concise Markdown schema maps with PKs, FKs, constraints, and defaults
  • Table documentation — Markdown descriptions of columns, indexes, foreign keys, and constraints
  • ER diagram generation — PlantUML and Mermaid diagrams with smart cardinality detection
  • Schema exploration — list programmable objects, view definitions, extended properties, dependency graphs
  • Query plan analysis — estimated or actual XML execution plans
  • DBA diagnostics — optional integration with First Responder Kit, DarlingData, and sp_WhoIsActive with automatic response size optimisation
  • Progressive discovery — dynamic toolset mode reduces initial context window usage by exposing tools on demand

Installation

All methods produce the same MCP server. Follow this order: install, save config, wire client, verify.

NuGet Global Tool (recommended)

1. Install (prerequisite: .NET 10.0 runtime)

bash
dotnet tool install -g SqlAugur

2. Save config file

bash
# Linux/macOSmkdir -p ~/.config/sqlaugur# Edit ~/.config/sqlaugur/appsettings.json with your server connections
# Windows (PowerShell)mkdir "$env:APPDATA\sqlaugur" -Force# Edit %APPDATA%\sqlaugur\appsettings.json with your server connections

Example appsettings.json to save at that location:

json
{  "SqlAugur": {    "Servers": {      "production": {        "ConnectionString": "Server=myserver;Database=master;Integrated Security=True;TrustServerCertificate=False;Encrypt=True;"      }    }  }}

3. Add to MCP client

json
{  "mcpServers": {    "sqlaugur": {      "command": "sqlaugur"    }  }}

To update: dotnet tool update -g SqlAugur

Docker / Podman

1. Run SqlAugur container

bash
# Volume-mount a config filedocker run -i --rm \  -v /path/to/appsettings.json:/app/appsettings.json:ro,Z \  ghcr.io/mbentham/sqlaugur:latest
# Or use environment variables (no config file needed)docker run -i --rm \  -e SqlAugur__Servers__production__ConnectionString="Server=host.docker.internal;Database=master;..." \  ghcr.io/mbentham/sqlaugur:latest

Note: To reach a SQL Server on the host machine, use host.docker.internal (Docker Desktop) or --network=host (Linux). Replace docker with podman — all commands are identical. The :Z flag on volume mounts is required for SELinux-enabled systems (Fedora, RHEL); Docker Desktop users on macOS/Windows can omit it.

If you mount a config file, save it as /path/to/appsettings.json and mount it to /app/appsettings.json.

2. Add to MCP client

json
{  "mcpServers": {    "sqlaugur": {      "command": "docker",      "args": ["run", "-i", "--rm",        "-v", "/path/to/appsettings.json:/app/appsettings.json:ro,Z",        "ghcr.io/mbentham/sqlaugur:latest"]    }  }}
Docker Compose
yaml
services:  sqlaugur:    image: ghcr.io/mbentham/sqlaugur:latest    stdin_open: true    volumes:      - ./appsettings.json:/app/appsettings.json:ro,Z

MCP client configuration:

json
{  "mcpServers": {    "sqlaugur": {      "command": "docker",      "args": ["compose", "run", "-i", "--rm", "sqlaugur"]    }  }}

Build from Source

1. Build (prerequisite: .NET 10.0 SDK)

bash
git clone [email protected]:mbentham/SqlAugur.gitcd SqlAugurdotnet publish SqlAugur -c Release -o SqlAugur/publish

2. Save config file

bash
# Linux/macOScp SqlAugur/appsettings.example.json SqlAugur/publish/appsettings.json# Edit SqlAugur/publish/appsettings.json with your server connections
# Windows (PowerShell)Copy-Item SqlAugur\appsettings.example.json SqlAugur\publish\appsettings.json# Edit SqlAugur\publish\appsettings.json with your server connections

3. Add to MCP client

json
{  "mcpServers": {    "sqlaugur": {      "command": "dotnet",      "args": ["/absolute/path/to/SqlAugur/publish/SqlAugur.dll"]    }  }}

Verify the MCP connection (LLM-first)

After restarting your MCP client, ask the assistant:

  • Call list_servers
  • Call list_databases for server "production"

Expected result:

  • list_servers returns your configured server name (for example production)
  • list_databases returns a JSON array of databases, not a connection or authentication error

If verification fails:

  1. Confirm MCP config runs the expected command (sqlaugur, docker run ..., or dotnet /path/to/SqlAugur.dll)
  2. Confirm appsettings.json is saved where your install method expects it:
    • Local tool: ~/.config/sqlaugur/appsettings.json (Linux/macOS) or %APPDATA%\sqlaugur\appsettings.json (Windows)
    • Container: mounted to /app/appsettings.json
    • Source build: next to the published DLL (SqlAugur/publish/appsettings.json)
  3. Confirm the tool call uses a configured server key (for example production)
  4. Confirm SQL connectivity and authentication in the connection string

Configuration

The server loads configuration from multiple sources. Higher-priority sources override lower ones:

  1. Command-line arguments
  2. Environment variables — using __ as section delimiter (e.g., SqlAugur__Servers__production__ConnectionString=...)
  3. Current working directory — appsettings.json in the directory you run the command from
  4. User config directory — ~/.config/sqlaugur/appsettings.json on Linux, %APPDATA%\sqlaugur\appsettings.json on Windows
  5. Azure Key Vault — when AzureKeyVaultUri is set (see below)
  6. App directory — appsettings.json next to the DLL

Example configuration (Windows Authentication — recommended):

json
{  "SqlAugur": {    "Servers": {      "production": {        "ConnectionString": "Server=myserver;Database=master;Integrated Security=True;TrustServerCertificate=False;Encrypt=True;"      }    },    "MaxRows": 1000,    "CommandTimeoutSeconds": 30,    "MaxConcurrentQueries": 5,    "MaxQueriesPerMinute": 60,    "EnableFirstResponderKit": false,    "EnableDarlingData": false,    "EnableWhoIsActive": false,    "EnableDynamicToolsets": false  }}
OptionDefaultDescription
Servers—Named SQL Server connections (name → connection string). Connections identify themselves to SQL Server as SqlAugur (program_name, Extended Events client_app_name) unless the connection string sets its own Application Name.
MaxRows1000Maximum rows returned per query, inline or in a result file
ResultFileThresholdRows500read_data results over this many rows (or about 40,000 characters) are written to a CSV file instead of returned inline, avoiding oversized stdio messages. 0 disables.
ResultsDirectorysqlaugur/results under the user's local application data folder (%LOCALAPPDATA%\sqlaugur\results on Windows)Where result files are written. Must be an absolute path.
ResultFileRetentionDays7Result files older than this are deleted at startup
CommandTimeoutSeconds30SQL command timeout for all queries and procedures
MaxConcurrentQueries5Maximum number of SQL queries that can execute concurrently
MaxQueriesPerMinute60Maximum queries allowed per minute (token bucket rate limit)
EnableFirstResponderKitfalseEnable First Responder Kit diagnostic tools (sp_Blitz, sp_BlitzFirst, sp_BlitzCache, sp_BlitzIndex, sp_BlitzWho, sp_BlitzLock, sp_BlitzPlanCompare)
EnableDarlingDatafalseEnable DarlingData diagnostic tools (sp_PressureDetector, sp_QuickieStore, sp_QuickieCache, sp_HealthParser, sp_LogHunter, sp_HumanEventsBlockViewer, sp_IndexCleanup, sp_QueryReproBuilder)
EnableWhoIsActivefalseEnable sp_WhoIsActive session monitoring
EnableDynamicToolsetsfalseEnable progressive tool discovery — DBA tools load on demand via 3 meta-tools instead of at startup. Reduces initial context window usage. The Enable* flags still control which toolsets are allowed.
AzureKeyVaultUri—Azure Key Vault URI (e.g., https://myvault.vault.azure.net/). When set, secrets from the vault are added as a configuration source using DefaultAzureCredential. Key Vault secret names use -- as a section separator (e.g., a secret named SqlAugur--Servers--prod--ConnectionString maps to SqlAugur:Servers:prod:ConnectionString).

Security Note: appsettings.json is gitignored to prevent accidental credential commits. See SECURITY.md for recommended authentication methods including Windows Authentication, Azure Managed Identity, and secure credential storage options.

Tools

The server provides 31 tools organized into toolsets. Six core tools are always available. Additional toolsets are loaded at startup (static mode) or on demand (dynamic mode).

Core Tools

ToolDescription
list_serversLists available SQL Server instances configured in appsettings.json.
list_databasesLists all databases on a named server with names, IDs, states, and creation dates.
read_dataExecutes a read-only SQL SELECT query. Only SELECT and WITH (CTE) queries are allowed. Small results are returned as JSON; large ones go to a CSV file, returning its path, row count, columns and a 10-row preview. Pass toFile: true to always get a file.
get_query_planReturns the estimated or actual XML execution plan for a SELECT query.
get_schema_overviewConcise Markdown schema overview: tables, columns, PKs, FKs, unique/check constraints, defaults. Supports compact mode, schema and table filtering.
describe_tableComprehensive table metadata in Markdown: columns, data types, nullability, defaults, identity, computed expressions, indexes, FKs, constraints.
Schema Exploration (4 tools)
ToolDescription
list_programmable_objectsLists views, stored procedures, functions, and triggers. Filterable by type and schema.
get_object_definitionReturns the source definition (CREATE statement) of a programmable object.
get_extended_propertiesReads extended properties (descriptions, metadata) on tables, columns, and other objects.
get_object_dependenciesShows what an object references and what references it — upstream and downstream dependency graphs.
Diagrams (2 tools)
ToolDescription
get_plantuml_diagramGenerates a PlantUML ER diagram with tables, columns, PKs, and FK relationships. Saves to a .puml file. Supports compact mode, schema/table filtering, and a configurable table limit (max 200).
get_mermaid_diagramGenerates a Mermaid ER diagram with tables, columns, PKs, and FK relationships. Saves to a .mmd file. Supports compact mode, schema/table filtering, and a configurable table limit (max 200).

DBA Diagnostic Tools

Each toolkit is enabled independently via config flags and requires the corresponding stored procedures installed on the target SQL Server.

All DBA tools apply response size optimisation by default — XML query plan columns are excluded and long string values are truncated to keep responses within AI context window limits. Every tool supports these optional parameters:

ParameterDescription
verboseReturn all columns with no truncation.
includeQueryPlansInclude XML execution plan columns in the output.
maxRowsMaximum rows to return per result set. Available on tools with variable-length output: BlitzIndex, BlitzLock, HealthParser, LogHunter (default 200), IndexCleanup, QueryReproBuilder.

Some tools have additional parameters: includeXmlReports (BlitzLock, HealthParser, HumanEventsBlockViewer), compact (sp_WhoIsActive), verboseMetrics (QuickieStore).

First Responder Kit (7 tools) — requires EnableFirstResponderKit: true

Install from: github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit

ToolDescription
sp_blitzOverall SQL Server health check — prioritized findings for performance, configuration, and security.
sp_blitz_firstReal-time performance diagnostics — samples DMVs over an interval for waits, file latency, and perfmon counters.
sp_blitz_cachePlan cache analysis — top queries by CPU, reads, duration, executions, or memory grants.
sp_blitz_indexIndex analysis — missing, unused, and duplicate indexes with usage patterns.
sp_blitz_whoActive query monitor — what's running, blocking info, tempdb usage, query plans.
sp_blitz_lockDeadlock analysis from the system_health extended event session.
sp_blitz_plan_compareCross-server query plan comparison — captures a plan snapshot on one server and compares it to the cached plan on a second server without using linked servers. Requires the demon_hunters branch until merged to main.
DarlingData (8 tools) — requires EnableDarlingData: true

Install from: github.com/erikdarling/DarlingData

ToolDescription
sp_pressure_detectorDiagnoses CPU and memory pressure — resource bottlenecks, high-CPU queries, memory grants, disk latency.
sp_quickie_storeQuery Store analysis — top resource-consuming queries, plan regressions, wait statistics.
sp_quickie_cachePlan cache analysis — high-impact queries ranked by impact score over the dm_exec_*_stats DMVs (the plan-cache companion to sp_quickie_store).
sp_health_parserParses the system_health extended event session for historical waits, disk latency, CPU, memory, and locking.
sp_log_hunterSearches SQL Server error logs for errors, warnings, and custom messages.
sp_human_events_block_viewerAnalyzes blocking events from sp_HumanEvents sessions — blocking chains, lock details, waits.
sp_index_cleanupFinds unused and duplicate indexes that are candidates for removal.
sp_query_repro_builderGenerates reproduction scripts for Query Store queries with parameter values.
sp_WhoIsActive (1 tool) — requires EnableWhoIsActive: true

Install from: whoisactive.com

ToolDescription
sp_whoisactiveMonitors active sessions and queries — wait info, blocking details, tempdb usage, resource consumption.

Progressive Discovery

When EnableDynamicToolsets is true, only core tools load at startup. Three meta-tools let the AI discover and enable additional toolsets on demand, reducing initial context window usage:

ToolDescription
list_toolsetsLists available toolsets with status (available, enabled, not configured) and tool counts.
get_toolset_toolsReturns detailed tool and parameter info for a specific toolset before enabling it.
enable_toolsetEnables a toolset, making its tools available. Only works if the admin has enabled the toolset via the corresponding Enable* config flag.

Example flow:

  1. AI calls list_toolsets — sees first_responder_kit is "available" (configured but not yet enabled)
  2. AI calls get_toolset_tools("first_responder_kit") — reviews the 7 tools and their parameters
  3. AI calls enable_toolset("first_responder_kit") — the 7 tools are now registered and usable
  4. AI calls sp_blitz — runs the health check as normal

In static mode (EnableDynamicToolsets: false), all enabled toolsets load at startup and the discovery tools are not registered. Schema Exploration and Diagrams toolsets are always loaded regardless of mode.

Known limitation: Progressive discovery relies on the MCP notifications/tools/list_changed notification to inform clients that new tools have been registered. Claude Code does not currently handle this notification (anthropics/claude-code#4118), so dynamically enabled toolsets will not appear. Use static mode (EnableDynamicToolsets: false) when using Claude Code.

Security

Query Validation

Every query is parsed into an Abstract Syntax Tree (AST) using Microsoft's official TSql180Parser and must pass these rules:

  • Single statement only — multiple statements are rejected
  • SELECT only — INSERT, UPDATE, DELETE, DROP, EXEC, CREATE, ALTER, and all other statement types are blocked
  • No SELECT INTO — prevents table creation via SELECT
  • No external data access — OPENROWSET (all variants including BULK, Cosmos DB, and internal), OPENQUERY, OPENDATASOURCE, OPENXML blocked
  • No linked servers — four-part name references are rejected
  • No MAXRECURSION hint — prevents overriding the default recursion limit
  • Cross-database queries are allowed — three-part names work by design; the security boundary is the server, not the database. To restrict to a single database, limit the login's permissions.

Because validation operates on the parsed AST, it correctly handles edge cases that defeat string-based approaches: keywords inside comments, string literals, nested block comments, and encoding tricks.

Parameter Blocking

Diagnostic stored procedures execute via whitelisted procedure names with blocked parameters that prevent writes:

  • First Responder Kit — all @Output* parameters blocked (prevents writing results to server tables)
  • DarlingData — logging and output parameters blocked (prevents table creation and data retention)
  • sp_WhoIsActive — @destination_table, @return_schema, @schema, @help blocked

Rate Limiting

All tool executions are subject to concurrency limiting (MaxConcurrentQueries, default 5) and throughput limiting (MaxQueriesPerMinute, default 60). Excess requests are rejected with a retry message.

Connection Security

Use Windows Authentication or Azure Managed Identity where possible to avoid storing credentials in config files. When SQL Authentication is required, use environment variable overrides to inject credentials at runtime. See SECURITY.md for detailed guidance including credential stores and connection string encryption.

Known Risks

  • This project depends on the official Microsoft MCP C# SDK (ModelContextProtocol NuGet package, version 1.3.0). As the MCP framework handles all protocol I/O, any vulnerability in it directly affects this application's security boundary. Monitor the package for updates and upgrade when new versions are released.
  • The data returned from a SQL Server query could include malicious prompt injection targeting AIs. This is a risk of all AI use and cannot be mitigated by this project. Ensure you're following best practices for AI security and only connecting to trusted data sources.

Contributing

Contributions are welcome. See CONTRIBUTING.md for architecture details, development setup, testing instructions, and guidelines for adding new tools.

License

MIT

來源:README.md,提交 f7e492e

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.3.1最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分