SqlAugur

by mbentham

Not rated
GitHub

Description

MCP server providing AI assistants with safe, read-only access to SQL Server databases. Built with C#/.NET 10, it uses AST-based query validation (Microsoft's T-SQL parser) to ensure only SELECT statements execute - blocking INSERT/UPDATE/DELETE/DROP/EXEC at the syntax tree…

About

MCP server providing AI assistants with safe, read-only access to SQL Server databases. Built with C#/.NET 10, it uses AST-based query validation (Microsoft's T-SQL parser) to ensure only SELECT statements execute - blocking INSERT/UPDATE/DELETE/DROP/EXEC at the syntax tree level. Features include schema exploration…

Details

Author
mbentham
Categories
Database, Other, Knowledge Base

Setup

Install SqlAugur in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/mbentham/SqlAugur

Follow the installation instructions in the repository README, then restart your MCP client.

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 │ │ │ └────────────────────────────────────┘ │ └───────────────────────────────────────────┘

- Install SqlAugur
- Saveappsettings.jsonin the correct location
- Add SqlAugur to your MCP client config
- Verify by asking your assistant to calllist_servers

Start withInstallationfor exact commands and file paths.

-

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 officialTSql180Parser. 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%. UseverboseandincludeQueryPlansparameters 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.

- 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

- 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, andsp_WhoIsActivewith automatic response size optimisation
- Progressive discovery — dynamic toolset mode reduces initial context window usage by exposing tools on demand

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

1. Install(prerequisite:.NET 10.0 runtime)

# Linux/macOS mkdir -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

Exampleappsettings.jsonto save at that location:

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

To update:dotnet tool update -g SqlAugur

# Volume-mount a config file docker 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, usehost.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.jsonand mount it to/app/appsettings.json.

{ "mcpServers": { "sqlaugur": { "command": "docker", "args": ["run", "-i", "--rm", "-v", "/path/to/appsettings.json:/app/appsettings.json:ro,Z", "ghcr.io/mbentham/sqlaugur:latest"] } } }
services: sqlaugur: image: ghcr.io/mbentham/sqlaugur:latest stdin_open: true volumes: - ./appsettings.json:/app/appsettings.json:ro,Z
{ "mcpServers": { "sqlaugur": { "command": "docker", "args": ["compose", "run", "-i", "--rm", "sqlaugur"] } } }
git clone git@github.com:mbentham/SqlAugur.git cd SqlAugur dotnet publish SqlAugur -c Release -o SqlAugur/publish
# Linux/macOS cp 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
{ "mcpServers": { "sqlaugur": { "command": "dotnet", "args": ["/absolute/path/to/SqlAugur/publish/SqlAugur.dll"] } } }

After restarting your MCP client, ask the assistant:

- Call list_servers
- Call list_databases for server "production"

- list_serversreturns your configured server name (for exampleproduction)
- list_databasesreturns a JSON array of databases, not a connection or authentication error
- Confirm MCP config runs the expected command (sqlaugur,docker run ..., ordotnet /path/to/SqlAugur.dll)
- Confirmappsettings.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)

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 directoryappsettings.jsonin the directory you run the command from
- User config directory~/.config/sqlaugur/appsettings.jsonon Linux,%APPDATA%\sqlaugur\appsettings.jsonon Windows
- Azure Key Vault— whenAzureKeyVaultUriis set (see below)
- App directoryappsettings.jsonnext to the DLL

Example configuration (Windows Authentication — recommended):

{ "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 } }

Security Note:appsettings.jsonis gitignored to prevent accidental credential commits. SeeSECURITY.mdfor recommended authentication methods including Windows Authentication, Azure Managed Identity, and secure credential storage options.

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).

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).

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

Install from:github.com/erikdarling/DarlingData

WhenEnableDynamicToolsetsis 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:
- AI callslist_toolsets— seesfirst_responder_kitis "available" (configured but not yet enabled)
- AI callsget_toolset_tools("first_responder_kit")— reviews the 7 tools and their parameters
- AI callsenable_toolset("first_responder_kit")— the 7 tools are now registered and usable
- AI callssp_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 MCPnotifications/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.

Every query is parsed into anAbstract Syntax Tree(AST) using Microsoft's officialTSql180Parserand 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.

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

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.

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. SeeSECURITY.mdfor detailed guidance including credential stores and connection string encryption.

- This project depends on the official MicrosoftMCP 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.

Contributions are welcome. SeeCONTRIBUTING.mdfor architecture details, development setup, testing instructions, and guidelines for adding new tools.

Official MCP server for dbt (data build tool) providing integration with dbt Core/Cloud CLI, project metadata discovery, model information, and semantic layer querying capabilities.

Query and analyze data with MotherDuck and local DuckDB

A collection of tools for managing the platform, addressing data quality and reading and writing to Teradata Database.

A read-only MCP server for Avro data sources, powered by the CData JDBC Driver.

Run SQL queries on data in Amazon S3 using AWS Athena.

Interact with Bauplan data tables and run queries.

Production-grade MCP server for Databricks: SQL Warehouses, Jobs API, multi-workspace support.

Visual no-code generator that turns any database into multiple scoped MCP servers — one per access group, with PII masking and fail-closed query scoping built in.

A read-only MCP server by CData that enables LLMs to query live data from EnterpriseDB databases.

A read-only MCP server for MySQL, enabling LLMs to query live data using the CData JDBC Driver.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.