Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

mcp: status --check checks the recorded URL without an enrollment

Claude3dbe98ed97db
diff --git a/cli/beacon/cmd/mcp_connect.go b/cli/beacon/cmd/mcp_connect.go
index 49ee3ec5..05e35fbc 100644
--- a/cli/beacon/cmd/mcp_connect.go
+++ b/cli/beacon/cmd/mcp_connect.go
@@ -509,15 +509,20 @@ func runMCPStatus(cmd *cobra.Command, args []string) error {
return err
}
report := mcpStatusReport{ServerName: mcpconnect.ServerName}
- if url, derived, err := mcpconnect.ResolveURL(mcpConnectOpts.url, mcpIngestURL()); err == nil {
- report.URL = url
+ url, derived, err := mcpconnect.ResolveURL(mcpConnectOpts.url, mcpIngestURL())
+ recorded := mcpconnect.RecordedURL(home)
+ switch {
+ case err != nil && recorded != "":
+ // No --url and no enrollment, but connect has written a URL: that is the one to report
+ // and, with --check, to check. It was given explicitly, so it must match exactly.
+ url, derived, err = recorded, false, nil
+ case err == nil && derived && recorded != "" && !mcpConnectOpts.check:
// Without --check nothing is fetched, so a derived URL cannot be turned into the
// canonical one; compare against the URL connect checked and wrote instead.
- if derived && !mcpConnectOpts.check {
- if recorded := mcpconnect.RecordedURL(home); recorded != "" {
- report.URL = recorded
- }
- }
+ url = recorded
+ }
+ if err == nil {
+ report.URL = url
if mcpConnectOpts.check {
if canonical, err := mcpconnect.CheckURL(cmd.Context(), mcpHTTPClient, url, derived); err != nil {
report.Check = "failed: " + err.Error()
@@ -525,8 +530,6 @@ func runMCPStatus(cmd *cobra.Command, args []string) error {
report.URL, report.Check = canonical, "ok"
}
}
- } else if recorded := mcpconnect.RecordedURL(home); recorded != "" && !mcpConnectOpts.check {
- report.URL = recorded
} else if mcpConnectOpts.check {
report.Check = "failed: " + err.Error()
}
diff --git a/cli/beacon/cmd/mcp_connect_test.go b/cli/beacon/cmd/mcp_connect_test.go
index d1f45f5a..61015a09 100644
--- a/cli/beacon/cmd/mcp_connect_test.go
+++ b/cli/beacon/cmd/mcp_connect_test.go
@@ -559,3 +559,24 @@ func TestMCPStatusFallsBackToTheRecordedURLWithoutAnEnrollment(t *testing.T) {
t.Fatalf("err = %v\n%s", err, stdout)
}
}
+
+// Regression: after `connect --url` on an endpoint with no enrollment, `status --check` must check
+// the URL connect wrote rather than fail for want of one.
+func TestMCPStatusCheckUsesTheRecordedURLWithoutAnEnrollment(t *testing.T) {
+ fx := newMCPFixture(t, "cursor")
+ if _, _, err := runMCP(t, "connect", "--url", fx.url, "--yes"); err != nil {
+ t.Fatal(err)
+ }
+ stdout, _, err := runMCP(t, "status", "--check")
+ if err != nil || !strings.Contains(stdout, "URL check: ok") || !strings.Contains(stdout, "Beacon Managed MCP URL: "+fx.url) {
+ t.Fatalf("err = %v\n%s", err, stdout)
+ }
+ // With nothing recorded and no enrollment, --check still fails, and says why.
+ if _, _, err := runMCP(t, "disconnect"); err != nil {
+ t.Fatal(err)
+ }
+ stdout, _, err = runMCP(t, "status", "--check")
+ if err == nil || !strings.Contains(stdout, "URL check: failed") {
+ t.Fatalf("err = %v\n%s", err, stdout)
+ }
+}