fix: add mcp command with setup guidance (#315)

* fix: add mcp command with setup guidance

* fix: include --palace guidance in mcp command output

* fix: make mcp guidance commands copy-pastable

---------

Co-authored-by: Milla J <millaj1217@gmail.com>
This commit is contained in:
Kevin Pulikkottil
2026-04-09 13:21:18 -05:00
committed by GitHub
parent 69afba3b28
commit 2981433535
4 changed files with 64 additions and 0 deletions
+3
View File
@@ -585,6 +585,9 @@ mempalace compress --wing myapp # AAAK compress
# Status # Status
mempalace status # palace overview mempalace status # palace overview
# MCP
mempalace mcp # show MCP setup command
``` ```
All commands accept `--palace <path>` to override the default location. All commands accept `--palace <path>` to override the default location.
+30
View File
@@ -14,6 +14,7 @@ Commands:
mempalace mine <dir> Mine project files (default) mempalace mine <dir> Mine project files (default)
mempalace mine <dir> --mode convos Mine conversation exports mempalace mine <dir> --mode convos Mine conversation exports
mempalace search "query" Find anything, exact words 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 Show L0 + L1 wake-up context
mempalace wake-up --wing my_app Wake-up for a specific project mempalace wake-up --wing my_app Wake-up for a specific project
mempalace status Show what's been filed mempalace status Show what's been filed
@@ -28,6 +29,7 @@ Examples:
import os import os
import sys import sys
import shlex
import argparse import argparse
from pathlib import Path from pathlib import Path
@@ -241,6 +243,27 @@ def cmd_instructions(args):
run_instructions(name=args.name) run_instructions(name=args.name)
def cmd_mcp(args):
"""Show how to wire MemPalace into MCP-capable hosts."""
base_server_cmd = "python -m mempalace.mcp_server"
if args.palace:
resolved_palace = str(Path(args.palace).expanduser())
server_cmd = f"{base_server_cmd} --palace {shlex.quote(resolved_palace)}"
else:
server_cmd = base_server_cmd
print("MemPalace MCP quick setup:")
print(f" claude mcp add mempalace -- {server_cmd}")
print("\nRun the server directly:")
print(f" {server_cmd}")
if not args.palace:
print("\nOptional custom palace:")
print(f" claude mcp add mempalace -- {base_server_cmd} --palace /path/to/palace")
print(f" {base_server_cmd} --palace /path/to/palace")
def cmd_compress(args): def cmd_compress(args):
"""Compress drawers in a wing using AAAK Dialect.""" """Compress drawers in a wing using AAAK Dialect."""
import chromadb import chromadb
@@ -501,6 +524,12 @@ def main():
help="Rebuild palace vector index from stored data (fixes segfaults after corruption)", 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 # status
sub.add_parser("status", help="Show what's been filed") sub.add_parser("status", help="Show what's been filed")
@@ -532,6 +561,7 @@ def main():
"mine": cmd_mine, "mine": cmd_mine,
"split": cmd_split, "split": cmd_split,
"search": cmd_search, "search": cmd_search,
"mcp": cmd_mcp,
"compress": cmd_compress, "compress": cmd_compress,
"wake-up": cmd_wakeup, "wake-up": cmd_wakeup,
"repair": cmd_repair, "repair": cmd_repair,
+1
View File
@@ -60,6 +60,7 @@ AI memory system. Store everything, find anything. Local, free, no API key.
mempalace compress Compress palace storage mempalace compress Compress palace storage
mempalace status Show palace status mempalace status Show palace status
mempalace repair Rebuild vector index mempalace repair Rebuild vector index
mempalace mcp Show MCP setup command
mempalace hook run Run hook logic (for harness integration) mempalace hook run Run hook logic (for harness integration)
mempalace instructions <name> Output skill instructions mempalace instructions <name> Output skill instructions
+30
View File
@@ -2,6 +2,7 @@
import argparse import argparse
import sys import sys
from pathlib import Path
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
import pytest import pytest
@@ -326,6 +327,35 @@ def test_main_split_dispatches():
mock_cmd.assert_called_once() mock_cmd.assert_called_once()
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" in captured.out
assert "\nOptional custom palace:\n" in captured.out
assert "python -m mempalace.mcp_server --palace /path/to/palace" in captured.out
assert "[--palace /path/to/palace]" not in captured.out
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 "Optional custom palace:" not in captured.out
assert "[--palace /path/to/palace]" not in captured.out
assert captured.err == ""
def test_main_hook_no_subcommand_prints_help(capsys): def test_main_hook_no_subcommand_prints_help(capsys):
with patch("sys.argv", ["mempalace", "hook"]): with patch("sys.argv", ["mempalace", "hook"]):
main() main()