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)
Features - Supports multiple database connections from multiple agents
- Schema Introspection: Returns table structures, types, indexes and constraints; enriched with descriptions from pg_catalog. (for well documented databases)
- Read-Only Queries: Controlled execution of queries via MCP.
- EXPLAIN Tool: Helps smart agents optimize queries before execution.
- Extension Plugins: YAML-based plugin system for Postgres extensions (supports pgvector and postgis out of the box).
- Server Mode: Spin up the container and it's ready to accept connections at http://localhost:8000/sse
Basically, it's not rocket science. I also built MCP servers for Mysql, Twilio, Polars, etc.
> Please don't post shallow dismissals, especially of other people's work. A good critical comment teaches us something.
We are hackers here. Building is good. Sharing is good. All this is true even if you personally know how to do what is being shared, and it is easy for you. I promise you there are people who encounter every sharing post here and do not think what is posted is easy.
Is there a glitzy corporate PR page trying to sell something, or is this just code for people to read?
Did Ars Technica breathlessly cover it, or did a random hacker post and share something they worked on?
If it’s the work of a random hacker not promoted by media outlets, who benefits from negative comments about that person’s work?
Is it possible that there are at least some people who read this site who know less about the topics covered than you do, and so might find this interesting or useful?
When you post something, will it help you to improve if people post non-constructive negative feedback? Will dismissive comments like these make you more or less likely to show your work publicly?
Just food for thought…
MCP is getting trendy, but a lot of people being drawn in can't find the actual meat of what it is outside of self-referential definitions.
Someone pointing out the reason for the flood of MCP servers being how trivial they are to implement is a helpful data point. Simple as that.
My comment was against the shallow dismissal. Do you think that the negative comments helped anyone locate the meat of what it is? Did they clarify or educate?
Even the infamous Dropbox comment[1] was more constructive. I gently push back in the hope that we can have better discussions here than on other sites.
Like you can write a single 20 line method to connect to a MySQL database, add the MCP tool decorator to the method and boom you "built an MCP server".
But no one is posting up to HN saying "Look guys, I wrote a method which connects to a MySQL server", because it takes almost zero expertise and is not novel at all.
sidenote: I'm scared of what's going to happen to those roles!
Q: show me the top 5 customers by total sales
A: System.Data.Odbc.OdbcException (0x80131937): ERROR [57014] ERROR: canceling statement due to statement timeout;
Q: Why do I get this error
A: Looks like it needs an index, let me create that for you. Done. Rerunnign query.
could not close temporary statistics file "pg_stat_tmp/global.tmp": No space left on device
Q: Why this error
A: 429 Too Many Requests
Rub hands... great next 10 years to be a backend dev.
The question is do they still need 10? Or 2 would suffice? How about 5?
This does not need to be a debate about the absolutes.
I am hoping Jevon will keep employing me. He has been a great boss for the last 25 years TBH.
It doesn't work because the PHB doesn't have the domain knowledge and doesn't know which questions to ask. (No, it's never as simple as group-by and top-5.)
I suppose this could be useful in that it prevents everyone in the company having to learn even the basics of SQL which is some barrier, however minimal.
Also the LLM will presumably be able to see all the tables/fields and ‘understand’ them (with the big assumption that they are even remotely reasonably named) so English language queries will be much more feasible now. Basically what LLMs have over all those older attempts is REALLY good fuzziness.
I see this being useful for some subset of questions.
The project manager also won't learn behat and write tests.
Your client also won't use the CMS to update their website.
Do human reviewing and correcting of the updated documentation. Then ensure that the AI knows that the documentation might still contain errors and ask it to do the 'actual' work.
To give you an extreme example, I can ask 1000000 different models for a counterexample to the 3n + 1 problem, and all will get it wrong.
For reference: https://en.wikipedia.org/wiki/Collatz_conjecture
So no, sampling 1000000 LLMs will not get you a solution to it. I guarantee you that.
If you want to scale back, many programming problems are going to be like this, too. Failure points of different models are correlated as much as failure points during sampling are correlated. You only gain information from repeated trials when those trials are uncorrelated, and sampling multiple LLMs is still correlated.
Is that the correct answer to "write a lock-free MPMC queue"? That is a coding problem that literally every LLM gets wrong, but has several well-known solutions.
There's merit to "I don't know" as a solution, but a lot of the knowledge encoded in LLMs is correlated with other LLMs, so more sampling isn't going to get rid of all the "I don't knows."
Thats cute.
Nuanced BI analytics can have a lot of toggles and filters and drilldowns, like compare sales of product A in category B subcategory C, but only for stores in regions X,Y and that one city Z during time periods T1, T2. and out of these sales, look at sales of private brand vs national brand, and only retail customers, but exclude purchases via business credit card or invoiced.
with every feature in a DB (of which there could be thousands), the number of permutations and dimensions grows very quickly.
whats probably going to happen, is simple questions could be self-served by GenAI, but more advanced usage is still needed interention by specialist. So we would see some improvement in productivity, but people will not lose jobs. Perhaps number of jobs could even increase due to increased demand for analytics, as it often happens with increased efficiency/productivity (Jevon's paradox)
i suppose the desktop app can use it, but how good is it for this general purpose "chat with the database for lightweight analytics" use cases is it worth the trouble of dealing with some electron app to make it work?
Agents will become ubiquitous parts of the user interface that is currently the chat.
So if you bother with a website or an electron app now, MCP will just add more capabilities to what you can control using agents.
when i've read through documentation for mcp servers, it seems like the use cases they've mostly been focused on are improving effectiveness of programming assistants by letting them look at databases associated with codebases they're looking to modify.
i understand that these things are meant to be generic in nature, but you never really know if something is fit for purpose until it's been used for that purpose. (at least until agi, i suppose)
ports:
- "8000:8000"
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.OP, exposing your application without authentication is a serious security risk!
Quick anecdote: Last week, I ran a Redis container on a VPS with an exposed port and no password (rookie mistake). Within 24 hours, the logs revealed someone attempting to make my Redis instance a slave to theirs! The IP traced back to Tencent, the Chinese tech giant... Really weird. Fortunately, there was nothing valuable stored in it.
They're a large cloud provider in Asia like Amazon AWS or Microsoft Azure. I doubt such a tech company would make it that obvious when breaking the law.
UI <--> Agent(s) <--> MCP Server(s) <--> Tools/Resources
|
LLM(s)
https://github.com/stuzero/pg-mcp/blob/main/server/tools/que...
What I'd be looking for is a MCP server where I can run in "biz/R&D exploration-mode", eg:
- 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
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?
Good luck!
My first foray into using MCP was via Claude Desktop. Would be great if you packaged your tool such that one could add it with a few lines in their ‘~/Library/Application Support/Claude/claude_desktop_config.json’
All it does is expose methods as a "tool" which is then brought back to your LLM and defined with its name, description and input parameters.
E.g. Name: "MySqlTool", Description: "Allows arbitrary MySQL queries to the XYZ database", Parameters: "string: sqlToExecute"
The MCP Client (e.g. Claude Desktop, Claude Code), is configured to talk to an MCP server via stdio or sse, and calls a method like "tools/list", the server just sends a list back (in JSON) of all the tools, names, descriptions, params.
Then, if the LLM gets a query that mentions e.g. do a web search, or a web scraping, etc, it just outputs a tool use token then stops inferencing. Then the code calls that tool via stdio/sse (json-rpc), to the MCP server, which just runs that method, returns the result, then its added to the message history in the LLM, then inferencing runs again from the beginning.
It may be easy for you to configure, but you dropped some acronyms in there that I would have to look up. I have definitely not personally set up anything like this.
As a side note, do people here not realize that less complicated examples are often better for learning? Have we as a community forgotten this basic truism?
Since it’s not complicated, you should be able to write it up quickly, and parallel commmenters to mine suggest there is an audience for such documentation.
Thanks!
1. You add this MCP to your DB (make sure it is securely connected to your AI of choice of course)
2. Ask anything about your data, ask to make graphs, ask to make scheduled tasks, ask to analyze queries and show optimizations and so on.
3. Profit, literally. No need to pay BI companies thousands each month.
Think about each MCP implementer like an agent’s input/output device.