HsSqlAgent.Server
1.10.0
dotnet add package HsSqlAgent.Server --version 1.10.0
NuGet\Install-Package HsSqlAgent.Server -Version 1.10.0
<PackageReference Include="HsSqlAgent.Server" Version="1.10.0" />
<PackageVersion Include="HsSqlAgent.Server" Version="1.10.0" />
<PackageReference Include="HsSqlAgent.Server" />
paket add HsSqlAgent.Server --version 1.10.0
#r "nuget: HsSqlAgent.Server, 1.10.0"
#:package HsSqlAgent.Server@1.10.0
#addin nuget:?package=HsSqlAgent.Server&version=1.10.0
#tool nuget:?package=HsSqlAgent.Server&version=1.10.0
hs-sql-agent
The high-performance MCP server for instant SQL interaction and secure enterprise governance. <img src="miscellaneous\coverImage.png" />
hs-sql-agent is an HTTP MCP server for relational databases (SQLite, PostgreSQL, MySQL, SQL Server, Oracle, Firebird) with a built-in Admin Panel for governance.
🤔 Why hs-sql-agent?
Most "Chat with your Data" tools ask the LLM to write raw SQL — a recipe for hallucinations, dialect confusion, and injection risks. hs-sql-agent takes a structured approach: the AI can write SQL, the server parses it into structured definitions, validates the result, and rebuilds the final query through the SQL builder before execution. Zero hallucinated syntax, zero direct string injection into the database.
- Structured SQL Pipeline — The AI can write SQL, but the server parses it into structured definitions, validates it, and rebuilds the final query through the SQL builder before execution.
- Universal DB Support — One agent for SQLite, PostgreSQL, MySQL, SQL Server, Oracle, and Firebird. The same MCP endpoint switches engines transparently.
- Enterprise Governance — Built-in Admin Web UI, key-level connection mapping, table whitelisting, per-key CORS, rate limiting, and full audit logs.
- Semantic Layer — Map cryptic legacy column names to business-friendly labels so the LLM understands your schema.
Where to use it
| Use case | Description |
|---|---|
| Cursor / Claude Desktop | Let devs query dev/test DBs in natural language from their AI IDE. |
| Multi-DB agents | One MCP server per database, each secured with its own API key. The agent aggregates multiple MCP connections to seamlessly orchestrate workflows across PostgreSQL, MySQL, and Oracle. |
| Enterprise chatbots | Connect internal AI agents to ERP/CRM systems with table-level permission isolation. |
| Legacy modernization | Bridge modern AI to decades-old databases via the semantic layer. |
🚀 Quick Start
cp .env.example .env # set HMAC_KEY and JWT_KEY (32+ bytes)
docker compose up -d # http://localhost:8080
📦 NuGet for Existing .NET APIs
Already have an ASP.NET Core API? Embed the full MCP SQL Agent + Admin UI in minutes:
dotnet add package HsSqlAgent.Server
builder.Services.AddHsSqlAgent(options => { ... });
app.UseHsSqlAgent(); // API-only
// app.UseHsSqlAgent().ServeAdminUi(); // with Admin UI
The Admin UI is embedded in the DLL — no external files to deploy. See the NuGet Package guide for details.
📖 Documentation
Detailed docs are on the Wiki:
| Topic | Link |
|---|---|
| 🚀 Getting Started | Getting-Started |
| ✨ Features | Features |
| 📘 MCP Tools | MCP-Tools-Reference |
| 🖥️ Admin Panel | Admin-Panel |
| ⚙️ Configuration | Configuration |
| 🐳 Deployment | Deployment |
| 🏠 Development | Development |
| 📡 API Reference | API-Reference |
| ❓ FAQ | FAQ |
SQL Execution Flow
flowchart TD
LLM["LLM / MCP Client"] -->|Call tool with SQL| MCP["HsSqlAgent MCP Server"]
MCP --> AUTH["Access key auth<br/>allowed tools + DB binding + table whitelist"]
AUTH --> ROUTE{"Tool"}
ROUTE -->|execute_query_sql(sql)| QPARSE["Parse SELECT SQL<br/>SqlDefinitionParser.ParseQuery"]
QPARSE --> QDEF["QueryDefinition"]
QDEF --> QVALID["DefinitionValidator<br/>+ table whitelist checks"]
QVALID --> QBUILD["SQL builder / strategy compile"]
QBUILD --> QEXEC["Execute SELECT"]
QEXEC --> QRESULT["Rows / JSON result"]
ROUTE -->|execute_dml_sql(sql)| DPARSE["Parse DML SQL<br/>SqlDefinitionParser.ParseDml"]
DPARSE --> DDEF["DmlDefinition"]
DDEF --> DVALID["DefinitionValidator<br/>+ table whitelist checks"]
DVALID --> DRYRUN["Dry-run inside uncommitted transaction"]
DRYRUN --> ELICIT["MCP Elicitation<br/>user approves in client UI"]
ELICIT --> DECIDE{"User response"}
DECIDE -->|Accept| DEXEC["Commit transaction"]
DECIDE -->|Decline / Cancel| DROLLBACK["Rollback transaction"]
QRESULT --> AUDIT["Async audit log"]
DEXEC --> AUDIT
DROLLBACK --> AUDIT
DML Approval Prompt
This is what the human-in-the-loop approval step looks like during execute_dml_sql:
<img src="miscellaneous/dml-approval-prompt.png" width="550" style="border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);" />
🤝 Contributing
See CONTRIBUTING.md and the Development wiki page.
📜 License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- BCrypt.Net-Next (>= 4.0.3)
- dapper (>= 2.1.79)
- FirebirdSql.Data.FirebirdClient (>= 10.3.4)
- FluentValidation.AspNetCore (>= 11.3.1)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 10.0.9)
- Microsoft.Data.SqlClient (>= 7.0.2)
- Microsoft.EntityFrameworkCore (>= 10.0.9)
- Microsoft.EntityFrameworkCore.Sqlite (>= 10.0.9)
- Microsoft.Extensions.Caching.StackExchangeRedis (>= 10.0.9)
- Microsoft.Extensions.FileProviders.Embedded (>= 10.0.9)
- ModelContextProtocol (>= 1.4.0)
- ModelContextProtocol.AspNetCore (>= 1.4.0)
- MySql.Data (>= 9.7.0)
- Npgsql (>= 10.0.3)
- Oracle.ManagedDataAccess.Core (>= 23.26.200)
- SQLitePCLRaw.lib.e_sqlite3 (>= 3.50.3)
- System.IdentityModel.Tokens.Jwt (>= 8.19.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.10.0 | 46 | 7/4/2026 |
| 1.9.1 | 97 | 6/29/2026 |
| 1.9.0 | 93 | 6/28/2026 |
| 1.8.3 | 109 | 6/26/2026 |
| 1.8.2-alpha | 99 | 6/2/2026 |
| 1.8.1-alpha | 99 | 5/30/2026 |
| 1.8.0-alpha | 99 | 5/30/2026 |