Registry / database / postgres-mysql-mcp-server

postgres-mysql-mcp-server

JSON →
library1.0.6jsnpmunverified

An MCP server for querying PostgreSQL and MySQL databases, currently at version 1.0.6. It enables AI assistants in editors like Cursor and Windsurf to explore database schemas, execute queries, and generate database-aware code. The server connects to PostgreSQL and MySQL databases via environment variables, supports connection pooling, parameterized queries, and auto-connect on startup. It can be run directly with npx without installation. Release cadence is not documented; it's a single-instance server intended for local or dev use. Differentiates from other MCP servers by supporting both PostgreSQL and MySQL in one package, with a simple configuration model.

npm install postgres-mysql-mcp-server
INSTALL
IMPORT
SIG · POSTGRES-MYSQL-MCP
P
postgres-mysql-mcp-server
databasejavascriptv1.0.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
npx postgres-mysql-mcp-server
This package is meant to be run as a CLI server, not imported as a library. It exposes an MCP server via stdio. To use, run with npx or globally installed package.
server
import { Server } from '@modelcontextprotocol/sdk/server/index.js'
const server = require('postgres-mysql-mcp-server')
The package does not export a server symbol; it's a binary. Use the MCP SDK for custom client implementations.
main
npx postgres-mysql-mcp-server
node -e "require('postgres-mysql-mcp-server')"
Direct require will run the server, but it's designed to be used as a CLI. Use npx or install globally.

Configures and runs the MCP SQL server with npx, connecting to a PostgreSQL database via environment variables.

// Configure in your MCP client (e.g., Cursor) as: // { // "mcpServers": { // "sql": { // "command": "npx", // "args": ["-y", "postgres-mysql-mcp-server"], // "env": { // "DB_TYPE": "postgresql", // "DB_HOST": "localhost", // "DB_PORT": "5432", // "DB_DATABASE": "mydb", // "DB_USER": "postgres", // "DB_PASSWORD": "password" // } // } // } // } // Or run directly from terminal: // export DB_TYPE=postgresql DB_HOST=localhost DB_PORT=5432 DB_DATABASE=mydb DB_USER=postgres DB_PASSWORD=password // npx postgres-mysql-mcp-server // The server listens on stdin/stdout for MCP JSON-RPC messages. // Tools available: query (execute SQL), list_tables, describe_table, etc.
Debug
Known issues
warningEnvironment variables passed in MCP client config may be exposed in process listing.
fix
Use .env files or secure secret management; avoid hardcoding credentials in JSON config.
affects: >=1.0.0
warningRunning `npx postgres-mysql-mcp-server -y` executes arbitrary code from npm.
fix
Pin version (e.g., `npx postgres-mysql-mcp-server@1.0.6`) to avoid unexpected updates.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module '@modelcontextprotocol/sdk'
The package does not install the MCP SDK as a dependency; it is a binary that uses internal implementation.
fix
You don't need to import the SDK; just run `npx postgres-mysql-mcp-server` directly.
Error: DB_TYPE must be 'postgresql' or 'mysql'
Missing or invalid DB_TYPE environment variable.
fix
Set DB_TYPE to either 'postgresql' or 'mysql' in your environment.
Error: Connection refused (ECONNREFUSED)
Database server is not running or host/port is incorrect.
fix
Ensure database is running and accessible; check DB_HOST and DB_PORT values.
Upgrade
Version history
1.0.6latest on npm
Audit
Dependencies
pgrequiredRequired for PostgreSQL database connectivity.
mysql2requiredRequired for MySQL database connectivity.
Agent activity
12 hits · last 30 days
node
10
Resources
postgres-mysql-mcp-server — npm install postgres-mysql-mcp-server · libregistry