Skip to main content
Glama

hs-sql-agent

一个用于安全 SQL 访问和企业治理的高性能 MCP 服务器。

License: Apache 2.0 Docker NuGet CodeQL Advanced Tests Deploy on Zeabur

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.Server
builder.Services.AddHsSqlAgent(options => { ... });
app.UseHsSqlAgent();                    // API only
// app.UseHsSqlAgent().ServeAdminUi();  // API and Admin UI

有关配置和部署详细信息,请参阅 NuGet 包指南

SQL 执行的工作原理

  1. 对 MCP 密钥进行身份验证,并应用其数据库、表和策略范围。

  2. 将受支持的 SQL 解析为结构化定义。

  3. 验证定义并针对配置的数据库提供程序进行编译。

  4. 在配置的限制内执行查询。

  5. 对于 DML,在事务中试运行,并在提交前通过 MCP Elicitation 要求人工审批。

自定义 SQL 工具与内置工具一样,会经过相同的解析器、验证、访问策略和执行限制。生命周期、参数和发布规则记录在管理面板指南中。

文档

主题

文档

入门

入门指南

配置

配置

管理面板

管理面板

MCP 工具和 SQL 支持

MCP 工具参考

安全、OIDC 和 MFA

安全治理

部署和可观测性

部署 · 分布式部署

API

API 参考

故障排除

故障排除

开发

开发

SQL 执行流程

DML 审批提示

这是 execute_dml_sql 期间人工参与审批步骤的界面:

贡献

请参阅 CONTRIBUTING.md开发指南

许可证

Apache License 2.0

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.

Maintenance

ActivityActive
ResponsivenessSyncing

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    F
    maintenance
    A 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 opera
    829
    40
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    Secure MCP server for safe, read-only DB access by AI agents, with SQL guardrails, table allowlists, PII masking, and audit logs
    6
    50
    7
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    Secure and token-efficient MySQL MCP server built specifically for AI agents. Prevents hallucinations, optimizes context windows and blocks dangerous queries.
    5
    89
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    Automatically scans SQLite databases and generates typed CRUD tools for each table, allowing natural language database interaction without exposing raw SQL.
    12
    -

Latest Blog Posts

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