
SqlAugur
io.github.mbentham由 GitHub 账号 mbentham 发布v1.3.1更新于 Oct 24, 2026
MCP server providing AI assistants with safe, read-only SQL Server access
概览
本地 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 开关。
安装
在 SourceWeft 中
- 打开 控制台中的 SqlAugur,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
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.
Quick Start
Use this order for all install methods:
- Install SqlAugur
- Save
appsettings.jsonin the correct location - Add SqlAugur to your MCP client config
- 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
verboseandincludeQueryPlansparameters 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)
2. Save config file
Example appsettings.json to save at that location:
3. Add to MCP client
To update: dotnet tool update -g SqlAugur
Docker / Podman
1. Run SqlAugur container
Note: To reach a SQL Server on the host machine, use
host.docker.internal(Docker Desktop) or--network=host(Linux). Replacedockerwithpodman— all commands are identical. The:Zflag 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
Docker Compose
MCP client configuration:
Build from Source
1. Build (prerequisite: .NET 10.0 SDK)
2. Save config file
3. Add to MCP client
Verify the MCP connection (LLM-first)
After restarting your MCP client, ask the assistant:
Call list_serversCall list_databases for server "production"
Expected result:
list_serversreturns your configured server name (for exampleproduction)list_databasesreturns a JSON array of databases, not a connection or authentication error
If verification fails:
- Confirm MCP config runs the expected command (
sqlaugur,docker run ..., ordotnet /path/to/SqlAugur.dll) - Confirm
appsettings.jsonis 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)
- Local tool:
- Confirm the tool call uses a configured server key (for example
production) - Confirm SQL connectivity and authentication in the connection string
Configuration
The server loads configuration from multiple sources. Higher-priority sources override lower ones:
- Command-line arguments
- Environment variables — using
__as section delimiter (e.g.,SqlAugur__Servers__production__ConnectionString=...) - Current working directory —
appsettings.jsonin the directory you run the command from - User config directory —
~/.config/sqlaugur/appsettings.jsonon Linux,%APPDATA%\sqlaugur\appsettings.jsonon Windows - Azure Key Vault — when
AzureKeyVaultUriis set (see below) - App directory —
appsettings.jsonnext to the DLL
Example configuration (Windows Authentication — recommended):
Security Note:
appsettings.jsonis 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
Schema Exploration (4 tools)
Diagrams (2 tools)
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:
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
DarlingData (8 tools) — requires EnableDarlingData: true
Install from: github.com/erikdarling/DarlingData
sp_WhoIsActive (1 tool) — requires EnableWhoIsActive: true
Install from: whoisactive.com
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:
Example flow:
- AI calls
list_toolsets— seesfirst_responder_kitis "available" (configured but not yet enabled) - AI calls
get_toolset_tools("first_responder_kit")— reviews the 7 tools and their parameters - AI calls
enable_toolset("first_responder_kit")— the 7 tools are now registered and usable - 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_changednotification 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,@helpblocked
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 (
ModelContextProtocolNuGet 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
来源:README.md,提交 f7e492e
工具
0版本历史
1- v1.3.1最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
