slcg
Provides read-only PostgreSQL schema introspection via MCP, including tables, columns, primary keys, foreign keys, and indexes, with security enforced by a least-privilege database role.
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., "@slcgshow me all tables and their columns"
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.
SLCG — read-only you can actually trust
A read-only PostgreSQL MCP server that gives an AI clean schema context — with a read-only guarantee enforced by the database itself, not by trying to filter the SQL an agent sends.
The popular way to give an AI database access shipped a "read-only" mode that a single
COMMIT; DROP SCHEMAcan break out of. This is the version where the guarantee holds — and there's a test suite that proves the attacks fail.
The 60-second version
A read-only mode is only real if it survives someone actively trying to leave it. Enforcing it by inspecting the agent's SQL is the same losing game as classic SQL injection, now with an LLM as the untrusted input — anything the agent reads (a row, a ticket, a web page) can carry the payload. So SLCG doesn't filter SQL. It connects as a PostgreSQL role that was never granted the ability to write.
The attack that breaks the naive approach, run against this one:
# The documented breakout: BEGIN READ ONLY; SELECT ...; COMMIT; DROP TABLE ...
#
# Against a privileged connection (the vulnerable pattern):
DROP TABLE <- table destroyed
# Against the slcg_readonly role (this project):
ERROR: cannot execute DROP TABLE in a read-only transaction
# ...and even if the attacker turns the read-only flag OFF first:
SET default_transaction_read_only = off;
INSERT INTO customers ...
ERROR: permission denied for table customers <- the privilege layer, not a flagThat last line is the whole point: there is nothing to talk your way around, because the role has no write privilege to begin with.
Related MCP server: postgres-mcp-readonly
What it does / what it doesn't
Does | Doesn't |
Introspects schema: tables, columns, PKs, FKs, indexes | Offer a |
Enforces read-only via a least-privilege DB role | RBAC, SSO, control plane |
Ships an adversarial test suite + threat model | Multi-DB, vector search, dashboards |
Speaks MCP (Claude Desktop, Cursor, …) | Write access "with safeguards" |
Quickstart
1. Create the least-privilege role (this file is the security model — read it):
psql -v db=mydb -f sql/01_setup_readonly_role.sql -d mydb2. Run the server as that role:
pip install -e .
PGDATABASE=mydb PGUSER=slcg_readonly slcg-server3. Point an MCP client at it. Example Claude Desktop config:
{
"mcpServers": {
"slcg": {
"command": "slcg-server",
"env": { "PGDATABASE": "mydb", "PGUSER": "slcg_readonly" }
}
}
}Prove it yourself
pip install -e ".[dev]"
pytest # 10 adversarial attacks blocked, 6 introspection checksThe attack cases read like a spec: test_commit_breakout_cannot_drop_table,
test_disabling_readonly_still_cannot_write, test_copy_to_program_exfil_is_denied,
test_injected_row_payload_cannot_trigger_write.
Why the keys come from pg_catalog, not information_schema
A detail worth knowing: information_schema's constraint views are
privilege-filtered — a low-privilege read-only role literally cannot see primary
and foreign keys through them. SLCG reads keys from pg_catalog, which is
world-readable, so introspection stays complete for exactly the least-privilege
role the design insists on.
Design decisions
See docs/THREAT_MODEL.md for the threat model mapped to
the OWASP LLM / MCP risk categories, and the sql/01_setup_readonly_role.sql
comments for the enforcement rationale.
Status
Working and tested: the read-only server, the least-privilege role, and a 10-case adversarial test suite all pass. Planned polish — a recorded terminal demo (asciinema → gif) at the top of this README, and a linked writeup of the transaction-breakout bypass class this design defends against.
License
MIT.
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 Servers
- Alicense-qualityCmaintenanceRead-only PostgreSQL MCP server that enables running SELECT queries, listing tables and schemas, and describing columns, with built-in protection against writes and malicious SQL attacks.Last updated484MIT
- Alicense-qualityDmaintenanceA secure, read-only PostgreSQL MCP server that provides safe database introspection and querying capabilities.Last updated25MIT
- Alicense-qualityBmaintenanceA read-only MCP server for PostgreSQL that enables safe database introspection and querying via natural language.Last updated484MIT
- AlicenseAqualityCmaintenanceRead-only PostgreSQL database MCP server for safely exploring schema, tables, relationships, and sample data without modification.Last updated1054MIT
Related MCP Connectors
MCP server for managing Prisma Postgres.
Read-only MCP server for ClassQuill, a tutoring-business-management platform.
MCP server for interacting with the Supabase platform
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/aadhyathmik/slcg'
If you have feedback or need assistance with the MCP directory API, please join our Discord server