Skip to content

tse-wei-chen/hs-sql-agent

hs-sql-agent

The high-performance MCP server for instant SQL interaction and secure enterprise governance.

License: Apache 2.0 Docker CodeQL Advanced Tests

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 flips the model: the LLM only extracts logical parameters (tables, columns, conditions), and a deterministic engine (SqlKata) constructs the final SQL. Zero hallucinated syntax, zero injection surface.

  • Deterministic Accuracy — The LLM never writes raw SQL. No made-up tables, no wrong functions, no dialect mix-ups between PostgreSQL and Oracle.
  • 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

🤝 Contributing

See CONTRIBUTING.md and the Development wiki page.

📜 License

Apache License 2.0

About

A high-performance C# SQL Agent MCP that eliminates LLM hallucinations and security risks. Instead of letting the AI write raw SQL, it extracts parameters to generate deterministic, injection-free queries across 6 major databases—complete with a visual Admin UI and enterprise guardrails.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors