text2sql

io.github.cpenniman12由 GitHub 帳號 cpenniman12 發布v0.1.2更新於 Oct 24, 2026

Ask any SQL database in natural language. Agent explores schema, writes SQL, self-corrects.

已驗證STDIO僅桌面資料庫AI 與機器學習

概覽

AI 產生的概覽

讓助理以自然語言查詢 SQL 資料庫,自動探索 schema、撰寫並執行 SQL,並在出錯時自我修正。

可以做什麼
以自然語言向資料庫提問,取得產生的 SQL、查詢結果、錯誤與列數。
適用情境
當你想直接用自然語言向 SQLite、Postgres、MySQL、Snowflake 或 BigQuery 資料庫提問,而不想手寫 SQL 或事先建立 schema 說明與向量索引時,適合加入此伺服器。
執行需求
需在本機以 Python 套件執行(pip 或 uvx),並依資料庫安裝對應 extra(postgres、mysql、snowflake、bigquery)。需設定 TEXT2SQL_DATABASE_URL,以及 ANTHROPIC_API_KEY 或 OPENAI_API_KEY;可選用 TEXT2SQL_MODEL、TEXT2SQL_INSTRUCTIONS、TEXT2SQL_EXAMPLES。
安裝前請注意
需提供資料庫連線字串(可能含帳密)與 LLM 供應商 API 金鑰,這些憑證會寫入 MCP 用戶端設定。助理會在真實資料庫上執行產生的 SQL,可能寫入、修改或刪除資料,建議使用唯讀帳號或備份。問題與 schema 內容會送往所選的 LLM 供應商。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 text2sql,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

text2sql-mcp

MCP server for text2sql-framework. Plugs into Claude Desktop, Cursor, Goose, or any other MCP-compatible assistant and lets it ask a SQL database questions in natural language.

The agent explores the schema, writes SQL, executes it against the real DB, and self-corrects on errors — no RAG layer, no schema descriptions, no pre-computed embeddings.

Install

Out of the box, text2sql-mcp supports SQLite + Anthropic:

bash
pip install text2sql-mcp# oruvx text2sql-mcp

For other databases or LLM providers, install with the matching extra so the right driver gets installed:

You want…Install command
SQLite (default)uvx text2sql-mcp
Postgresuvx 'text2sql-mcp[postgres]'
MySQLuvx 'text2sql-mcp[mysql]'
Snowflakeuvx 'text2sql-mcp[snowflake]'
BigQueryuvx 'text2sql-mcp[bigquery]'
OpenAI modelsadd openai, e.g. uvx 'text2sql-mcp[postgres,openai]'

Configure

Set environment variables in your MCP client config:

VariableRequiredDescription
TEXT2SQL_DATABASE_URLyesSQLAlchemy URL, e.g. sqlite:///mydb.db, postgresql://user:pass@host/db
ANTHROPIC_API_KEY or OPENAI_API_KEYyesLLM provider key
TEXT2SQL_MODELnoLangChain model id (default: anthropic:claude-sonnet-4-6)
TEXT2SQL_INSTRUCTIONSnoBusiness rules / hints, e.g. "Revenue = net of refunds."
TEXT2SQL_EXAMPLESnoPath to a scenarios.md file for the agent's lookup_example tool

Claude Desktop / Cursor / generic MCP

json
{  "mcpServers": {    "text2sql": {      "command": "uvx",      "args": ["text2sql-mcp"],      "env": {        "TEXT2SQL_DATABASE_URL": "sqlite:///mydb.db",        "ANTHROPIC_API_KEY": "sk-ant-..."      }    }  }}

Goose CLI

bash
goose configure# Add Extension → Command-line Extension# Name: text2sql# Command: uvx text2sql-mcp# Env: TEXT2SQL_DATABASE_URL, ANTHROPIC_API_KEY

Tools

  • query(question, max_rows=100) — ask the database a natural-language question. Returns {sql, data, error, row_count, tool_calls_made}.

How it works

Under the hood this is a thin wrapper around text2sql-framework, which uses LangChain Deep Agents to do iterative tool-calling against a single execute_sql tool. See the framework README for benchmarks (19/20 on Spider zero-shot across 80 tables) and architecture details.

License

MIT

來源:README.md,提交 97142b4

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.2最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分