hs-sql-agent
hs-sql-agent
一个用于安全 SQL 访问和企业治理的高性能 MCP 服务器。
hs-sql-agent 通过 HTTP MCP 端点和内置的管理面板,将 MCP 客户端连接到 SQLite、PostgreSQL、MySQL、SQL Server、Oracle 和 Firebird。
为什么选择 hs-sql-agent?
服务器不会执行不受限制的 LLM 生成的 SQL,而是将受支持的 SQL 解析为结构化定义,进行验证,并通过特定于提供程序的 SQL 编译器重新构建最终语句。
六大数据库提供程序 — SQLite、PostgreSQL、MySQL、SQL Server、Oracle 和 Firebird。
受治理的访问 — 按密钥绑定数据库、表白名单、CORS、速率限制和执行策略。
安全的 DML — 事务性试运行,然后通过 MCP Elicitation 进行明确的人工审批。
管理面板 — 管理数据库、密钥、角色、自定义工具、审计记录和运行时策略。
企业就绪 — OIDC SSO、TOTP MFA、审计保留、Prometheus 指标、OTLP 以及 webhook/SIEM 交付。
语义元数据 — 表和列同义词、关系以及用于架构发现的范围化指标元数据。
SQL 支持是有意限定的:不支持的语法会被拒绝,而不会静默改变其含义。有关受支持的 SQL 约定,请参阅 MCP 工具参考。
Related MCP server: safedb-mcp
快速开始
cp .env.example .env
# Set HMAC_KEY and JWT_KEY to unique secrets of at least 32 bytes.
docker compose up -d在 http://localhost:8080 打开管理面板。配置选项和生产部署指南记录在 Wiki 中。
与 MCP 客户端一起使用
在管理面板中创建 MCP 密钥。密钥对话框会显示一次明文机密,并为 Claude Desktop、Cursor 和通用 Streamable HTTP 客户端生成配置。
将 MCP_PUBLIC_ENDPOINT 设置为可从外部访问的 MCP URL,包括 /mcp。有关客户端兼容性、入门和 DML Elicitation 要求,请参阅 MCP 客户端入门。
适用于现有 .NET API 的 NuGet
将 MCP SQL Agent 和可选的管理 UI 嵌入到 ASP.NET Core 应用程序中:
dotnet add package HsSqlAgent.Serverbuilder.Services.AddHsSqlAgent(options => { ... });
app.UseHsSqlAgent(); // API only
// app.UseHsSqlAgent().ServeAdminUi(); // API and Admin UI有关配置和部署详细信息,请参阅 NuGet 包指南。
SQL 执行的工作原理
对 MCP 密钥进行身份验证,并应用其数据库、表和策略范围。
将受支持的 SQL 解析为结构化定义。
验证定义并针对配置的数据库提供程序进行编译。
在配置的限制内执行查询。
对于 DML,在事务中试运行,并在提交前通过 MCP Elicitation 要求人工审批。
自定义 SQL 工具与内置工具一样,会经过相同的解析器、验证、访问策略和执行限制。生命周期、参数和发布规则记录在管理面板指南中。
文档
SQL 执行流程
DML 审批提示
这是 execute_dml_sql 期间人工参与审批步骤的界面:
贡献
请参阅 CONTRIBUTING.md 和开发指南。
许可证
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
This server cannot be installed
Maintenance
Related MCP Connectors
Deterministic safety, correctness & cost gate that vets Postgres SQL before your AI agent runs it.
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
- mcpOAuthcom.gibsonai
GibsonAI MCP server: manage your databases with natural language
AgentGuard — 20-tool AI safety MCP: policy preflight, risk scoring, audit logging, rate limits.
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceA Model Context Protocol (MCP) server that enables AI agents to interact with Microsoft SQL Server databases through secure, intelligent database operations. This server provides comprehensive CRUD capabilities, schema introspection, stored procedure execution, transaction management, and bulk opera82940MIT
- AlicenseAqualityCmaintenanceSecure MCP server for safe, read-only DB access by AI agents, with SQL guardrails, table allowlists, PII masking, and audit logs6507MIT
- AlicenseAqualityCmaintenanceSecure and token-efficient MySQL MCP server built specifically for AI agents. Prevents hallucinations, optimizes context windows and blocks dangerous queries.589MIT
- FlicenseAqualityDmaintenanceAutomatically scans SQLite databases and generates typed CRUD tools for each table, allowing natural language database interaction without exposing raw SQL.12-
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/tse-wei-chen/hs-sql-agent'
If you have feedback or need assistance with the MCP directory API, please join our Discord server