Hey HN,<p>I built pg-mcp, a Model Context Protocol (MCP) server for PostgreSQL that provides structured schema inspection and query execution for LLMs and agents. It's multi-tenant and runs over HTTP/SSE (not stdio)<p>Features
- Supports multiple database connections from multiple agents<p>- Schema Introspection: Returns table structures, types, indexes and constraints; enriched with descriptions from pg_catalog. (for well documented databases)<p>- Read-Only Queries: Controlled execution of queries via MCP.<p>- EXPLAIN Tool: Helps smart agents optimize queries before execution.<p>- Extension Plugins: YAML-based plugin system for Postgres extensions (supports pgvector and postgis out of the box).<p>- Server Mode: Spin up the container and it's ready to accept connections at <a href="http://localhost:8000/sse" rel="nofollow">http://localhost:8000/sse</a>
Just for everyone here, the code for "building an MCP server", is importing the standard MCP package for Typescript, Python, etc, then writing as little as 10 lines of code to define something is an MCP tool.<p>Basically, it's not rocket science. I also built MCP servers for Mysql, Twilio, Polars, etc.
This is wild. Our company has like 10 data scientists writing SQL queries on our DB for business questions. I can deploy pg-mcp for my organization so everyone can use Claude to answer whatever is on their mind? (e.x."show me the top 5 customers by total sales")<p>sidenote: I'm scared of what's going to happen to those roles!
From docker-compose<p><pre><code> ports:
- "8000:8000"
</code></pre>
This will cause Docker to expose this to the internet and even helpfully configure an allow rule to the host firewall, at least on Linux.
This is great, I like in particular that there are extensions plugins. I’ll be looking at integrating this in the Xata Agent (<a href="https://github.com/xataio/agent" rel="nofollow">https://github.com/xataio/agent</a>) as custom tooling.
Where's the pagination? How does a large query here not blow up my context:<p><a href="https://github.com/stuzero/pg-mcp/blob/main/server/tools/query.py#L8" rel="nofollow">https://github.com/stuzero/pg-mcp/blob/main/server/tools/que...</a>
Is there more to MCP than being a simple Remote Procedure Call framework that allows AI interactions to include function calls driven by the AI model? The various documentation pages are a bit hand wavy on what the protocol actually is. But it sounds to me that RPC describes all/most of it.
Nice!<p>What I'd be looking for is a MCP server where I can run in "biz/R&D exploration-mode", eg:<p>- assume I'm working on a replica (shared about all R&D engineers)
- they can connect and make read-only queries to the replica for the company data
- they have a temporary read-write schema just for their current connection so they can have temporary tables and caches
- temporary data is deleted when they close the session<p>How could you make a setup like that so that when using your MCP server, I'm not worried about the model / users modifying the data, but only doing their own private queries/tables?
I don’t understand the advantage of having the transport protocol be HTTP/SSE rather than studio especially in this case when it’s literally running locally.