Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(wrapper): run mcp-bridge through the native host client
AkitaOnRails135ce8d93806
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2c9359fc..47b7b57e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]### Fixed+- Fixed the session-aware MCP bridge failing on Docker-wrapper installs: the+ wrapper sent `mcp-bridge` to the helper container, where the registered+ `127.0.0.1` server URL is unreachable, so every session started without+ ai-memory's MCP tools. The wrapper now runs `mcp-bridge` through its+ checksum-verified native host client, which also repairs existing entries.+ (#1147)- Fixed the scheduled auto-improve tests' intermittent empty log captures(the same latent flaw #1116 fixed for the hooks checkpoint test): a shared`warn!` callsite's first-in-process execution on a bare thread cachesdiff --git a/bin/ai-memory b/bin/ai-memoryindex df3f98eb..274ae17e 100755--- a/bin/ai-memory+++ b/bin/ai-memory@@ -15,6 +15,9 @@# ai-memory workstreams Use that client to inspect the host checkout identity.# ai-memory rename-workstream# Same: the rename is keyed on host repo identity.+# ai-memory mcp-bridge ... Run the session-aware MCP bridge through that+# client: its --server-url loopback only resolves on+# the host, never inside the helper container.## Env overrides:# AI_MEMORY_IMAGE container image (default: docker.io/akitaonrails/ai-memory:latest)@@ -586,6 +589,15 @@ case "${1:-}" in;;esac;;+ mcp-bridge)+ # The session-aware MCP bridge dials the explicit --server-url it was+ # registered with, typically the host's 127.0.0.1:49374. Inside the+ # helper container that loopback is the container itself (Docker Desktop+ # has no host networking), so the bridge must run on the host through+ # the same checksum-verified native client install-hooks uses.+ NATIVE_HOST_BIN=$(native_host_binary)+ exec "${NATIVE_HOST_BIN}" "$@"+ ;;esac# ---- normal pass-through to the binary inside a container ----------------diff --git a/docs/install.md b/docs/install.mdindex 24c7e6ad..a89bb289 100644--- a/docs/install.md+++ b/docs/install.md@@ -135,7 +135,9 @@ ai-memory install-mcp --client claude-code --session-aware --applyIt replaces the static HTTP MCP entry with a local ai-memory stdio bridge thatstill connects to the configured remote server and bearer token, while-forwarding Claude's lifecycle session id. Pair it with+forwarding Claude's lifecycle session id. On a Docker-wrapper install the+wrapper runs the bridge through its checksum-verified native host client, so+the configured loopback server URL resolves on the host. Pair it with`[auto_scope] mode = "per_session"` when the same operator runs concurrentClaude Code sessions in different projects. The default static HTTPregistration remains appropriate for one active project at a time.diff --git a/tests/wrapper_upgrade.sh b/tests/wrapper_upgrade.shindex fad5a044..a460ee1d 100755--- a/tests/wrapper_upgrade.sh+++ b/tests/wrapper_upgrade.sh@@ -238,4 +238,44 @@ else:run_version_check_case docker_classic_gated "docker" "x86_64" "${H_INDEX}" "" "" "${MULTI_ARCH_JSON}" 0fi+# ---- mcp-bridge native host routing (#1147) -------------------------------++# The session-aware MCP bridge must run on the host: its --server-url loopback+# is unreachable from inside the helper container on Docker Desktop. The+# wrapper must exec the checksum-verified native client without ever invoking+# the container engine.+BRIDGE_CASE_DIR="${TMP_ROOT}/mcp_bridge"+mkdir -p "${BRIDGE_CASE_DIR}/home" "${BRIDGE_CASE_DIR}/cache"++FAKE_NATIVE="${BRIDGE_CASE_DIR}/native-ai-memory"+cat >"${FAKE_NATIVE}" <<'NATIVE'+#!/usr/bin/env bash+printf '%s\n' "$*" >>"${AI_MEMORY_WRAPPER_TEST_LOG}"+NATIVE+chmod 0755 "${FAKE_NATIVE}"++BRIDGE_DOCKER="${BRIDGE_CASE_DIR}/docker"+cat >"${BRIDGE_DOCKER}" <<'DOCKER'+#!/usr/bin/env bash+printf '%s\n' "$*" >>"${AI_MEMORY_DOCKER_TEST_LOG}"+exit 0+DOCKER+chmod 0755 "${BRIDGE_DOCKER}"++: >"${BRIDGE_CASE_DIR}/native.log"+: >"${BRIDGE_CASE_DIR}/docker.log"+HOME="${BRIDGE_CASE_DIR}/home" \+XDG_CACHE_HOME="${BRIDGE_CASE_DIR}/cache" \+AI_MEMORY_DOCKER="${BRIDGE_DOCKER}" \+AI_MEMORY_NATIVE_BIN="${FAKE_NATIVE}" \+AI_MEMORY_WRAPPER_TEST_LOG="${BRIDGE_CASE_DIR}/native.log" \+AI_MEMORY_DOCKER_TEST_LOG="${BRIDGE_CASE_DIR}/docker.log" \+ "${ROOT}/bin/ai-memory" mcp-bridge --server-url http://127.0.0.1:49374/mcp </dev/null++assert_contains "${BRIDGE_CASE_DIR}/native.log" "mcp-bridge --server-url http://127.0.0.1:49374/mcp"+if [ -s "${BRIDGE_CASE_DIR}/docker.log" ]; then+ fail "mcp-bridge unexpectedly reached the container engine: $(cat "${BRIDGE_CASE_DIR}/docker.log")"+fi+printf 'wrapper mcp-bridge native routing checks passed\n'+printf 'wrapper upgrade ownership checks passed\n'