SqlToAi

io.github.RalfHuesing由 GitHub 账号 RalfHuesing 发布v1.0.34更新于 Oct 28, 2026

Microsoft SQL Server schema discovery and SQL tools over local stdio on Windows x64.

已验证STDIO仅桌面数据库数据与分析

概览

AI 生成的概览

面向 Microsoft SQL Server 的本地 Windows MCP 服务器,让助手检查架构、执行 SQL,并比较查询结果与性能。

可以做什么
  • 查看服务器与数据库元数据,以及表、视图、例程、触发器、键、索引和对象引用
  • 在不执行查询的情况下查看预估执行计划、算子树和警告
  • 执行参数化查询和本地 .sql 脚本(含 GO 批次),并把结果流式写入 CSV 或 JSONL 文件
  • 测量 CPU 时间、耗时和读取量,比较基线查询与候选查询,并查看缺失索引建议
  • 将数据库架构导出为相互链接的 Markdown 文件以便离线阅读
  • 配置从仅架构到读写的访问级别,并可对字符串结果做掩码或可逆令牌替换
适用场景
适合在 Windows 机器上、数据库可连通时,让助手探索 Microsoft SQL Server 数据库、编写或执行查询、审阅执行计划,或对查询改动做基准比较。
运行要求
以本地 stdio 进程运行,仅限 Windows x64;MCPB 或 ZIP 包自带运行时,无需单独安装 .NET 运行时,从源码构建则需要 .NET 10 SDK。需要可连通的 SQL Server 和具备相应权限的登录账号,并需在 %LOCALAPPDATA%\SqlToAi 下按模板手动创建 appsettings.json,填写服务器、凭据和访问列表。未声明任何环境变量或请求头。
安装前请注意
配置文件包含数据库凭据和访问授权,未列入访问列表的数据库会被拒绝。ReadWrite 与 ReadWriteAnonymized 级别允许修改数据,因此还应使用权限受限的 SQL 登录。掩码不会隐藏数值、日期、架构定义、比较样本和执行计划内容,且令牌在服务器运行期间可还原。架构导出会写入文件,失败时会留下已写出的文件。诊断与日志默认开启。

安装

在 SourceWeft 中

  1. 打开 控制台中的 SqlToAi,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

SqlToAi

SqlToAi is a local Model Context Protocol (MCP) server for Microsoft SQL Server. It gives MCP clients tools to inspect schemas, execute SQL, and compare query results and performance. The server runs over stdio and is built with .NET 10.

Capabilities

  • Retrieve SQL Server and database environment metadata (version, edition, compatibility level, collation, state, read-only status).
  • Inspect tables, views, routines, triggers, keys, indexes, and object references.
  • Inspect estimated query execution plans with compact operator trees and warnings without executing queries.
  • Export database schema as linked Markdown files for offline reading.
  • Execute parameterized queries and local .sql scripts, including GO batches.
  • Stream query results directly into local CSV or JSONL files with compact metadata responses.
  • Measure CPU time, elapsed time, reads, and execution plan warnings; compare a baseline query with a candidate and inspect missing-index suggestions.
  • Configure database access levels, from schema-only access to read/write access.
  • Mask string query results or replace them with reversible in-memory tokens; add table and column descriptions from SQL Server or a metadata database.

See the tool reference for arguments and behavior.

Export schema without starting the MCP server:

powershell
.\SqlToAi.exe export-schema --database primary/DemoDB --output C:\Doku\Database

The output directory must be absent or empty. The export contains schema details and SQL definitions, without business records, metadata descriptions or anonymization indicators. A failure returns a nonzero exit code and leaves any files already written. See schema export for file layout and retry behavior.

Getting started

For a downloaded Windows x64 package, follow manual package setup (included as README.md beside the executable). Choose the ZIP to extract and launch the executable yourself, or the MCPB to install the same executable as a client launch entry. Both are self-contained and need no separate .NET runtime. Before either route can start the server, create %LOCALAPPDATA%\SqlToAi\appsettings.json manually from the supplied template; bundle installation does not create it. Updates preserve the separate user settings and logs, but upgrading from the old single-server settings is a breaking change: manually move old sections and provider settings under a named server, qualify database grants, and rename environment keys before the first new startup. There is no automatic migration; follow the upgrade instructions.

You need the .NET 10 SDK, a reachable SQL Server, and a database login with the permissions required by the tools you use.

Build

powershell
dotnet build SqlToAi.slnx -c Release

The Windows executable and configuration are written to src/SqlToAi/bin/Release/net10.0/.

Configure database access

Before starting SqlToAi, create %LOCALAPPDATA%\SqlToAi\appsettings.json manually from the shipped template. The main template has no database grants or working credentials; set the server, credentials, and access lists deliberately. The separate DemoDB example contains fictional local demo credentials and ReadWrite access. Select it manually for a local test database only; the host does not load it automatically.

For Windows authentication and string masking, configure the Databases and Servers sections with the following, substituting your database and server:

json
"Databases": {  "CacheTtlSeconds": 300,  "ReadWrite": [],  "ReadWriteAnonymized": [],  "ReadOnly": [],  "ReadOnlyAnonymized": ["primary/ReportingDB"],  "SchemaOnly": []},"Servers": {  "primary": {    "Server": "localhost\\MSSQLSERVER2022",    "IntegratedSecurity": true,    "ConnectTimeoutSeconds": 30  }}

These sections belong inside the existing SqlToAi object. Keep Anonymizer.Enabled set to true. Databases absent from the access lists are denied. Use a SQL Server login with restricted permissions as well as the application access lists.

See configuration for manual setup, SQL authentication, per-field environment overrides, metadata, and logging.

Connect an MCP client

Add a stdio server entry to your client's MCP configuration, using the absolute path to your executable. The exact configuration location depends on the client.

json
{  "mcpServers": {    "sql-to-ai": {      "command": "C:\\Path\\To\\SqlToAi\\src\\SqlToAi\\bin\\Release\\net10.0\\SqlToAi.exe",      "args": []    }  }}

Check tools from the command line

powershell
Set-Location src/SqlToAi/bin/Release/net10.0.\SqlToAi.exe query --help.\SqlToAi.exe query sql_list_databases --server primary.\SqlToAi.exe query sql_execute_query --database primary/ReportingDB --query "SELECT TOP 5 name FROM sys.tables".\SqlToAi.exe query sql_explain_query --database primary/ReportingDB --query "SELECT TOP 5 name FROM sys.tables"

Tool results contain Markdown or JSON. Successful CLI calls write data to stdout; notices and errors go to stderr. Failed calls exit with code 1. See development and CLI usage for export and deployment.

Protection and limits

Read-only execution uses SQL statement validation and rollback transactions. ReadWrite permits changes with raw string results; ReadWriteAnonymized permits changes while applying the configured string masking or tokenization to query and script results. These application checks complement SQL Server permissions; they do not replace them.

String masking applies to query, script, and data export results for ReadOnlyAnonymized and ReadWriteAnonymized databases. Numeric values, dates, schema definitions, query-comparison difference samples, and execution plan content can remain visible. Tokens are reversible within the running server. This is not a guarantee that all sensitive data is removed.

Query comparison checks schema, row counts, and distinct set differences. It does not establish row ordering or duplicate multiplicity. Benchmark results describe the measured executions and do not guarantee a production improvement.

Application and error diagnostics remain enabled. Review the security boundaries and logging settings before use.

Documentation and development

Run the xUnit v3 test suite with dotnet test SqlToAi.slnx.

License

MIT.

来源:README.md,提交 41af58e

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.0.34最新Oct 17, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分