Skip to content

feat(examples): postgres-backed MCP server with filesystem authorization#2494

Open
rudi193-cmd wants to merge 9 commits intomodelcontextprotocol:mainfrom
rudi193-cmd:feat/postgres-knowledge-server
Open

feat(examples): postgres-backed MCP server with filesystem authorization#2494
rudi193-cmd wants to merge 9 commits intomodelcontextprotocol:mainfrom
rudi193-cmd:feat/postgres-knowledge-server

Conversation

@rudi193-cmd
Copy link
Copy Markdown

Summary

Adds examples/servers/postgres-knowledge-server — a production-grade MCP server that demonstrates patterns not covered by existing examples:

Filesystem-based authorization middleware

def authorized(app_id: str) -> bool:
    folder = SAFE_ROOT / app_id
    return folder.is_dir() and (folder / "manifest").exists()

No ACL database. The filesystem shape IS the permission. Grant by creating a folder, revoke by deleting it.

Postgres backend via Unix socket
No host/port exposure. Connects via psycopg2.connect(dbname=..., user=...) on the local Unix socket — zero network surface.

Three tools: knowledge_put, knowledge_get, knowledge_search (Postgres FTS with plainto_tsquery).

stdio-only transport — no HTTP server, no open ports.

This pattern comes from production use in willow-mcp, an agent memory system running this architecture in daily use.

Files

  • mcp_postgres_server/server.py — server implementation
  • mcp_postgres_server/__main__.py — entry point
  • pyproject.toml — package config matching existing examples
  • README.md — usage and architecture docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant