lime-ref-postgres-mcp
Provides MCP tools for interacting with PostgreSQL databases, including schema inspection, read-only queries, write operations, and database statistics, with permission controls.
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., "@lime-ref-postgres-mcpshow me the first 10 rows from the users table"
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.
lime-ref-postgres-mcp
English · Русский
An open-source showcase of LIME agent identity on a real resource: PostgreSQL behind MCP.
Agents do not share a generic database password. They arrive with a LIME passport (Authorization: Bearer), get checked against a local whitelist and capabilities, then use MCP tools against Postgres. After an authorized agent is recognized, the core emits one audit event — who called what, and how it ended — without copying the tool response body.
This repository is a reference implementation, not a production service operated by LIME. Fork it, study the pattern, run it against your own Postgres, and plug your own audit consumers if you need them.
Why this exists
Without named agent identity | With LIME on this door |
One shared | Each agent is a person ( |
Logs show “someone queried the DB” | Logs/events can say which agent did what |
Hard to attach corporate audit / SIEM | EventBus is an extension point — subscribe your own sink |
MCP demos often skip real auth | Same LIME passport model as other LIME-protected resources |
Primary goal of this package: make LIME technology tangible — passport → allowlist → action → event — on a concrete door (Postgres over MCP), so developers can see how agent identity works end-to-end.
Related LIME pieces:
Platform & docs: lime.pics
Agent client (issue MCP JWT with domain):
lime-agents-sdkResource-server verify (JWKS / RS256):
lime-mcp-server-sdk(this server wraps it)
Related MCP server: AgenticMCP
What it is / is not
Is | Is not |
Open showcase of LIME agent passport on MCP → Postgres | LIME’s production product or hosted SaaS |
Deny-by-default whitelist + capabilities | “One API key opens the whole DB” |
Shipped ConsoleSink (demo of the event system) | Shipped webhook / SIEM exporters |
Process observability (JSONL + metrics, ADR-003) | Mixing agent audit cards into process logs |
Extractable package under this folder | Coupled to the rest of a monorepo runtime |
Agent Bearer ≠ POSTGRES_URL.
The Bearer is the agent’s LIME passport. POSTGRES_URL is the MCP service database role — service credentials, not agent identity.
How a call works
Agent (LIME passport) -- Bearer + tools/call --> MCP /mcp
│
▼
1. Verify JWT (JWKS from lime.pics, domain + aud pin)
│ fail → error to agent, NO agent-action event
▼
2. Whitelist (config/agents.json)
│ unknown agent → error, NO agent-action event
▼
3. Capabilities + SQL class guard
│ denied → reply + agent-action event (denied)
▼
4. Postgres (asyncpg)
▼
5. Agent-action event (ok | error) → reply to agent
│
└── EventBus subscribers (ConsoleSink demo / your sink)Process logs (lime.mcp.process_log.v1) always can record preauth failures and call lifecycle; agent-action events exist only after a allowlisted agent is established. See ADR-003.
Features
LIME passport gate —
Authorization: Beareron everytools/call; verify vialime-mcp-server-sdkPolicy — JSON whitelist, permissions
READ_SCHEMA/READ_DATA/WRITE_DATA/DDL/ADMIN,max_rows, lazy reload by mtimeSQL defense — pglast AST → statement-class guard (readonly vs write vs DDL)
Eight MCP tools — schema / data / write / admin surface only on
/mcpEvent system —
AgentActionEventwithout response payload;bus.subscribe(...)for custom sinksConsoleSink — optional JSONL cards on stdout (event-system demo)
Process observability — structured logs + in-process metrics +
request_idcorrelationQuality gate — package-local
prime_check+ CI workflow
Quick start
Requirements: Python ≥ 3.12, uv. Docker only for integration tests.
cd Marketing/lime-postgres-mcp # or clone this package as its own repo
uv sync --all-extras
cp .env.example .env # fill LIME_* and POSTGRES_URL
# create config/agents.json from config/agents.example.json
# map real LIME agent_id (passport sub) → permissions
uv run python -m lime_ref_postgres_mcp serve
# → http://127.0.0.1:8000/mcpFrom an agent worker, use lime-agents-sdk against that URL (OAuth mints a JWT with {"domain": "<your pin>"} matching LIME_EXPECTED_DOMAIN):
from lime_agents import LimeAgent
async with LimeAgent(agent_token="...") as agent:
tools = await agent.list_tools("http://127.0.0.1:8000/mcp")
result = await agent.call_tool(
"http://127.0.0.1:8000/mcp",
"list_schemas",
{},
)Composition check (no HTTP):
uv run python -m lime_ref_postgres_mcpMCP tools
Tool | Capability |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Passport goes in the HTTP header only — never in tool arguments.
Agent event system (for integrators)
The core emits immutable AgentActionEvent values after an allowlisted agent is in context. It does not ship webhooks or SIEM connectors — by design. You attach consumers yourself.
What you get on each event
agent_id,status(ok|denied|error)request— tool name + args (no result rows / no agent reply body)outcome— reason codes, missing capabilities, statement class, row countsmeta— e.g.request_id,domainduration_ms,event_id,ts
Privacy rule: full SELECT payloads must not leave through audit. Events are cards, not response mirrors.
When there is no event
Missing / invalid passport, JWKS failure, or agent not on the whitelist → agent gets an error; no AgentActionEvent (there was no authorized actor). Process logs still record preauth.fail.
Shipped demo: ConsoleSink
With ENABLE_CONSOLE_EVENT_SINK=1 (default), bootstrap registers ConsoleSink — one JSON line per event on stdout. Turn it off if you only want your own subscribers.
Add your own sink (logging elsewhere)
Any async callable that accepts AgentActionEvent works. Subscribe at composition time (after build_scaffold_runtime / on runtime.event_bus):
from lime_ref_postgres_mcp.bootstrap.container import build_scaffold_runtime
from lime_ref_postgres_mcp.domain.auditing.agent_action_event import AgentActionEvent
async def forward_to_my_logger(event: AgentActionEvent) -> None:
# Examples: write to your DB, push to a queue, call an internal API.
# Do not put agent response bodies here — they are not on the event.
await my_audit_store.write(
agent_id=str(event.agent_id),
tool=event.request.get("tool"),
status=event.status,
reason=(event.outcome.reason_code if event.outcome else None),
request_id=(event.meta or {}).get("request_id"),
)
runtime = build_scaffold_runtime()
runtime.event_bus.subscribe(forward_to_my_logger)
# then serve ASGI from this runtime (same pattern as `serve`)Rules of the road
Sink is one-way: read the event; do not call back into invoke/authorize.
Sink errors are swallowed by the bus — they must not change the tool
Resultreturned to the agent.Prefer idempotent, fast handlers; offload heavy work to a queue inside your sink.
Process observability (
bootstrap.observability) is a different channel from agent events — don’t overload one with the other.
ConsoleSink source: subscribers/console_sink.py.
Port: application/ports/events.py.
Configuration
Copy .env.example. Important variables:
Variable | Required | Role |
| yes | Hostname pin on the MCP JWT ( |
| yes | JWKS (default lime.pics well-known) |
| no | default |
| yes | Service DB URL (lazy pool) |
| no | default |
| no | default |
| no | default on — demo agent-action JSONL |
| no | process observability (ADR-003) |
| no |
|
Policy shape: config/agents.example.json.
There is no WEBHOOK_URL and no WebhookSink in this package.
Verify / quality
uv run ruff check src tests
uv run mypy src
uv run pytest
uv run pytest tests/integration -m integration --no-cov -o addopts=
uv run python -m scripts.prime_check
uv run python -m scripts.prime_check --listNested CI: .github/workflows/prime_check.yml (extract-to-own-repo ready).
Documentation map
Doc | Content |
Product intent, access model, event rules | |
Architecture, layers, module map | |
Auth boundary on MCP | |
Process logs + metrics + correlation | |
Phase reports (Day0 → P6) |
Layout
src/lime_ref_postgres_mcp/
domain/ # policy, SQL guard, AgentActionEvent (pure)
application/ # invoke / authorize / emit ports
infrastructure/ # JWKS verify, JSON policy, asyncpg, EventBus
presentation/mcp/ # Streamable HTTP /mcp
subscribers/ # ConsoleSink (demo)
bootstrap/ # settings, container, process observability
config/ # agents.example.json
scripts/prime_check # package quality gate
tests/Status
Showcase sealed through P6 (CI green + SBOM). Intended as public reference code for LIME agent identity on MCP → Postgres.
Maintainers do not operate this as LIME production, and do not ship outbound webhook sinks.
License
See package metadata in pyproject.toml.
This server cannot be installed
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
- Flicense-qualityDmaintenanceA secure MCP server that enables querying PostgreSQL databases through an SSH tunnel with enforced read-only access, connection pooling, and comprehensive data exploration tools.Last updated
- Alicense-qualityDmaintenanceA Model Context Protocol (MCP) server that provides secure, role-based access to PostgreSQL databases for AI agents.Last updatedMIT
- Alicense-qualityDmaintenanceA secure, read-only PostgreSQL MCP server that provides safe database introspection and querying capabilities.Last updated25MIT
- AlicenseAqualityDmaintenanceA production-grade MCP server that gives AI agents safe, authenticated access to a PostgreSQL database.Last updated3MIT
Related MCP Connectors
MCP server for managing Prisma Postgres.
MCP server for interacting with the Supabase platform
A paid remote MCP for CLI tool MCP, built to return verdicts, receipts, usage logs, and audit-ready
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/Mawyxx/lime-ref-postgres-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server