Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,9 @@ mempalace compress --wing myapp # AAAK compress

# Status
mempalace status # palace overview

# MCP
mempalace mcp # show MCP setup command
```

All commands accept `--palace <path>` to override the default location.
Expand Down
24 changes: 24 additions & 0 deletions mempalace/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
mempalace mine <dir> Mine project files (default)
mempalace mine <dir> --mode convos Mine conversation exports
mempalace search "query" Find anything, exact words
mempalace mcp Show MCP setup command
mempalace wake-up Show L0 + L1 wake-up context
mempalace wake-up --wing my_app Wake-up for a specific project
mempalace status Show what's been filed
Expand All @@ -28,6 +29,7 @@

import os
import sys
import shlex
import argparse
from pathlib import Path

Expand Down Expand Up @@ -240,6 +242,21 @@ def cmd_instructions(args):
run_instructions(name=args.name)


def cmd_mcp(args):
"""Show how to wire MemPalace into MCP-capable hosts."""
palace_flag = "[--palace /path/to/palace]"
if args.palace:
resolved_palace = str(Path(args.palace).expanduser())
palace_flag = f"--palace {shlex.quote(resolved_palace)}"

server_cmd = f"python -m mempalace.mcp_server {palace_flag}"
Comment thread
kpulik marked this conversation as resolved.
Resolved

print("MemPalace MCP quick setup:")
print(f" claude mcp add mempalace -- {server_cmd}")
print("\nRun the server directly:")
print(f" {server_cmd}")


def cmd_compress(args):
"""Compress drawers in a wing using AAAK Dialect."""
import chromadb
Expand Down Expand Up @@ -500,6 +517,12 @@ def main():
help="Rebuild palace vector index from stored data (fixes segfaults after corruption)",
)

# mcp
sub.add_parser(
"mcp",
help="Show MCP setup command for connecting MemPalace to your AI client",
)

# status
sub.add_parser("status", help="Show what's been filed")

Expand Down Expand Up @@ -531,6 +554,7 @@ def main():
"mine": cmd_mine,
"split": cmd_split,
"search": cmd_search,
"mcp": cmd_mcp,
"compress": cmd_compress,
"wake-up": cmd_wakeup,
"repair": cmd_repair,
Expand Down
1 change: 1 addition & 0 deletions mempalace/instructions/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ AI memory system. Store everything, find anything. Local, free, no API key.
mempalace compress Compress palace storage
mempalace status Show palace status
mempalace repair Rebuild vector index
mempalace mcp Show MCP setup command
mempalace hook run Run hook logic (for harness integration)
mempalace instructions <name> Output skill instructions

Expand Down
33 changes: 33 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sys
from pathlib import Path

from mempalace.cli import main


def test_mcp_command_prints_setup_guidance(monkeypatch, capsys):
monkeypatch.setattr(sys, "argv", ["mempalace", "mcp"])

main()

captured = capsys.readouterr()
assert "MemPalace MCP quick setup:" in captured.out
assert (
"claude mcp add mempalace -- "
"python -m mempalace.mcp_server [--palace /path/to/palace]" in captured.out
)
assert "python -m mempalace.mcp_server [--palace /path/to/palace]" in captured.out
Comment thread
kpulik marked this conversation as resolved.
Resolved
assert captured.err == ""


def test_mcp_command_uses_custom_palace_path_when_provided(monkeypatch, capsys):
monkeypatch.setattr(sys, "argv", ["mempalace", "--palace", "~/tmp/my palace", "mcp"])

main()

captured = capsys.readouterr()
expanded = str(Path("~/tmp/my palace").expanduser())

assert "python -m mempalace.mcp_server --palace" in captured.out
assert expanded in captured.out
assert "[--palace /path/to/palace]" not in captured.out
assert captured.err == ""
Loading