Skip to main content

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:

pip install text2sql-mcp
# or
uvx 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
Postgres uvx 'text2sql-mcp[postgres]'
MySQL uvx 'text2sql-mcp[mysql]'
Snowflake uvx 'text2sql-mcp[snowflake]'
BigQuery uvx 'text2sql-mcp[bigquery]'
OpenAI models add openai, e.g. uvx 'text2sql-mcp[postgres,openai]'

Configure

Set environment variables in your MCP client config:

Variable Required Description
TEXT2SQL_DATABASE_URL yes SQLAlchemy URL, e.g. sqlite:///mydb.db, postgresql://user:pass@host/db
ANTHROPIC_API_KEY or OPENAI_API_KEY yes LLM provider key
TEXT2SQL_MODEL no LangChain model id (default: anthropic:claude-sonnet-4-6)
TEXT2SQL_INSTRUCTIONS no Business rules / hints, e.g. "Revenue = net of refunds."
TEXT2SQL_EXAMPLES no Path to a scenarios.md file for the agent's lookup_example tool

Claude Desktop / Cursor / generic MCP

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

Goose CLI

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

Release files for text2sql-mcp 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for text2sql-mcp 0.1.2
File Size Uploaded
text2sql_mcp-0.1.2.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for text2sql-mcp 0.1.2
File Interpreter ABI Platform
text2sql_mcp-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / text2sql_mcp-0.1.2.tar.gz

Download URL text2sql_mcp-0.1.2.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a4b80855d701b6534386b0a961b1c4c3489bee89cd39a09cf18e31382716e8f4
BLAKE2b-256 checksum
How to use checksums
e0c2e27e023d373c485b4eeee690425c331f9ecdb5d7732ce8c31362368b9fcb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / text2sql_mcp-0.1.2-py3-none-any.whl

Download URL text2sql_mcp-0.1.2-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
71cf65423d596ceeebea683fcd827026655be4929494b30a9c0751fb202b2db2
BLAKE2b-256 checksum
How to use checksums
80c6298a8a4c27fa9a6942ecd2e3cfaf2e900d7e05cf7341ce0f3ec5cbd5e857
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page