Query Analysis
Submit any SQL query and get a detailed breakdown of what it does, potential performance issues, and estimated cost relative to table size.
An MCP server that gives AI agents 8 tools to analyze, optimize, and rewrite your database queries. Explain plans, index recommendations, slow query detection, and schema inspection — all callable programmatically from any AI agent.
$25/mo. Install in 60 seconds.
The Problem
Slow database queries are the leading cause of application performance problems — and they're invisible until users complain. Most developers write queries that work but never check if they're optimal, missing indexes, or causing full table scans on millions of rows.
The Solution
TRUSS DB Query MCP is an MCP server that AI agents use to diagnose and fix database performance problems. No manual EXPLAIN parsing. No guessing at indexes. Your agent analyzes, recommends, and rewrites — you review and apply.
Submit any SQL query and get a detailed breakdown of what it does, potential performance issues, and estimated cost relative to table size.
Run EXPLAIN or EXPLAIN ANALYZE and get a structured, human-readable breakdown of the execution plan with cost estimates and bottleneck identification.
Scan pg_stat_statements or the slow query log to surface the top queries by execution time, call count, and total load on your database.
Analyze query patterns and table statistics to recommend which indexes to create, modify, or drop. Includes estimated read/write impact for each suggestion.
Retrieve table structure, column types, constraints, existing indexes, and row counts. Gives agents full context before suggesting query optimizations.
Given an inefficient query, return an optimized rewrite. Handles N+1 patterns, unnecessary subqueries, missing JOINs, and anti-patterns like SELECT *.
Pull vacuum stats, dead tuple counts, bloat estimates, and autovacuum schedules for any table. Diagnose hidden performance drags before they cause downtime.
Before executing any write query, check for missing WHERE clauses, potential full-table deletes/updates, lock contention risks, and unsafe DDL operations.
How It Works
TRUSS DB Query MCP is an MCP server. Install via npm, add your database connection string, and your AI agents can start analyzing queries immediately.
One npm command. Add your database connection string to the MCP env config. Supports PostgreSQL, MySQL, and SQLite connection strings.
Point Claude Code, Cursor, or any MCP-compatible agent at the server. The 8 tools appear immediately in your agent's tool list.
Tell your AI agent "analyze the slow queries in this app" or "suggest indexes for this query." The agent calls the MCP tools, gets structured results, and gives you actionable recommendations.
# Install
npx truss-db-mcp
# Claude Code / Cursor MCP config (~/.claude/mcp.json or .cursor/mcp.json)
{
"mcpServers": {
"db-query": {
"command": "npx",
"args": ["truss-db-mcp"],
"env": {
"DATABASE_URL": "postgresql://user:pass@localhost/mydb",
"TRUSS_API_KEY": "your-api-key"
}
}
}
}
Pricing
One plan. No usage limits, no metered queries. Optimize as many queries as you want for a flat $25/mo.
Unlimited query analysis for one developer or team environment.
Tool Reference
FAQ
What databases does the DB Query MCP server support?
TRUSS DB Query MCP supports PostgreSQL, MySQL, and SQLite. Connect via a standard connection string in your MCP environment config. PostgreSQL support includes pg_stat_statements integration for richer slow query data.
How does AI query optimization work with MCP?
Your AI agent calls tools like analyze_query, get_explain_plan, and suggest_indexes. The MCP server connects to your database, runs EXPLAIN, analyzes execution statistics, and returns structured results the agent can reason about and act on.
Is my database data sent to any external service?
No. The MCP server runs locally in your environment. Only query metadata, execution plans, and schema information are analyzed — not your actual row data. Your database credentials stay in your local environment variables.
Does it work with Claude Code and Cursor?
Yes. TRUSS DB Query MCP is a standard MCP server that works with any MCP-compatible client: Claude Code, Claude Desktop, Cursor, VS Code Copilot, and custom agents. Add it to your mcpServers config and start using it immediately.
Give your AI agents the tools to find, analyze, and fix database performance issues. Install in 60 seconds.
Get DB Query MCP — $25/moFlat $25/mo. No usage limits. Cancel anytime.