SuperAPI AI Directory

pg-mnemosyne-mcp

PostgreSQL-backed persistent memory, task tracker and multi-agent coordination hub for AI assistants.

Open website

About this tool

Purpose

pg-mnemosyne-mcp is a Model Context Protocol (MCP) server designed to provide AI assistants with persistent memory, task tracking, and dynamic PostgreSQL database management capabilities. It enables AI agents to create project databases, manage memories and tasks within the same PostgreSQL instance, and coordinate collaboration in multi-agent scenarios.

Key Capabilities

  • High performance: Uses a cached connection pool (asyncpg.create_pool), supporting sub-millisecond database queries.
  • Dynamic projects: AI can create new databases on demand for different projects.
  • Dynamic schema: AI can dynamically modify table structures to adapt to changing memory needs.
  • Standard memory tracking: Built-in tracking, updating, and deletion of memory entries, with tag support.
  • Advanced task management: Dedicated tasks table structure, including fields such as status transitions, priority, and due dates.
  • Multi-agent collaboration: Centralized session tracking to prevent duplicate coding and file editing conflicts.
  • Raw SQL execution: Provides maximum flexibility for complex queries and DDL operations.

Usage

Installation:

  • Windows: pip install pg-mnemosyne-mcp
  • macOS / Linux: pipx install pg-mnemosyne-mcp (pip install pg-mnemosyne-mcp --break-system-packages can also be used)

Automatically configure all supported AI agents (Claude, Gemini, Qwen, Cursor, etc.): pg-mnemosyne init --dsn "postgresql://user:password@localhost:5432/postgres"

Users need to provide PostgreSQL credentials via the PG_BASE_DSN environment variable, in the format: postgresql://<USERNAME>:<PASSWORD>@<HOST>:<PORT>/<DEFAULT_DB>

The configuration location depends on the AI client used:

  • Claude Desktop: Mac path ~/Library/Application Support/Claude/claude_desktop_config.json; Windows path %APPDATA%\Claude\claude_desktop_config.json.
  • Cursor: Settings > Features > MCP to add a new MCP server, or edit the project .cursor/mcp.json.
  • Roo Code / Cline (VS Code): Edit ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json (Mac) or the corresponding Windows path.
  • Gemini CLI and Qwen CLI: Edit ~/.gemini/settings.json or ~/.qwen/settings.json, or use the CLI: gemini mcp add pg-mnemosyne "/path/to/pg-mnemosyne" -e PG_BASE_DSN="postgresql://user:pass@localhost:5432/postgres" -s user or qwen mcp add pg-mnemosyne "/path/to/pg-mnemosyne" -e PG_BASE_DSN="postgresql://user:pass@localhost:5432/postgres" -s user
  • Claude Code CLI: claude mcp add pg-mnemosyne "/path/to/pg-mnemosyne" -e PG_BASE_DSN="postgresql://user:pass@localhost:5432/postgres" -s user; manual configuration is located at ~/.claude.json.
  • Codex: codex mcp add pg-mnemosyne --env PG_BASE_DSN="postgresql://user:pass@localhost:5432/postgres" -- pg-mnemosyne; manual configuration is located at ~/.codex/config.toml (TOML format).
  • Windsurf IDE: edit ~/.codeium/windsurf/mcp_config.json, or click the Hammer (MCP) icon in the Cascade panel and select Configure.
  • Antigravity CLI (agy): create the plugin directory mkdir -p ~/.gemini/config/plugins/pg-mnemosyne, create ~/.gemini/config/plugins/pg-mnemosyne/mcp_config.json and fill it in according to the standard template, then add an entry to the "imports" array in ~/.gemini/config/import_manifest.json: { "name": "pg-mnemosyne", "source": "manual", "components": ["mcpServers"] }.
  • OpenCode: edit ~/.config/opencode/opencode.jsonc.

Run the server standalone (using standard input/output): The pg-mnemosyne command can also serve as a standalone CLI for managing data and configuring agents. It supports automatic initialization and manual record management (adding and listing records directly in the terminal).

Multi-Agent Collaboration and Advanced Tasks

Pg-Mnemosyne includes dedicated modes to help complex multi-agent environments (such as Gemini CLI, Codex CLI, Roo Code, Claude Desktop) collaborate on the same project:

  • Professional task table: can create a dedicated tasks table, including status (backlog, todo, in_progress, blocked, done), priority (low, medium, high, critical), tags, and due dates.
  • Agent coordination hub: initializes a shared agent_sessions coordination table to avoid merge conflicts, duplicate coding, and redundant compiler troubleshooting. When enabled, agents use update_agent_session and get_active_sessions MCP tools to register the currently edited file and active subtask, forming a real-time bulletin board for mutual visibility.

Available MCP Tools

  • create_project_db(db_name: str): Create a new isolated PostgreSQL database.
  • init_schema(db_name: str): Initialize the basic records table.
  • init_todo_schema(db_name: str): Initialize the professional tasks table.
  • init_coordination_schema(db_name: str): Initialize the multi-agent agent_sessions table.
  • add_column(db_name: str, table: str, column_name: str, data_type: str): Dynamically add a column to any table.
  • add_record(db_name: str, type: str, content: str, tags: list[str]): Add a memory/todo record.
  • get_records(db_name: str, type: str = None, limit: int = 50): Get recent records.
  • update_record(db_name: str, record_id: int, content: str = None, tags: list[str] = None, status: str = None): Partially update a record.
  • delete_record(db_name: str, record_id: int): Delete a record by ID.
  • update_agent_session(db_name: str, agent_name: str, active_task: str, active_file: str = None, status: str = "active"): Register/update active agent status.
  • get_active_sessions(db_name: str): List active agent coordination sessions.
  • run_sql(db_name: str, query: str): Run anySQL (SELECT, INSERT, DDL, etc.).

Use Cases

Suitable for development scenarios that need to provide AI assistants with cross-session persistent memory, structured task tracking, and coordination of coding and file editing in multi-agent systems to avoid conflicts.

Limitations

PostgreSQL credentials (PG_BASE_DSN) must be provided before use. Other limitations are not yet provided.