text2sql-mcp
Uses OpenAI's language model to convert natural language questions into SQL queries for execution on a connected database.
Connects to a PostgreSQL database to execute generated SQL queries and return results.
Connects to a SQLite database to execute generated SQL queries and return results.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@text2sql-mcpWhat was the total sales last quarter?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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-mcpFor other databases or LLM providers, install with the matching extra so the right driver gets installed:
You want… | Install command |
SQLite (default) |
|
Postgres |
|
MySQL |
|
Snowflake |
|
BigQuery |
|
OpenAI models | add |
Related MCP server: mcp-server-mssql
Configure
Set environment variables in your MCP client config:
Variable | Required | Description |
| yes | SQLAlchemy URL, e.g. |
| yes | LLM provider key |
| no | LangChain model id (default: |
| no | Business rules / hints, e.g. "Revenue = net of refunds." |
| no | Path to a scenarios.md file for the agent's |
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_KEYTools
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
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/cpenniman12/text2sql-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server