#!/bin/sh # Adds the Editing Engine to Claude Code for every project, and lets its tools run without asking each time. # curl -fsSL https://editing-engine.tail1ac0d5.ts.net/install.sh | sh # Claude Code won't change its own settings from inside a session in auto mode, so this runs in a terminal instead. set -e URL="https://editing-engine.tail1ac0d5.ts.net/mcp" NAME=editing-engine RULE="mcp__$NAME" # Edit a JSON file in place: jq where it's installed (macOS 15 and later), else JavaScript through osascript. edit_json() { # file, jq filter, JavaScript statement on `d` [ -s "$1" ] || echo '{}' > "$1" if command -v jq >/dev/null 2>&1; then jq --arg url "$URL" --arg name "$NAME" --arg rule "$RULE" "$2" "$1" > "$1.tmp" && mv "$1.tmp" "$1" else F="$1" URL="$URL" NAME="$NAME" RULE="$RULE" osascript -l JavaScript -e " ObjC.import('Foundation'); const env = (k) => \$.NSProcessInfo.processInfo.environment.objectForKey(k).js; const [f, url, name, rule] = ['F', 'URL', 'NAME', 'RULE'].map(env); const d = JSON.parse(\$.NSString.stringWithContentsOfFileEncodingError(f, \$.NSUTF8StringEncoding, null).js); $3; \$(JSON.stringify(d, null, 2)).writeToFileAtomicallyEncodingError(f, true, \$.NSUTF8StringEncoding, null);" >/dev/null fi } mkdir -p "$HOME/.claude" if command -v claude >/dev/null 2>&1; then claude mcp remove "$NAME" --scope user >/dev/null 2>&1 || true claude mcp add --transport http --scope user "$NAME" "$URL" >/dev/null else # Only the Claude desktop app, no claude command: write the same entry claude mcp add would. edit_json "$HOME/.claude.json" '.mcpServers[$name] = {type: "http", url: $url}' \ "d.mcpServers = d.mcpServers || {}; d.mcpServers[name] = {type: 'http', url: url}" fi edit_json "$HOME/.claude/settings.json" '.permissions.allow = ((.permissions.allow // []) + [$rule] | unique)' \ "d.permissions = d.permissions || {}; d.permissions.allow = [...new Set([...(d.permissions.allow || []), rule])]" echo "Added the Editing Engine to Claude Code ($URL), with its tools always allowed." echo "Next: sign in. In a terminal, start claude, run /mcp, pick $NAME and choose Authenticate." echo "In the Claude desktop app, open a new session and connect $NAME when it asks."