Skip to main content
Glama
cpenniman12

text2sql-mcp

by cpenniman12

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

Postgres

uvx 'text2sql-mcp[postgres]'

MySQL

uvx 'text2sql-mcp[mysql]'

Snowflake

uvx 'text2sql-mcp[snowflake]'

BigQuery

uvx 'text2sql-mcp[bigquery]'

OpenAI models

add openai, e.g. uvx 'text2sql-mcp[postgres,openai]'

Related MCP server: Data Agent Connector

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

Available Tools

1 tool
queryA

Ask the database a natural-language question.

The agent explores the schema, writes SQL, executes it, and self-corrects on errors before returning. Read-only — only SELECT-style statements.

Args: question: The natural-language question, e.g. "top 5 customers by revenue". max_rows: Cap on rows returned in data. Defaults to 100.

Returns: dict with: sql: the final verified SQL data: list of row dicts (capped at max_rows) error: error message if execution failed, else None row_count: number of rows in data tool_calls_made: how many SQL calls the agent made while exploring

ParametersJSON Schema
NameRequiredDescriptionDefault
max_rowsNo
questionYes

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden and does so thoroughly. It discloses that the agent explores the schema, writes and executes SQL, self-corrects on errors, caps results at max_rows, and returns a detailed dict including sql, data, error, row_count, and tool_calls_made. This is exemplary behavioral transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-organized with a lead sentence for the main purpose, a brief behavioral paragraph, and clearly labeled Args/Returns sections. Every sentence adds useful information; nothing is redundant or filler. The format is long enough to be complete but remains scannable.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, so the description's detailed Returns section is essential and well executed. It explains the return dict fields, row count, error behavior, and internal tool calls. Combined with the parameter explanations and read-only guarantee, the description fully covers what an agent needs to invoke and interpret the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Although the schema only lists types and a default, the description explains the meaning of each parameter: 'question' is a natural-language query with an example, and 'max_rows' caps the returned data with a default of 100. It also clarifies how max_rows affects the output, which is additional semantic value beyond the raw schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: 'Ask the database a natural-language question.' It goes further to describe the internal process (explore schema, write SQL, execute, self-correct) and explicitly scopes it as read-only with SELECT-style statements. This makes the purpose unmistakable even without sibling tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description establishes clear context by presenting the tool as a natural-language interface to the database and by noting that it only executes SELECT statements. It implicitly says not to use it for writes or mutations, though it does not explicitly name alternative tools or spell out when-not-to-use scenarios in more detail.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 1 tool updatev0.1.2
    • First observedquery

TDQS

A4.7/5.0
Disambiguation5/5

With only one tool, there is no possibility of confusion between overlapping functions. The tool's purpose is clearly defined for natural-language database queries, making selection trivial.

Naming Consistency5/5

The single tool named 'query' is simple, intuitive, and uses a clear verb form. While there is no pattern to compare, the naming is unambiguous and follows common conventions for a query action.

Tool Count3/5

The server has just one tool, which feels thin for a database interaction service. However, the tool is comprehensive and handles schema exploration, SQL generation, execution, and self-correction internally, so it may be sufficient for its narrow scope.

Completeness5/5

The tool covers the full natural-language query lifecycle: it interprets the question, writes SQL, executes it, and returns results with error handling. As a read-only query tool, it fully addresses the stated purpose without obvious gaps.

Maintenance

ActivityMaintained
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    C
    maintenance
    Enables AI agents to interact with Microsoft SQL Server databases via MCP, supporting table listing, schema retrieval, and CRUD operations.
    3
    1
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables SQL agents to connect to any SQLAlchemy-supported database via MCP, providing read-only SQL querying, automatic table summarization, and column content search.
    4
    Apache 2.0
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to connect to Microsoft SQL Server via the MCP protocol, supporting database schema queries, data reading, and arbitrary SQL execution.
    -
  • F
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to query a SQLite database using natural language through the Model Context Protocol (MCP). Includes security guardrails that block destructive SQL operations.
    -

Latest Blog Posts

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