postgres-mysql
MCP server from TranChiHuu/postgres-mysql-mcp-server
claude mcp add --transport stdio tranchihuu-postgres-mysql-mcp-server npx -y postgres-mysql-mcp-server \ --env DB_HOST="localhost" \ --env DB_PORT="5432" \ --env DB_TYPE="postgresql" \ --env DB_USER="postgres" \ --env DB_DATABASE="mydb" \ --env DB_PASSWORD="password"
How to use
This MCP server provides a database-aware bridge between your AI coding assistants and your PostgreSQL or MySQL databases. It exposes tools to connect to a database, run SQL queries, and inspect schema details so your editor plugins (like Cursor or Windsurf) can generate accurate code and queries based on your actual schema. After starting the server (for example via npx as shown above), you can configure your MCP client with the provided sql server definition and environment variables to auto-connect to your database on startup. The server supports executing parameterized queries, listing tables, describing table schemas, and disconnecting from the database, all through MCP calls from your editor.
How to install
Prerequisites:
- Node.js and npm or npx available on your machine
- Access to run npm install or npx to fetch packages
Option 1: Use with npx (no installation required)
- Run the server directly: npx postgres-mysql-mcp-server
Option 2: Install via npm (global or local)
- Global installation: npm install -g postgres-mysql-mcp-server
- Local installation in your project: npm install postgres-mysql-mcp-server
Option 3: Development installation (for contributors)
- Clone the repository and install dependencies: git clone https://github.com/TranChiHuu/postgres-mysql-mcp-server.git cd postgres-mysql-mcp-server npm install
Additional notes
Tips and notes:
- You can configure automatic connection by setting environment variables (DB_TYPE, DB_HOST, DB_PORT, DB_DATABASE, DB_USER, DB_PASSWORD). If those are present, the server will auto-connect on startup.
- The MCP client configuration example uses the npx command; you can adapt the same approach with custom host/port or different DB credentials.
- Ensure your database accepts connections from the host running the MCP server and that the user has appropriate privileges for the requested operations.
- For production deployments, consider using a proper database connection pool and secure handling of credentials (e.g., managed secrets, environment variable protections).
- The server supports both PostgreSQL and MySQL connections; use DB_TYPE to switch between them as needed.
Related MCP Servers
zen
Selfhosted notes app. Single golang binary, notes stored as markdown within SQLite, full-text search, very low resource usage
MCP -Deepseek_R1
A Model Context Protocol (MCP) server implementation connecting Claude Desktop with DeepSeek's language models (R1/V3)
mcp-fhir
A Model Context Protocol implementation for FHIR
mcp
Inkdrop Model Context Protocol Server
mcp-appium-gestures
This is a Model Context Protocol (MCP) server providing resources and tools for Appium mobile gestures using Actions API..
dubco -npm
The (Unofficial) dubco-mcp-server enables AI assistants to manage Dub.co short links via the Model Context Protocol. It provides three MCP tools: create_link for generating new short URLs, update_link for modifying existing links, and delete_link for removing short links.