← Back to Database MCP Server

Install Database MCP Server

Pick your client, copy the command, done.

1

Add it to Claude Code

claude mcp add -e "DATABASE_URL=${DATABASE_URL}" database-mcp -- npx tsx PATH_TO_PROJECT/src/index.ts
Required:DATABASE_URL+ 3 optional

Environment Variables

Set these before running Database MCP Server.

VariableDescriptionRequired
DATABASE_URLConnection string for the databaseYes
DB_TYPEDatabase type (default: postgres)No
MIGRATIONS_ENABLEDAuto-record DDL changes to migration filesNo
MIGRATIONS_DIRDirectory for migration filesNo

Available Tools (6)

Once configured, Database MCP Server gives your AI agent access to:

db_list_schemasList all schemas in the database.
db_create_tableCreate a new table in the database.
db_queryExecute a SELECT query.
db_execute_sqlExecute arbitrary SQL commands.
db_create_userCreate a new database user with login privileges.
db_apply_all_migrationsApply all pending migrations to synchronize the database.

Try It Out

After setup, try these prompts with your AI agent:

List all the tables currently in my public schema.
Create a new table named 'users' with columns for id, username, and email.
Execute a query to find all users who signed up in the last 30 days.
Grant read-only access to the 'reports' table for the 'analyst' role.
Apply all pending database migrations to update the schema.
Prerequisites & system requirements
  • An MCP-compatible client (Claude Code, Cursor, Windsurf, Claude Desktop, or Codex)
  • Node.js 18+ with npm/npx installed
  • DATABASE_URL — Connection string for the database
Alternative installation methods

npx

npx tsx src/index.ts

Keep this setup from going cold

Save the docs, env vars, and workflow around Database MCP Server in Conare so Claude Code, Codex, and Cursor remember it next time.

Remember this setup