# PostgreSQL (MCP Server)

> Archived reference server for read-only PostgreSQL access

- Type: MCP server
- Publisher: Model Context Protocol (official)
- Categories: Data & Analytics, Development
- Website: https://github.com/modelcontextprotocol/servers-archived/tree/main/src/postgres
- Source: https://github.com/modelcontextprotocol/servers-archived
- Transport: stdio
- Launch command: npx -y @modelcontextprotocol/server-postgres postgresql://localhost/mydb
- Sign-in: none
- Listed: 2024-11-25

## About

Archived reference MCP server (no longer maintained, now in servers-archived) providing read-only PostgreSQL access. Exposes table schemas as resources and a query tool that runs inside a read-only transaction.

## Install

1. **Add the server to Codex**

   Codex CLI:

   ```bash
   codex mcp add postgres -- npx -y @modelcontextprotocol/server-postgres postgresql://localhost/mydb
   ```

   config.toml:

   ```toml
   [mcp_servers.postgres]
   command = "npx"
   args = ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"]
   ```

   Agents SDK:

   ```python
   from agents import Agent, Runner
   from agents.mcp import MCPServerStdio
   
   async with MCPServerStdio(
       name="PostgreSQL",
       params={"command": "npx", "args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"]},
   ) as server:
       agent = Agent(name="Assistant", mcp_servers=[server])
       result = await Runner.run(agent, "What tables are in my database?")
       print(result.final_output)
   ```

## Tools

- `query`

## Example prompts

- "What tables are in my database?"
- "Show the schema of the orders table"
- "How many users signed up last week?"

## Related

- [Chrome DevTools MCP](https://chatgptplugins.directory/mcp/chrome-devtools.md): Let coding agents control and debug a live Chrome browser
- [Playwright MCP](https://chatgptplugins.directory/mcp/playwright.md): Browser automation for agents via Playwright accessibility snapshots
- [GitHub](https://chatgptplugins.directory/mcp/github.md): Manage repos, issues, pull requests and Actions from your AI agent
- [Context7](https://chatgptplugins.directory/mcp/context7.md): Pull up-to-date, version-specific library docs into your coding agent
- [Supabase](https://chatgptplugins.directory/mcp/supabase.md): Manage Supabase databases, migrations, edge functions and logs
- [Stripe](https://chatgptplugins.directory/mcp/stripe.md): Query and act on your Stripe account and search Stripe docs from any agent

---
Source: https://chatgptplugins.directory/mcp/postgres · Index: https://chatgptplugins.directory/llms.txt · Independent and community-run. Not affiliated with or endorsed by OpenAI. ChatGPT is a trademark of OpenAI.
