simple-psql
A beginner-friendly MCP server template featuring a PostgreSQL connector with clean, easy-to-understand code. Perfect for developers new to Model Context Protocol who want to experiment and create their own AI tool connectors with minimal setup.
claude mcp add --transport stdio netanelbollag-simple-psql-mcp uv --directory /path/to/simple-psql-mcp run postgres \ --env DSN="postgresql://username:password@localhost:5432/my-db" \ --env SCHEMA="public"
How to use
This MCP server exposes a PostgreSQL-backed set of tools, resources, and prompts that you can access through the MCP Inspector or an integrator AI. The Tools section includes execute_query for running SQL against your database and test_connection to verify connectivity. Resources provide db://tables (lists all tables), db://tables/{table_name} (schema details for a specific table), and db://schema (complete schema information for all tables). Prompts include query generation templates and analytical query builders that help construct SQL queries from natural language intents. To use it, start the server via the Inspector (uv) and connect your AI tool to the configured DSN and schema. The Inspector UI lets you interactively test commands, view results, and see how the MCP server responds to natural language inputs transformed into tool calls.
How to install
Prerequisites:\n- Python 3.8+\n- uv (Python package manager/installer)\n- Node.js with npx (for the MCP Inspector)\n- PostgreSQL database you can connect to\n\n1. Set up a Python virtual environment and install dependencies:\nbash\n# Create a virtual environment with uv\nuv venv\n\n# Activate the virtual environment\nsource .venv/bin/activate # On Windows: .venv\Scripts\activate\n\n# Install dependencies\nuv pip install -r requirements.txt\n\n\n2. Start the MCP server via the Inspector (as shown in the README):\nbash\n# Replace with your actual database credentials in DSN/SCHEMA within the config file or environment\nnpx @modelcontextprotocol/inspector uv --directory . run postgres\n\nThis will launch the MCP Inspector interface in your browser where you can connect to the server and test Tools, Resources, and Prompts.\n\n3. Create or update the MCP configuration file (see example in the README) to point to your uv-based server.\njson\n{\n "mcpServers": {\n "postgres": {\n "command": "uv",\n "args": [\n "--directory",\n "/path/to/simple-psql-mcp",\n "run",\n "postgres"\n ],\n "env": {\n "DSN": "postgresql://username:password@localhost:5432/my-db",\n "SCHEMA": "public"\n }\n }\n }\n}\n\n\n4. Optional: If you use the included example database, follow the README’s steps to spin it up and connect via the inspector.\n
Additional notes
Tips and common considerations:\n- Ensure DSN and SCHEMA in the MCP config reflect your actual database connection details. Treat DSN like a secret; do not commit it to public repos.\n- The server performs a basic safety check (e.g., only allows SELECT-like queries via execute_query by default); evaluate whether you need stronger safeguards for production.\n- The Inspector UI is a convenient way to validate commands before integrating with an AI tool.\n- If you modify the SQL templates or prompts, keep them aligned with the actual database schema to improve accuracy of generated queries.\n- If you encounter connection issues, verify network access to the PostgreSQL host, correct port, user permissions, and that the database accepts connections from the environment where the MCP server runs.\n
Related MCP Servers
mcp-vegalite
MCP server from isaacwasserman/mcp-vegalite-server
github-chat
A Model Context Protocol (MCP) for analyzing and querying GitHub repositories using the GitHub Chat API.
nautex
MCP server for guiding Coding Agents via end-to-end requirements to implementation plan pipeline
pagerduty
PagerDuty's official local MCP (Model Context Protocol) server which provides tools to interact with your PagerDuty account directly from your MCP-enabled client.
futu-stock
mcp server for futuniuniu stock
mcp -boilerplate
Boilerplate using one of the 'better' ways to build MCP Servers. Written using FastMCP