Back to Browse

Text2sql MCP Server

Developer ToolsUse Caution4.2MCP RegistryLocal
Free

Server data from the Official MCP Registry

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

About

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

Security Report

4.2
Use Caution4.2High Risk

This is a well-intentioned MCP server for database querying via natural language. Authentication and authorization are appropriately delegated to the underlying text2sql-framework and LLM providers (Anthropic/OpenAI). The primary security concern is that database access depends entirely on the `TEXT2SQL_DATABASE_URL` environment variable and the framework's internal safety mechanisms — users must ensure their database credentials are properly managed and that the framework actually enforces read-only access. Code quality is good with proper error handling, but lacks explicit input validation and logging safeguards around sensitive operations. Supply chain analysis found 4 known vulnerabilities in dependencies (0 critical, 3 high severity). Package verification found 1 issue.

4 files analyzed · 9 issues found

Security scores are indicators to help you make informed decisions, not guarantees. Always review permissions before connecting any MCP server.

Permissions Required

This plugin requests these system permissions. Most are normal for its category.

env_vars

Check that this permission is expected for this type of plugin.

HTTP Network Access

Connects to external APIs or services over the internet.

database

Check that this permission is expected for this type of plugin.

What You'll Need

Set these up before or after installing:

SQLAlchemy connection URL, e.g. sqlite:///mydb.db or postgresql://user:pass@host/dbOptional

Environment variable: TEXT2SQL_DATABASE_URL

Anthropic API key (required if using the default Anthropic model)Required

Environment variable: ANTHROPIC_API_KEY

OpenAI API key (required when TEXT2SQL_MODEL is set to an openai:* model)Required

Environment variable: OPENAI_API_KEY

Optional LangChain model id (default: anthropic:claude-sonnet-4-6)Optional

Environment variable: TEXT2SQL_MODEL

How to Install

Add this to your MCP configuration file:

{
  "mcpServers": {
    "io-github-cpenniman12-text2sql-mcp": {
      "env": {
        "OPENAI_API_KEY": "your-openai-api-key-here",
        "TEXT2SQL_MODEL": "your-text2sql-model-here",
        "ANTHROPIC_API_KEY": "your-anthropic-api-key-here",
        "TEXT2SQL_DATABASE_URL": "your-text2sql-database-url-here"
      },
      "args": [
        "text2sql-mcp"
      ],
      "command": "uvx"
    }
  }
}

Documentation

View on GitHub

From the project's GitHub 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

Reviews

No reviews yet

Be the first to review this server!