npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

database-admin-mcp

v1.0.1

Published

MCP server for database administration - schema inspection, query optimization, data exploration, and migration helpers for PostgreSQL and MySQL

Readme

Database Admin MCP Server

A Model Context Protocol (MCP) server for database administration. Provides AI assistants with tools for schema inspection, query optimization, data exploration, and migration helpers.

Supports PostgreSQL and MySQL.

Features

  • Schema Inspection: List tables, describe columns, view indexes and foreign keys
  • Data Exploration: Sample rows from tables with configurable limits
  • Query Execution: Run SQL queries (read-only by default for safety)
  • Index Analysis: Find unused indexes, missing FK indexes, get optimization suggestions
  • Query Plans: EXPLAIN queries with cost analysis and recommendations
  • Migration Generation: Generate up/down migration scripts for schema changes
  • Relationship Mapping: Visualize foreign key relationships across tables
  • Safety First: Read-only mode by default, write operations require explicit opt-in

Installation

npm install -g database-admin-mcp

Or use with npx:

npx database-admin-mcp

Configuration

Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "database": {
      "command": "npx",
      "args": ["database-admin-mcp"],
      "env": {
        "DATABASE_URL": "postgresql://user:pass@localhost:5432/mydb"
      }
    }
  }
}

Environment Variables

Connection (choose one method):

Using connection string:

DATABASE_URL=postgresql://user:pass@localhost:5432/dbname
# or
DATABASE_URL=mysql://user:pass@localhost:3306/dbname

Using individual variables:

DB_TYPE=postgres     # or mysql
DB_HOST=localhost
DB_PORT=5432         # 3306 for MySQL
DB_NAME=mydb
DB_USER=myuser
DB_PASSWORD=mypassword
DB_SSL=true          # optional

Safety settings:

DB_READ_ONLY=true    # Default: true (prevents INSERT/UPDATE/DELETE)
DB_MAX_ROWS=1000     # Default: 1000 (max rows returned per query)

Available Tools

Schema Tools

| Tool | Description | |------|-------------| | list_tables | List all tables with size and index count | | describe_table | Get columns, types, indexes, and foreign keys | | get_relationships | View all foreign key relationships as a graph | | get_connection_info | Show current connection settings |

Data Tools

| Tool | Description | |------|-------------| | sample_data | Retrieve sample rows from a table | | execute_query | Run SQL queries (respects read-only mode) |

Optimization Tools

| Tool | Description | |------|-------------| | analyze_indexes | Get index usage stats and suggestions | | explain_query | Get query execution plan with recommendations |

Migration Tools

| Tool | Description | |------|-------------| | generate_migration | Generate up/down SQL for schema changes |

Examples

List all tables

"Show me all tables in the database"

Describe a table

"What columns does the users table have?"

Sample data

"Show me 5 sample rows from the orders table"

Analyze indexes

"Are there any unused indexes on the products table?"

Generate migration

"Generate a migration to add an email column to the customers table"

Query optimization

"Why is this query slow: SELECT * FROM orders WHERE customer_id = 123"

Safety Features

  1. Read-only by default: Write operations (INSERT, UPDATE, DELETE, DROP, etc.) are blocked unless DB_READ_ONLY=false

  2. Row limits: Results are limited to DB_MAX_ROWS (default 1000) to prevent memory issues

  3. Connection pooling: Efficient connection management with automatic cleanup

  4. No credentials in output: Connection info tool hides passwords

Supported Databases

PostgreSQL

  • Full feature support
  • Schema-aware (supports multiple schemas)
  • Uses pg_stat_user_indexes for index analysis
  • JSON query plans with cost estimates

MySQL

  • Full feature support
  • Uses information_schema for metadata
  • SHOW TABLE STATUS for storage analysis
  • Standard EXPLAIN output

License

MIT License - see LICENSE