-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·55 lines (49 loc) · 1.73 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·55 lines (49 loc) · 1.73 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
#!/usr/bin/env bash
#
# Install the cowork2code CLI and register its local MCP server with Claude Code.
#
# Set COWORK_RESUME_DRYRUN=1 to print the actions without making changes.
#
set -euo pipefail
REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BIN_DIR="${HOME}/.local/bin"
DRYRUN="${COWORK_RESUME_DRYRUN:-}"
run() {
if [ -n "$DRYRUN" ]; then echo "+ $*"; else "$@"; fi
}
command -v python3 >/dev/null 2>&1 || { echo "python3 (>=3.10) is required" >&2; exit 1; }
# 1. Install the CLI shim with the repo path baked in.
SHIM="${BIN_DIR}/cowork2code"
if [ -n "$DRYRUN" ]; then
echo "+ mkdir -p ${BIN_DIR}"
echo "+ write ${SHIM} (PYTHONPATH=${REPO}; exec python3 -m cowork2code.cli)"
else
mkdir -p "${BIN_DIR}"
cat > "${SHIM}" <<EOF
#!/usr/bin/env bash
export PYTHONPATH="${REPO}:\${PYTHONPATH:-}"
exec python3 -m cowork2code.cli "\$@"
EOF
chmod +x "${SHIM}"
fi
echo "CLI: ${SHIM}"
# 2. Register the MCP server with Claude Code (user scope).
# Remove any prior registration first so re-running install.sh updates rather
# than aborting on "MCP server already exists".
MCP="${REPO}/cowork2code_mcp.py"
if [ -n "$DRYRUN" ]; then
echo "+ claude mcp remove cowork2code --scope user (ignored if absent)"
else
claude mcp remove cowork2code --scope user >/dev/null 2>&1 || true
fi
if command -v uv >/dev/null 2>&1; then
run claude mcp add cowork2code --scope user -- uv run --quiet "${MCP}"
else
echo "note: 'uv' not found; the MCP server needs 'pip install mcp' to run" >&2
run claude mcp add cowork2code --scope user -- python3 "${MCP}"
fi
echo
echo "Done."
echo " - Ensure ${BIN_DIR} is on your PATH."
echo " - Try: cowork2code list"
echo " - In Claude Code, the 'cowork2code' MCP exposes cowork_session_list and cowork_session_rehome."