Natural language database querying powered by Archestra and the Model Context Protocol.
2 Fast 2 MCP Hackathon Entry | Built on Archestra
Ask questions in plain English. Get SQL results instantly. Visualize your schema. All secured by Archestra.
Demo here: https://youtu.be/cCExnJntogk
QueryMaster lets anyone query a PostgreSQL database using plain English. No SQL knowledge required.
User: "Show me the top 10 customers by total spend"
QueryMaster:
1. Calls introspect_schema -> understands tables & relationships
2. Generates SQL -> SELECT c.name, SUM(o.total) ...
3. Executes safely -> read-only, timeout-protected
4. Returns formatted results with insights
User (natural language) --> Archestra Chat UI --> QueryMaster Agent
|
MCP Gateway (secure)
|
QueryMaster MCP Server
/ | | \ \
introspect query explain list visualize
_schema _db _results _dbs _schema
|
PostgreSQL
QueryMaster is a single, focused MCP server deployed through Archestra's Kubernetes orchestrator. The LLM agent (running in Archestra) decides which tools to call and in what order -- the MCP server just provides the capabilities.
| Tool | Description |
|---|---|
introspect_schema |
Discovers tables, columns, types, foreign keys, and sample data |
query_database |
Executes safe, read-only SQL queries with timeout and row limits |
explain_results |
Analyzes query performance with PostgreSQL EXPLAIN and optimization tips |
list_databases |
Shows configured database connections and their status |
visualize_schema |
Generates Mermaid ER diagrams for visual schema exploration |
- Read-only enforcement: Only SELECT/WITH queries allowed. INSERT, UPDATE, DELETE, DROP, and all other mutations are blocked at parse time.
- Statement timeout: Queries that run too long are automatically killed (default: 30s).
- Row limit: Results capped at 1,000 rows to prevent memory issues.
- Single statement: Multi-statement queries (SQL injection attempts) are rejected.
- No credential exposure: Database URLs are stored as K8s secrets, never returned to the LLM.
- Tool invocation policies: Archestra's dual-LLM security blocks untrusted contexts from executing queries.
- Cost limits: Token usage caps prevent runaway LLM costs.
- Audit logging: Every tool call is logged with full context for compliance.
- MCP Gateway auth: Bearer token / OAuth 2.1 authentication on the gateway.
This project deeply leverages Archestra's platform capabilities:
- MCP Catalog & Registry -- QueryMaster is registered as a reusable MCP server that any team can install with their own DATABASE_URL.
- Kubernetes Orchestrator -- The MCP server runs as a K8s Deployment managed by Archestra's orchestrator, with automatic secret management.
- Streamable HTTP Transport -- Production-grade HTTP transport with session management, not just stdio.
- Chat UI -- Zero frontend code needed. Archestra provides the ChatGPT-style interface.
- Security Policies -- Tool invocation policies and trusted data evaluation protect against prompt injection.
- Cost Controls -- Token limits and usage tracking per agent.
- Observability -- Tool call logs, execution metrics, and traces via Archestra's built-in monitoring.
- Archestra running locally (
tilt up) - Docker Desktop with Kubernetes enabled
- Node.js 20+
cd querymaster-mcp
docker compose up -d postgres-demoThis starts PostgreSQL with a pre-seeded e-commerce dataset (6 tables, 512 rows).
npm install
npm run build
docker build -t querymaster-mcp:latest .In the Archestra UI (http://localhost:3000):
- Go to MCP Registry > Add the
querymaster-mcpcatalog entry - Install with DATABASE_URL:
postgresql://querymaster:querymaster_dev@host.docker.internal:5433/querymaster_demo - Create an agent, assign all 5 QueryMaster tools
- Set the system prompt (see
system-prompt.md) - Chat!
"How many tables are in the database?"
"Show me the top 10 customers by total spend"
"Which product categories have the highest revenue?"
"What's the average order value per month in 2025?"
"Show me products with an average rating below 4"
"Compare revenue across countries"
"Visualize the database schema"
"Explain the performance of: SELECT * FROM orders JOIN customers ON ..."
- Runtime: Node.js 20, TypeScript
- MCP SDK:
@modelcontextprotocol/sdkv1.26+ - Transport: Streamable HTTP (port 8080)
- Database: PostgreSQL via
pgdriver - Container: Archestra MCP Server Base Image
- Orchestration: Archestra + Kubernetes
querymaster-mcp/
src/
index.ts # MCP server entry (streamable-http)
config.ts # Environment configuration
tools/
introspect-schema.ts # Schema discovery tool
query-database.ts # Safe SQL execution
explain-results.ts # EXPLAIN ANALYZE tool
list-databases.ts # Database listing
visualize-schema.ts # Mermaid ER diagram generator
db/
connection.ts # PostgreSQL connection pool
safety.ts # SQL validation (read-only enforcement)
seed/
init.sql # E-commerce demo dataset
Dockerfile # Based on Archestra MCP base image
docker-compose.yml # Local dev database
MIT
