Skip to content

fix: synchronize MCP broker startup#1273

Merged
joshuajbouw merged 4 commits into
mainfrom
fix/mcp-broker-readiness
Jul 19, 2026
Merged

fix: synchronize MCP broker startup#1273
joshuajbouw merged 4 commits into
mainfrom
fix/mcp-broker-readiness

Conversation

@joshuajbouw

@joshuajbouw joshuajbouw commented Jul 19, 2026

Copy link
Copy Markdown
Member

Linked Issue

Closes #1272

Summary

Gate astrid mcp serve on a real response from a named principal's generic MCP
broker path. This prevents an immediate client request from being dropped while
a non-default principal's capsules are still warming after global daemon
readiness. Explicit anonymous remains the intentional transport-only,
no-capability mode and does not wait for a broker it cannot own.

Changes

  • Add a principal-scoped, idempotent tools/list readiness probe before MCP
    stdio is exposed for named principals.
  • Replay an unanswered probe when the principal's capsules_loaded signal
    arrives, with a wall-clock-driven three-second retry fallback that cannot be
    starved by unrelated broker traffic and the existing 55-second reply budget.
  • Preserve explicit anonymous MCP initialization without weakening broker
    readiness for any named agent principal.
  • Add deterministic cold-start, warm-broker, noisy-frame retry,
    principal-isolation, and anonymous-boundary tests and document the fix under
    [Unreleased].

Verification

  • cargo fmt --all -- --check
  • cargo test --locked -p astrid --bin astrid commands::mcp:: -- --quiet
  • cargo test --workspace -- --quiet
  • cargo clippy --workspace --all-features --all-targets --locked -- -D warnings
  • git diff --check
  • Cold-start integration smoke through the installed Unicity AOS Codex plugin:
    send MCP initialize, notifications/initialized, and tools/list
    immediately for codex-code; readiness is confirmed and tools/list
    returns instead of hanging.

Checklist

  • Linked to an issue
  • CHANGELOG.md updated (entry under [Unreleased] — or [Unreleased] rolled into a version section for a release PR; not applicable to docs/CI-only changes)

Copilot AI review requested due to automatic review settings July 19, 2026 14:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a startup race in astrid mcp serve where an immediate client tools/list can be dropped if the authenticated (non-default) principal’s MCP broker capsule hasn’t subscribed yet. It adds a principal-scoped readiness gate that proves the generic broker request path responds before exposing MCP stdio, aligning behavior with the issue’s acceptance criteria.

Changes:

  • Add a principal-scoped tools/list readiness probe that gates MCP stdio startup and replays the probe on capsules_loaded (with a retry fallback).
  • Wire the readiness gate into the mcp serve startup sequence (before starting the stdio transport).
  • Document the behavioral fix in CHANGELOG.md under [Unreleased].

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
crates/astrid-cli/src/commands/mcp/readiness.rs Implements principal-scoped broker readiness probing (probe/retry/replay) plus deterministic unit tests.
crates/astrid-cli/src/commands/mcp/mod.rs Calls the readiness gate before exposing MCP stdio during astrid mcp serve.
CHANGELOG.md Adds an [Unreleased] entry describing the fixed cold-start race and new readiness behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/astrid-cli/src/commands/mcp/readiness.rs
@joshuajbouw
joshuajbouw merged commit b5f4fc9 into main Jul 19, 2026
27 checks passed
@joshuajbouw
joshuajbouw deleted the fix/mcp-broker-readiness branch July 19, 2026 16:23
joshuajbouw added a commit that referenced this pull request Jul 19, 2026
## Linked Issue

Closes #1274

## Summary

Prepare Astrid Runtime `0.10.2` as the immutable patch candidate
containing the
MCP broker cold-start readiness fix from #1273.

## Changes

- roll the reviewed MCP readiness fix into `0.10.2`
- update the workspace and internal dependency versions to `0.10.2`
- roll `[Unreleased]` into the dated `0.10.2` changelog section
- keep the next nightly base unchanged

## Verification

- `cargo fmt --all -- --check`
- `cargo test --workspace --locked -- --quiet`
- `cargo clippy --workspace --all-features --all-targets --locked -- -D
warnings`
- release CI on the exact version and changelog commit
- no runtime code changes beyond the already reviewed and tested fix in
#1273

## Checklist

- [x] Linked to an issue
- [x] CHANGELOG.md rolled into the `0.10.2` release section
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP serve can drop the first tools request during principal warmup

2 participants