Skip to main content

MCP server for text2sql-framework. Lets any MCP-compatible assistant (Claude Desktop, Cursor, Goose, etc.) ask a SQL database questions in natural language.

Project description

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

pip install text2sql-mcp
# or
uvx text2sql-mcp

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

text2sql_mcp-0.1.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

text2sql_mcp-0.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file text2sql_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: text2sql_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for text2sql_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 57980f7f2d1b07f55ef5be55ba299b890c4e257862251f6b9ed80f7e7e722922
MD5 63b18fb85737d07ae6580124a182c3b4
BLAKE2b-256 414578e7739d6e3d8028fd1b36a6d2181f7393b301a26bf4526966336d867c33

See more details on using hashes here.

File details

Details for the file text2sql_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: text2sql_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for text2sql_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dd8e3634c763775021c1aee3432369eb89baff434cef2414c4545971bb796165
MD5 e09e4c129b8ea159009cc10f628b21c9
BLAKE2b-256 94510e4130a30b90d4739dadf11d902328df0a29d912485ee8b344f764b4a562

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page