forked from doobidoo/mcp-memory-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.py
More file actions
executable file
·141 lines (112 loc) · 4.47 KB
/
install.py
File metadata and controls
executable file
·141 lines (112 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/usr/bin/env python3
"""
Root-level install.py for mcp-memory-service.
This script exists to help users who follow the wiki installation guide
(https://github.com/doobidoo/mcp-memory-service/wiki/01-Installation-Guide)
and run `python install.py` from the repository root.
It delegates to the appropriate installer based on what the user needs:
- Python package installer: scripts/installation/install.py
- Claude Code hooks installer: claude-hooks/install_hooks.py
Usage:
python install.py # Interactive menu
python install.py --package # Install Python package (delegates to scripts/installation/install.py)
python install.py --hooks # Install Claude Code hooks (delegates to claude-hooks/install_hooks.py)
python install.py --help # Show this help
"""
import sys
import subprocess
from pathlib import Path
REPO_ROOT = Path(__file__).parent.resolve()
PACKAGE_INSTALLER = REPO_ROOT / "scripts" / "installation" / "install.py"
HOOKS_INSTALLER = REPO_ROOT / "claude-hooks" / "install_hooks.py"
def print_banner():
print()
print("=" * 60)
print(" mcp-memory-service installer")
print("=" * 60)
print()
def print_python313_warning():
"""Warn users about known safetensors / Python 3.13 issues."""
if sys.version_info >= (3, 13):
print("WARNING: You are running Python 3.13.")
print(" Some dependencies (e.g. safetensors) may not yet support")
print(" Python 3.13 and could cause installation failures.")
print()
print(" Recommended: Use Python 3.11 or 3.12 for best compatibility.")
print(" See docs: https://github.com/doobidoo/mcp-memory-service/wiki")
print(" or docs/first-time-setup.md")
print()
def run_installer(script_path: Path, extra_args: list) -> int:
"""Run a sub-installer and return its exit code."""
if not script_path.exists():
print(f"ERROR: Installer not found: {script_path}")
print(" This is likely a bug. Please report it at:")
print(" https://github.com/doobidoo/mcp-memory-service/issues")
return 1
cmd = [sys.executable, str(script_path)] + extra_args
print(f"Running: {' '.join(cmd)}")
print()
result = subprocess.run(cmd, check=False)
return result.returncode
def show_help():
print(__doc__)
def interactive_menu() -> int:
"""Show an interactive menu and delegate to the chosen installer."""
print("This project has two separate installation options:")
print()
print(" 1. Python package installation")
print(" Installs the mcp-memory-service Python package and its")
print(" dependencies using pip/uv.")
print(" Script: scripts/installation/install.py")
print()
print(" 2. Claude Code hooks installation")
print(" Installs memory awareness hooks for Claude Code (session-")
print(" start/end hooks, natural memory triggers, etc.).")
print(" Script: claude-hooks/install_hooks.py")
print()
print(" q. Quit")
print()
try:
choice = input("Enter choice [1/2/q]: ").strip().lower()
except (EOFError, KeyboardInterrupt):
print()
print("Aborted.")
return 0
print()
if choice == "1":
print("Delegating to: scripts/installation/install.py")
print()
return run_installer(PACKAGE_INSTALLER, [])
elif choice == "2":
print("Delegating to: claude-hooks/install_hooks.py")
print()
return run_installer(HOOKS_INSTALLER, [])
elif choice in ("q", "quit", "exit"):
print("Exiting.")
return 0
else:
print(f"Unknown choice: {choice!r}")
print("Run `python install.py --help` for usage.")
return 1
def main() -> int:
print_banner()
print_python313_warning()
args = sys.argv[1:]
# Pass-through: any unrecognised flags are forwarded to the package installer
if "--help" in args or "-h" in args:
show_help()
return 0
if "--hooks" in args:
extra = [a for a in args if a != "--hooks"]
print("Delegating to: claude-hooks/install_hooks.py")
print()
return run_installer(HOOKS_INSTALLER, extra)
if "--package" in args or args:
extra = [a for a in args if a != "--package"]
print("Delegating to: scripts/installation/install.py")
print()
return run_installer(PACKAGE_INSTALLER, extra)
# No flags - show interactive menu
return interactive_menu()
if __name__ == "__main__":
sys.exit(main())