About @rog0x/mcp-database-tools
@rog0x/mcp-database-tools is an MCP server for AI agents working with SQL, with operations performed on SQL text rather than a live database. It formats and explains queries, analyzes schemas, builds queries from natural language, and generates migrations.
Key features
- 01Format SQL for MySQL, PostgreSQL, and SQLite
- 02Explain queries and suggest optimizations
- 03Extract schema details and create Mermaid ER diagrams
- 04Build SQL from natural language
- 05Generate forward and rollback migrations
Use cases
- 01Prettify a SQL statement before review
- 02Understand query structure and possible optimizations
- 03Map tables and relationships from CREATE TABLE statements
- 04Draft queries from a textual description
- 05Compare schema versions and produce migrations
MCP support
Exposes SQL and database-analysis tools to MCP clients. The tools operate on SQL text and do not require a database connection.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEmcp-database-tools
MCP server providing SQL and database tools for AI agents. All analysis is performed on SQL text — no actual database connection required.
Tools
sql_format
Format and prettify SQL queries with proper indentation, uppercased keywords, and aligned columns. Supports MySQL, PostgreSQL, and SQLite syntax.
sql_explain
Take a SQL query and explain what it does in plain English, step by step. Identifies query type, tables, columns, conditions, and provides optimization tips.
schema_analyze
Parse CREATE TABLE statements to extract tables, columns, types, constraints, foreign keys, and indexes. Generates an ER diagram in Mermaid format.
query_build
Build SQL queries from natural language descriptions. Supports common patterns like filtering by date, aggregation, joins, ordering, and pagination.
migration_generate
Compare two schemas (old vs new CREATE TABLE statements) and generate ALTER TABLE migration statements. Produces both up (forward) and down (rollback) migrations.
Installation
npm install
npm run build
Usage
With Claude Desktop
Add to your Claude Desktop config (claude_desktop_config.json):
{
"mcpServers": {
"database-tools": {
"command": "node",
"args": ["path/to/mcp-database-tools/dist/index.js"]
}
}
}
Standalone
npm start
Development
npm run build # Compile TypeScript
npm start # Run the server
License
MIT
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.