text2sql

io.github.cpenniman12Published by GitHub account cpenniman12v0.1.2Updated Oct 24, 2026

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

VerifiedSTDIODesktop onlyDatabasesAI & ML

Overview

AI-generated overview

Lets an assistant query a SQL database in natural language, exploring the schema, writing and running SQL, and correcting itself on errors.

What you can do
Ask a database a natural-language question and get back the generated SQL, result rows, error and row count.
When to use it
Use it when you want to ask questions of a SQLite, Postgres, MySQL, Snowflake or BigQuery database in plain language without writing SQL or setting up schema descriptions and embeddings first.
Requirements
Runs locally as a Python package (pip or uvx), with a database extra such as postgres, mysql, snowflake or bigquery installed as needed. Requires TEXT2SQL_DATABASE_URL and either ANTHROPIC_API_KEY or OPENAI_API_KEY; optional TEXT2SQL_MODEL, TEXT2SQL_INSTRUCTIONS and TEXT2SQL_EXAMPLES.
Before you install
Needs a database connection URL, which may embed credentials, and an LLM provider API key, both stored in the MCP client config. The assistant executes generated SQL against the real database, so it may write, change or delete data; prefer a read-only account or backups. Questions and schema details are sent to the chosen LLM provider.

Installation

In SourceWeft

  1. Open text2sql in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

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

Source: README.md at commit 97142b4

Tools

0
SourceWeft has not started this package in its sandbox yet, so its tools are not known.

Version history

1
  1. v0.1.2LatestSep 16, 2026

Score

50% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts

    Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.

  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listed15 pts

    Answer tools/list without a credential, or ship a package that starts in a sandbox without one.

  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts