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 分