Text2sql logo

Text2sql

Natural-language SQL queries for SQLite, Postgres, MySQL, Snowflake, and BigQuery through an MCP-compatible assistant.

Install Text2sql

Pick your client, then add it in one click or paste the config.

STDIOPython
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "text2sql": {
      "command": "uvx",
      "args": [
        "text2sql-mcp"
      ],
      "env": {
        "TEXT2SQL_DATABASE_URL": "YOUR_VALUE_HERE",
        "ANTHROPIC_API_KEY": "YOUR_VALUE_HERE",
        "OPENAI_API_KEY": "YOUR_VALUE_HERE"
      }
    }
  }
}

Settings → Developer → Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

Values are written into the snippet above so you can paste it as is. They never leave your browser.

We couldn’t confirm it starts correctly

We ran the install command but it didn't respond within our test window — this can mean a slow first-time install rather than a real problem.

uvx text2sql-mcp

No response to initialize.

This is an experimental automated check and can have false negatives — missing environment variables, a slow cold install, etc. It doesn’t necessarily mean something’s wrong. Last checked .

Overview

The text2sql MCP server lets an MCP-compatible assistant query SQL databases using natural language. It inspects the database schema, generates SQL, executes the query, and retries after errors through an iterative tool-calling workflow. SQLite and Anthropic are supported by default, with install extras for Postgres, MySQL, Snowflake, BigQuery, and OpenAI models. Use it when an agent needs direct database access without a RAG layer, schema descriptions, or precomputed embeddings.

Use cases

  • Ask business questions about records in a SQL database
  • Explore an unfamiliar database schema through an assistant
  • Generate and run SQL without maintaining schema embeddings
  • Retry malformed queries after database execution errors

Key features

  • Natural-language database queries
  • Schema exploration
  • Iterative SQL generation and correction
  • SQLite, Postgres, MySQL, Snowflake, and BigQuery support
  • Anthropic and OpenAI model support
  • Structured query results with SQL and error details

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

12/12 checks healthy over the last 60d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 4d ago via OSV.dev · text2sql-mcp (PyPI)

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars1Stargazers on the source repository.
Last commit3mo agoMost recent push to the default branch.
Install checkInconclusiveDidn't respond in our test window — often a slow first install.
Directory activity4 viewsConfig copies, upvotes, and views on AllMCPs.

How Text2sql works

What text2sql does

The text2sql MCP server connects an MCP-compatible assistant to a SQL database and turns natural-language questions into executed queries. It supports SQLite by default and can be installed with extras for Postgres, MySQL, Snowflake, or BigQuery. Anthropic is the default model provider, while OpenAI models can be enabled with the corresponding installation extra.

The main interaction is the query tool. It accepts a question and an optional max_rows limit, then returns the generated SQL, result data, any error, the row count, and the number of tool calls made. This makes it suitable for assistants that need to inspect data rather than only explain how to write a query.

How it works

The text2sql MCP server is a thin MCP wrapper around the text2sql-framework. The agent first explores the connected database schema, creates SQL for the user’s question, and runs that SQL through an execute_sql tool. If execution produces an error, the agent can revise the query and try again.

This workflow operates directly against the configured database. It does not require a retrieval-augmented generation layer, manually maintained schema descriptions, or precomputed embeddings. You can also provide business guidance through TEXT2SQL_INSTRUCTIONS, such as definitions for revenue or other domain-specific terms. The optional TEXT2SQL_EXAMPLES variable points to a scenarios.md file that the agent can use with its lookup_example tool.

Setup and configuration

Install the package with pip or run it through uvx. The default installation is suitable for SQLite with Anthropic:

Terminal
pip install text2sql-mcp
uvx text2sql-mcp

Use the matching extra when another database or provider is needed, such as text2sql-mcp[postgres], text2sql-mcp[mysql], text2sql-mcp[snowflake], or text2sql-mcp[bigquery]. Add the openai extra to use OpenAI models.

Configure the MCP client with TEXT2SQL_DATABASE_URL, using a SQLAlchemy URL such as sqlite:///mydb.db or a PostgreSQL connection URL. An ANTHROPIC_API_KEY or OPENAI_API_KEY is also required. TEXT2SQL_MODEL selects the LangChain model ID and defaults to anthropic:claude-sonnet-4-6.

The package can be registered as a command-line MCP server in Claude Desktop, Cursor, or another compatible client. Goose can be configured with its command-line extension settings.

Tools and capabilities

  • Ask natural-language questions with query.
  • Limit returned results with max_rows, which defaults to 100.
  • Inspect database schema before query generation.
  • Execute generated SQL against the configured database.
  • Retry after SQL execution errors.
  • Return SQL, data, errors, row counts, and tool-call counts.

Limitations and notes

The server connects to one configured SQL database through TEXT2SQL_DATABASE_URL; the material does not describe multi-database orchestration. Database support beyond SQLite depends on installing the relevant extra and driver. Query results are limited to 100 rows by default unless a different max_rows value is supplied.

The agent uses an LLM provider key, so model availability and behavior depend on the selected Anthropic or OpenAI configuration.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Text2sql

text2sql is an MCP server that connects an MCP-compatible assistant to a SQL database and uses an LLM to explore its schema, generate SQL, execute it, and correct errors. Its main tool is `query`, which accepts a natural-language question and returns SQL, data, errors, row counts, and tool-call counts.

Install it with `pip install text2sql-mcp` or run `uvx text2sql-mcp`. The default package supports SQLite with Anthropic; install database-specific extras such as `[postgres]` or `[mysql]`, and add `[openai]` for OpenAI models.

Yes, text2sql works with Cursor through its MCP configuration. Register `uvx text2sql-mcp` as the command, then set `TEXT2SQL_DATABASE_URL` and an Anthropic or OpenAI provider key in the client environment.

It supports SQLite by default and provides installation extras for Postgres, MySQL, Snowflake, and BigQuery. Use the matching package extra so the required database driver is installed.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewText2sql AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/text2sql?style=directory)](https://allmcps.com/mcp/text2sql)
HTML Embed
<a href="https://allmcps.com/mcp/text2sql"><img src="https://allmcps.com/api/badge/text2sql?style=directory" alt="Text2sql on AllMCPs" /></a>