mcpField
T
text2sql

text2sql

Local
github.com/cpenniman12Databases1Updated 13w ago

About text2sql

text2sql is an MCP server for asking SQL databases questions in natural language. It explores the schema, runs generated SQL, and corrects errors, without a RAG layer or precomputed embeddings.

Key features

  1. 01Natural-language database queries
  2. 02Schema exploration
  3. 03SQL execution and error correction
  4. 04SQLite, Postgres, MySQL, Snowflake, BigQuery support

Use cases

  1. 01Ask questions about database contents
  2. 02Run queries without writing SQL manually

MCP support

Exposes a `query` tool to MCP clients, returning generated SQL, data, errors, and row counts. It can connect to Claude Desktop, Cursor, Goose, and other MCP-compatible assistants.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"cpenniman12-text2sql": {
"command": "uvx",
"args": [
"text2sql-mcp"
],
"env": {
"TEXT2SQL_DATABASE_URL": "<TEXT2SQL_DATABASE_URL>",
"ANTHROPIC_API_KEY": "<ANTHROPIC_API_KEY>",
"OPENAI_API_KEY": "<OPENAI_API_KEY>",
"TEXT2SQL_MODEL": "<TEXT2SQL_MODEL>"
}
}
}
}
Run commanduvx text2sql-mcp
Environment variables to set
TEXT2SQL_DATABASE_URLSQLAlchemy connection URL, e.g. sqlite:///mydb.db or postgresql://user:pass@host/db
ANTHROPIC_API_KEYSecretAnthropic API key (required if using the default Anthropic model)
OPENAI_API_KEYSecretOpenAI API key (required when TEXT2SQL_MODEL is set to an openai:* model)
TEXT2SQL_MODELOptional LangChain model id (default: anthropic:claude-sonnet-4-6)

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
pypitext2sql-mcp0.1.2

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project 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:

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
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
{
  "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

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.