SQL Generative MCP
Allows querying a PostgreSQL database using natural language, with results returned as structured XML.
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., "@SQL Generative MCPShow 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.
| Name | Required | Description | Default |
|---|---|---|---|
| user_query | Yes | The database query request in plain English (e.g. 'Show a list of all expense items'). |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries full burden. It mentions returning structured XML but fails to disclose whether the query modifies data, requires authentication, or the database state. Behavioral traits like read-only nature or error handling are not addressed.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence that front-loads the purpose. Every word is necessary, and there is no redundancy or wasted text.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the lack of annotations and sibling tools, the description is insufficient. It does not address important context such as query timeout, security considerations, or the nature of the output schema. The presence of an output schema is noted but not explained.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, with the parameter `user_query` fully described in the schema including an example. The description does not add significant semantic value beyond what the schema already provides, so a baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool runs a plain-English natural language query against a database and returns structured XML. The verb 'run' and resource 'database query' are specific, and the output format is explicitly mentioned. Without siblings, no differentiation needed.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit guidance on when to use this tool versus alternatives. Since there are no sibling tools, the lack of alternatives is less critical, but there is no mention of prerequisites or limitations (e.g., database connection status). Usage is implied from the description.
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 tool update
v0.1.0- First observed
query_database
TDQS
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
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
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Generate, fix, explain and run read-only SQL on PostgreSQL, MySQL and SQL Server
1Ask questions in plain language, get answers from your business database. No SQL required.
1Ask business questions in plain English. Get instant answers from your database, no SQL needed.
Related MCP Servers
- AlicenseAqualityAmaintenanceEnables read-only interaction with PostgreSQL databases through natural language queries, supporting dynamic connections and secure query validation.31252MIT
- AlicenseNot gradedqualityDmaintenanceEnables secure, read-only PostgreSQL database interaction through natural language, with automatic database discovery and connection management.2MIT
- FlicenseNot gradedqualityCmaintenanceConverts natural language to safe SQL queries for PostgreSQL databases with read-only access and multi-layer security validation. Provides tools for running validated SELECT queries, retrieving schema, and sampling table data.-
- AlicenseNot gradedqualityCmaintenanceEnables read-only interaction with PostgreSQL databases, allowing natural language queries for listing schemas, tables, describing columns, and executing SELECT/WITH statements.83MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- 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/Denuwanhh/sql-generative-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server