loading…
Search for a command to run...
loading…
Provides AI assistants with read-only access to inspect database schemas, preview data, and run safe queries across PostgreSQL, MySQL, MongoDB, and SQL Server.
Provides AI assistants with read-only access to inspect database schemas, preview data, and run safe queries across PostgreSQL, MySQL, MongoDB, and SQL Server. It enables AI tools to understand database structures and relationships automatically to generate more accurate code.
npm version npm downloads License: MIT Website
DLP lets your AI coding assistant read your database — so it writes better code, faster.
Ever had your AI assistant guess what your database looks like, only to generate wrong column names or miss relationships? DLP solves that. It gives tools like Claude Code, Cursor, VS Code Copilot, and antigravity (Gemini) read-only access to your database schema and data — no debug code needed, no copy-pasting table structures into chat.
🌐 dlp-mcp.vercel.app — Give Your AI Database Eyes
Think of DLP as a bridge between your AI assistant and your database. Once set up:
Example: Instead of telling your AI "I have a users table with id, name, email columns...", it can just look at the database itself.
DLP uses the Model Context Protocol (MCP) — an open standard that lets AI assistants use external tools. When you set up DLP:
DATABASE_URL from your projectYour AI Assistant <--> DLP (MCP Server) <--> Your Database
(Claude, etc.) (runs locally) (Postgres, MySQL, etc.)
npm install database-lookup-protocol
Or use it directly without installing (via npx):
npx database-lookup-protocol set cursor
Setting up DLP takes two steps and under a minute.
.envMake sure your project has a .env file with your database connection. If you already have one (most projects do), you're good — skip to Step 2.
Option A: Single connection string (most common)
DATABASE_URL=postgresql://user:password@localhost:5432/mydb
Option B: Individual variables (if your project uses separate host/user/password vars)
# PostgreSQL
PG_HOST=localhost
PG_PORT=5432
PG_DATABASE=mydb
PG_USER=admin
PG_PASSWORD=secret
# MySQL
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_DATABASE=mydb
MYSQL_USER=admin
MYSQL_PASSWORD=secret
# MongoDB
MONGODB_URI=mongodb://localhost:27017/mydb
# SQL Server
MSSQL_HOST=localhost
MSSQL_PORT=1433
MSSQL_DATABASE=mydb
MSSQL_USER=admin
MSSQL_PASSWORD=secret
DLP automatically detects whichever format you use — DATABASE_URL or individual variables.
Not sure what your DATABASE_URL looks like? See the Connection String Formats section below for examples for each database.
Open a terminal inside your project folder (where your .env file is) and run:
# For antigravity (Gemini)
npx dlp set antigravity
# For Cursor
npx dlp set cursor
# For VS Code
npx dlp set vscode
# For Claude Code
npx dlp set claude
# For all IDEs at once
npx dlp set all
That's it! Restart your IDE and DLP is ready to use.
What just happened? The
dlp setcommand read your database connection variables from your project's.envfile (eitherDATABASE_URLor individual vars likePG_HOST,MYSQL_HOST, etc.) and wrote the MCP configuration to your IDE's global config directory. Your AI assistant will now see DLP as an available tool.
Once set up, your AI assistant automatically has access to four database tools. You don't need to do anything special — just ask questions about your database naturally:
Your AI will use DLP tools behind the scenes to answer these questions.
| Tool | What it does | Example use |
|---|---|---|
dlp_get_schema |
Shows all tables, columns, types, keys, and relationships | "What does my database look like?" |
dlp_describe_table |
Shows detailed info about one table — column types, indexes, defaults, constraints | "Tell me about the orders table" |
dlp_preview_table |
Shows sample rows from a table (up to 20 rows) | "Show me some data from the users table" |
dlp_safe_query |
Runs a read-only SQL SELECT query (must include LIMIT, max 20 rows) | "How many orders were placed today?" |
Tip: You can tell your AI: "Use
dlp_get_schemato understand the database before writing any queries" — this gives it the full picture upfront.
DLP works with five popular databases. You only need to install the driver for the database you're using:
| Database | Install the driver | Status |
|---|---|---|
| PostgreSQL | npm install pg |
Production-ready |
| MySQL / MariaDB | npm install mysql2 |
Production-ready |
| MongoDB | npm install mongodb |
Production-ready |
| Microsoft SQL Server | npm install mssql |
Production-ready |
| Prisma (any DB Prisma supports) | npm install @prisma/client |
Production-ready |
Note: If your project already uses one of these drivers (check your
package.json), you don't need to install anything extra.
Here's what DATABASE_URL looks like for each database:
# PostgreSQL
DATABASE_URL=postgresql://username:password@hostname:5432/database_name
# MySQL / MariaDB
DATABASE_URL=mysql://username:password@hostname:3306/database_name
# MongoDB
DATABASE_URL=mongodb://username:password@hostname:27017/database_name
# Microsoft SQL Server
DATABASE_URL=mssql://username:password@hostname:1433/database_name
# Prisma (uses whatever your Prisma schema defines)
DATABASE_URL=postgresql://username:password@hostname:5432/database_name
Common hosted database examples:
# Supabase (PostgreSQL)
DATABASE_URL=postgresql://postgres.[project-ref]:[password]@aws-0-[region].pooler.supabase.com:6543/postgres
# PlanetScale (MySQL)
DATABASE_URL=mysql://[user]:[password]@[host]/[database]?ssl={"rejectUnauthorized":true}
# MongoDB Atlas
DATABASE_URL=mongodb+srv://[user]:[password]@[cluster].mongodb.net/[database]
# Neon (PostgreSQL)
DATABASE_URL=postgresql://[user]:[password]@[host].neon.tech/[database]?sslmode=require
# Railway (PostgreSQL)
DATABASE_URL=postgresql://postgres:[password]@[host].railway.app:5432/railway
dlp set write configs?When you run npx dlp set <ide>, it writes the MCP configuration to your IDE's global config directory in your home folder (~ = C:\Users\YourName on Windows, /Users/YourName on Mac, /home/YourName on Linux):
| IDE | Config file location |
|---|---|
| antigravity (Gemini) | ~/.gemini/antigravity/mcp_config.json |
| Cursor | ~/.cursor/mcp_config.json |
| VS Code | ~/.vscode/mcp_config.json |
| Claude Code | ~/.mcp.json |
Switching projects? Just cd into the new project, and run npx dlp set <ide> again. It will update the config with the new project's database connection.
DLP is designed to be safe by default:
postbuild scriptDLP includes a postbuild npm script that adds a shebang line (#!/usr/bin/env node) to the CLI entry point file. This is a standard practice for Node.js command-line tools to work correctly on Unix-like systems (Linux, macOS).
What it does:
// Checks if dist/cli/index.js exists
// Reads the compiled CLI file
// Adds #!/usr/bin/env node at the top if it's not already there
// Writes it back to disk
This script runs automatically after TypeScript compilation (npm run build) and is necessary for the dlp command to be executable. The script only reads and writes to the project's own build output — it doesn't access external files, network resources, or perform any malicious operations.
Why it's needed: TypeScript doesn't preserve shebang lines during compilation, so we add it back afterwards. Without this line, the dlp command wouldn't work when installed globally or used via npx.
When you switch to a different project with a different database:
.env file with its database connection (DATABASE_URL or individual vars)npx dlp set <ide> againThe config will be updated with the new database connection.
Most users don't need this. The MCP mode (set up above) is the recommended way to use DLP. HTTP mode is for custom integrations, scripts, or tools that can't use MCP.
If you want to run DLP as a standalone HTTP API:
# Add these to your .env
DATABASE_URL=postgresql://user:pass@localhost:5432/mydb
DLP_API_KEY=your-secret-key
# Start the server
npx dlp start
The server runs on http://localhost:3434. All requests go to POST /protocol with an Authorization: Bearer <your-api-key> header.
Example requests:
# Get database schema
curl -X POST http://localhost:3434/protocol \
-H "Authorization: Bearer your-secret-key" \
-H "Content-Type: application/json" \
-d '{"action": "get_schema", "schema": "public"}'
# Preview table data
curl -X POST http://localhost:3434/protocol \
-H "Authorization: Bearer your-secret-key" \
-H "Content-Type: application/json" \
-d '{"action": "preview_table", "table": "users", "limit": 5}'
# Describe a table
curl -X POST http://localhost:3434/protocol \
-H "Authorization: Bearer your-secret-key" \
-H "Content-Type: application/json" \
-d '{"action": "describe_table", "table": "users"}'
# Run a read-only query
curl -X POST http://localhost:3434/protocol \
-H "Authorization: Bearer your-secret-key" \
-H "Content-Type: application/json" \
-d '{"action": "safe_query", "query": "SELECT id, email FROM users LIMIT 5"}'
Rules: Only SELECT queries are allowed. Every query must include a LIMIT clause. Maximum 20 rows returned.
npx dlp set <ide> Read DB vars from .env and configure your IDE
npx dlp set all Configure all supported IDEs at once
npx dlp start Start HTTP API server on port 3434
npx dlp start --mcp Start MCP stdio server
npx dlp mcp Same as "start --mcp"
"DLP tools not showing up in my IDE"
npx dlp set <ide> from inside your project folder (where .env is).env file contains a valid DATABASE_URL"Cannot connect to database"
DATABASE_URL is correct by testing the connection with your database clientnpm install pg for PostgreSQL, etc.)"Permission denied" or "Config file error"
npx dlp set <ide> again — it will overwrite any broken config filesSwitching to a different database?
DATABASE_URL in your project's .envnpx dlp set <ide> againContributions are welcome! Here's how to get started:
git clone https://github.com/your-username/Database-Lookup-Protocol.gitgit checkout -b feat/your-featuresrc/ directorynpm run buildTo add support for a new database:
src/adapters/ that implements the DLPAdapter interfacegetSchema(), previewTable(), describeTable(), and safeQuery()src/cli/index.tsdlp set automatically reads all database-related variables from your project's .env — not just DATABASE_URL. Here's the full list of variables it detects and writes into your IDE config:
| Variable | Database | Description |
|---|---|---|
DATABASE_URL |
Any | Full connection string (auto-detects DB type from scheme) |
DB_TYPE |
Any | Explicitly set DB type: postgres, mysql, mongodb, mssql, prisma |
| PostgreSQL | ||
PG_HOST / PGHOST |
PostgreSQL | Database host |
PG_PORT / PGPORT |
PostgreSQL | Database port (default: 5432) |
PG_DATABASE / PGDATABASE |
PostgreSQL | Database name |
PG_USER / PGUSER |
PostgreSQL | Username |
PG_PASSWORD / PGPASSWORD |
PostgreSQL | Password |
PG_SSL |
PostgreSQL | Set to true to enable SSL |
| MySQL / MariaDB | ||
MYSQL_HOST |
MySQL | Database host |
MYSQL_PORT |
MySQL | Database port (default: 3306) |
MYSQL_DATABASE |
MySQL | Database name |
MYSQL_USER |
MySQL | Username |
MYSQL_PASSWORD |
MySQL | Password |
| MongoDB | ||
MONGODB_URI |
MongoDB | Full MongoDB connection URI |
MONGODB_DATABASE |
MongoDB | Database name (default: parsed from URI or test) |
| SQL Server | ||
MSSQL_HOST |
MSSQL | Database host |
MSSQL_PORT |
MSSQL | Database port (default: 1433) |
MSSQL_DATABASE |
MSSQL | Database name |
MSSQL_USER |
MSSQL | Username |
MSSQL_PASSWORD |
MSSQL | Password |
MSSQL_ENCRYPT |
MSSQL | Set to false to disable encryption |
MSSQL_TRUST_CERT |
MSSQL | Set to true to trust self-signed certificates |
How it works: When you run npx dlp set <ide>, it scans your .env for all of the above variables, and writes every one it finds into the IDE's MCP config env block. That way, when the IDE spawns the DLP MCP server, all your database credentials are available — regardless of whether you use a single DATABASE_URL or separate variables.
MIT - see LICENSE for details.
Built by Kalyan Gupta & Arghajit Saha | 🌐 Website | Report a bug | npm package
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"database-lookup-protocol-dlp": {
"command": "npx",
"args": []
}
}
}