gcp-postgres-tools
Provides read-only query tools for a PostgreSQL database, including retrieving recent users, user details, and recent user activities.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@gcp-postgres-toolsShow me the most recent 10 users."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
GCP Postgres MCP Tools
FastAPI app that connects to your GCP PostgreSQL database and exposes query tools over REST and MCP.
Setup
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .envPut your Cloud SQL URL in .env. If you already use a local Cloud SQL Auth Proxy, point at that host and port:
DATABASE_URL=postgresql+asyncpg://USERNAME:PASSWORD@127.0.0.1:5439/DATABASE_NAME
USERS_TABLE=tbl_users
USERS_ORDER_COLUMN=date_joinedThis app is read-only against Cloud SQL. Every production session sets default_transaction_read_only and SET TRANSACTION READ ONLY. REST tools are GET-only. POST is allowed only on /mcp (protocol) and /agent/chat (the agent loop). Agent traces are written to a separate local SQLite file, never to evolve_production.
get_last_10_users uses tbl_users. get_last_5_user_activities uses tbl_user_activities. Password columns are never returned.
For production, also use a Cloud SQL user that has SELECT only.
Related MCP server: PostgreSQL MCP Server
Run
uvicorn app.main:app --reload --port 8000Health:
GET /healthDocs:
http://127.0.0.1:8000/docsMCP:
http://127.0.0.1:8000/mcpAgent:
POST /agent/chatTraces:
GET /agent/tracesandGET /agent/traces/{trace_id}
Agentic loop and traces
The agent is a ReAct loop: think → call a read-only tool → observe → repeat → final answer.
curl -s http://127.0.0.1:8000/agent/chat \
-H 'Content-Type: application/json' \
-d '{"message":"Get the last 10 users"}'Each run stores a structured trace (user_input, LLM tool choices, tool results, final answer) in data/traces.db.
The agent uses the Gemini Developer API (Google AI Studio key), not Vertex AI and not OpenAI.
GEMINI_API_KEY=AIza...
GEMINI_MODEL=gemini-3.6-flashGet a key at aistudio.google.com/apikey. GOOGLE_API_KEY also works.
These are not the same as a Vertex AI key. Gemini keys start with AIza and do not need a GCP project or region.
Optional: LangSmith via LANGSMITH_TRACING=true and LANGSMITH_API_KEY.
Without GEMINI_API_KEY, /agent/chat returns 503. REST and MCP read tools still work.
Each chat request is capped so the agent cannot loop or retry forever:
Setting | Default | What it stops |
| 2 | Gemini HTTP retries |
| 1 | Tool/DB retries |
| 5 | Tools per request |
| 6 | Model turns per request |
| 12 | Hard LangGraph step stop |
Tools
REST | MCP tool | What it does |
|
| Latest 10 users |
|
| One user by id |
|
| Latest 5 activities |
|
| Full agent audit trace |
|
| Recent agent traces |
Password and hash columns are never returned.
Cursor MCP config
{
"mcpServers": {
"gcp-postgres-tools": {
"url": "http://127.0.0.1:8000/mcp"
}
}
}Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
- dataOAuthco.thinair
Read-only PostgreSQL, MySQL, SQL Server access via MCP — 24 dialect-aware hosted tools.
Generate, fix, explain and run read-only SQL on PostgreSQL, MySQL and SQL Server
1Create, manage, and query your Google Cloud SQL resources.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides read-only access to PostgreSQL databases, enabling LLMs to inspect database schemas and execute read-only SQL queries.100,745MIT
- FlicenseNot gradedqualityDmaintenanceProvides read-only access to PostgreSQL databases with schema inspection, query execution in multiple formats (JSON, CSV, Markdown), and query history tracking with built-in security features.-
- AlicenseNot gradedqualityCmaintenanceEnables secure read-only access to PostgreSQL databases, allowing users to list tables, query schemas, execute SELECT statements, and inspect table structures through natural language interactions.7514MIT
- AlicenseNot gradedqualityDmaintenanceEnables safe interaction with PostgreSQL databases through read-only queries, schema exploration, and performance analysis.121MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/backendengineershiv/pg-mcp-tools'
If you have feedback or need assistance with the MCP directory API, please join our Discord server