SQL Generative MCP
Allows querying a PostgreSQL database using natural language, with results returned as structured XML.
Click on "Deploy 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., "@SQL Generative MCP Show me all expenses from last month"
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.
SQL Generative MCP
An interactive Model Context Protocol (MCP) server that translates plain English queries into SQLAlchemy operations, queries a PostgreSQL database under strict read-only execution modes, and returns the query results formatted as structured XML.
π Key Features
Natural Language DB Querying: Translate user queries in plain English to corresponding database results dynamically.
SQLAlchemy Table Reflection: Reflects database schemas dynamically across multiple namespaces using standard ORM capabilities (no direct
pg_dumpclient tools needed).Enforced Read-Only Transactions: Database URL connections are injected with query options (
?options=-c%20default_transaction_read_only%3Don) to natively block any modifications (CREATE,UPDATE,DELETE,DROP) at the database engine level.Dynamic XML Response Formatting: Converts database records into a clean, well-formed XML structure automatically compiled by Claude.
FastMCP Protocol Integration: Built on top of the standard
fastmcpSDK to run as a local stdio MCP server.
Related MCP server: PostgreSQL MCP Server
ποΈ Architecture

π οΈ Setup & Installation
Prerequisites
Python 3.13+
uv (fast Python package installer and resolver)
PostgreSQL Server with an active database
1. Project Initialization & Dependencies
Initialize the project environment and install dependencies:
uv sync2. Environment Configuration
Create a .env file in the root directory and configure the database URL along with your Anthropic API key:
# Database connection for local development (enforced read-only mode via query options)
DATABASE_URL=postgresql://postgres:admin@localhost:5432/expence_db?options=-c%20default_transaction_read_only%3Don
# Anthropic API Key
ANTHROPIC_API_KEY="your-anthropic-api-key-here"π Running the Server
Start the stdio-based MCP server locally:
uv run python main.pyπ Integration with Claude Desktop
To configure Claude Desktop to use this database query tool on Windows, configure your claude_desktop_config.json file.
Press
Win + R, type%APPDATA%\Claudeand press Enter.Open
claude_desktop_config.jsonand insert the following server config:
{
"mcpServers": {
"db-query-server": {
"command": "uv",
"args": [
"--directory",
"c:/Projects/generative-tool",
"run",
"python",
"main.py"
]
}
}
}Restart Claude Desktop. You will see the tools icon π in the chat input area.
π Usage Examples
Once connected, you can ask Claude queries like:
"Show a list of all tables in the database"
"How many expense entries are recorded for AWS?"
"Show a list of all rows in table exp_expence_core_t"
The server returns results formatted as well-formed XML:
<data>
<item>
<exp_expence_core_id>26</exp_expence_core_id>
<title>AWS Bill</title>
<amount>100.00</amount>
</item>
</data>Available Tools
1 toolquery_databaseB
Run a plain-English natural language query against the connected database and return the result as structured XML.
Inputs: user_query (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 1 tool
Only one tool exists, so there is no possibility of confusion with other tools.
The single tool name, 'query_database', follows a clear verb_noun pattern, and consistency is trivially maintained with one tool.
With only one tool, the server feels thin for a database interaction service, though it may suffice as a single natural language query endpoint.
The server only provides querying, lacking common database operations like schema inspection, data modification, or DDL, leaving significant gaps in typical database workflows.
Maintenance
Related MCP Connectors
Query PostgreSQL databases in plain English β LLM-generated, safety-validated SQL.
Query, explore, and manage your databases through natural conversation.
Ask your databases questions in plain English, run read-only SQL and set up data alerts.
Ask questions in plain language, get answers from your business database. No SQL required.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables read-only interaction with PostgreSQL databases through natural language queries, supporting dynamic connections and secure query validation.3157 npm2MIT
- AlicenseNot gradedqualityDmaintenanceEnables secure, read-only PostgreSQL database interaction through natural language, with automatic database discovery and connection management.2MIT
- AlicenseNot gradedqualityDmaintenanceEnables read-only interaction with PostgreSQL databases, allowing natural language queries for listing schemas, tables, describing columns, and executing SELECT/WITH statements.236 npmMIT
- FlicenseAqualityCmaintenanceEnables users to interact with PostgreSQL databases using natural language, converting questions into validated, safe SQL queries and returning execution results with confidence scoring.1-