
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.
概览
让助手用自然语言查询 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。
安装
在 SourceWeft 中
- 打开 控制台中的 text2sql,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
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:
For other databases or LLM providers, install with the matching extra so the right driver gets installed:
Configure
Set environment variables in your MCP client config:
Claude Desktop / Cursor / generic MCP
Goose CLI
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版本历史
1- v0.1.2最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分