The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
fix(mcp): disconnect recorded entries when the config path no longer resolves
Kyle Elliott482d4b9d4634
diff --git a/cli/beacon/internal/mcpconnect/engine.go b/cli/beacon/internal/mcpconnect/engine.goindex c18d8018..4bfc2c61 100644--- a/cli/beacon/internal/mcpconnect/engine.go+++ b/cli/beacon/internal/mcpconnect/engine.go@@ -673,17 +673,16 @@ func Disconnect(ctx context.Context, opts Options, targets []Target) ([]Item, erif !t.Automatic {continue}- path, err := t.path(opts.Home)- if err != nil {- continue- }- it := Item{Target: t, Path: path}- // Records are matched by harness and file. A harness whose config moved (CODEX_HOME,- // CLAUDE_CONFIG_DIR) is still cleaned up at the path Beacon wrote.+ // Records are matched by harness and carry the file Beacon wrote, so a harness whose+ // config has since moved (CODEX_HOME, CLAUDE_CONFIG_DIR, an Oh My Pi profile) or no longer+ // resolves at all is still cleaned up there.recs := recordsFor(m, t.Name)if len(recs) == 0 {- it.Action, it.Detail = ActionAbsent, "nothing written by Beacon"- items = append(items, it)+ path, err := t.path(opts.Home)+ if err != nil {+ continue+ }+ items = append(items, Item{Target: t, Path: path, Action: ActionAbsent, Detail: "nothing written by Beacon"})continue}for _, rec := range recs {diff --git a/cli/beacon/internal/mcpconnect/harness_test.go b/cli/beacon/internal/mcpconnect/harness_test.goindex f8c1b001..0c39642f 100644--- a/cli/beacon/internal/mcpconnect/harness_test.go+++ b/cli/beacon/internal/mcpconnect/harness_test.go@@ -1131,6 +1131,24 @@ func TestOhMyPiConnectWritesTheActiveProfileOnly(t *testing.T) {}}+// Disconnect works from what connect recorded, not from where the config would resolve now, so a+// profile variable that has since become invalid cannot leave Beacon's entry behind.+func TestDisconnectRemovesARecordedEntryWhenThePathNoLongerResolves(t *testing.T) {+ home := isolate(t)+ target := mustTarget(t, "omp")+ t.Setenv("OMP_PROFILE", "work")+ connect(t, fileOptions(home), target)+ path := filepath.Join(home, ".omp", "profiles", "work", "agent", "mcp.json")++ t.Setenv("OMP_PROFILE", "../escape")+ if got := disconnect(t, fileOptions(home), target); got.Action != ActionRemove || got.Path != path {+ t.Fatalf("disconnect = %s at %q (%s), want remove at %q", got.Action, got.Path, got.Detail, path)+ }+ if _, err := os.Stat(path); !os.IsNotExist(err) {+ t.Fatalf("disconnect left the file connect created: %v", err)+ }+}+// A harness that switches servers off with `enabled` inside the entry gets the person's value// back on every write: re-running connect, or changing auth mode, must not turn beacon-managed// back on.