Skip to content

feat(cli): add async server wait workflow - #410

Open
xizhibei wants to merge 4 commits into
mainfrom
codex/issues-async-395-405
Open

feat(cli): add async server wait workflow#410
xizhibei wants to merge 4 commits into
mainfrom
codex/issues-async-395-405

Conversation

@xizhibei

@xizhibei xizhibei commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • expose deterministic startup loading states through authenticated, filtered inspect responses
  • add 1mcp wait [server] and status-aware run behavior that never falls through to an unsafe early MCP session
  • correct async-startup guidance and add matching English/Chinese command documentation

Validation

  • pnpm lint
  • pnpm typecheck
  • pnpm build
  • pnpm docs:build
  • pnpm test:unit (298 files, 4,333 tests)

Existing Vitest mock-hoisting, VitePress highlighting/chunk-size, and Node deprecation warnings remain unchanged.

Closes #395
Closes #405

Summary by CodeRabbit

  • New Features

    • Added a wait CLI command to monitor configured static servers until they are connected and available.
    • Added structured status reporting for loading, authorization, failure, and timeout states.
    • Enhanced run and inspect workflows with clearer server readiness and recovery guidance.
    • Added text, JSON, and TOON output options for waiting results.
  • Documentation

    • Added English and Chinese documentation for the wait command.
    • Updated startup, inspection, and run workflow guidance to reflect asynchronous server loading and status checks.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@xizhibei, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 42 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 42e4e948-f12e-48fe-811e-e9f449141ff3

📥 Commits

Reviewing files that changed from the base of the PR and between 780bbe3 and 7986931.

📒 Files selected for processing (20)
  • docs/en/commands/index.md
  • docs/en/commands/inspect.md
  • docs/en/commands/wait.md
  • docs/en/guide/advanced/fast-startup.md
  • docs/zh/commands/index.md
  • docs/zh/commands/inspect.md
  • docs/zh/commands/run.md
  • docs/zh/commands/wait.md
  • docs/zh/guide/advanced/fast-startup.md
  • src/commands/run/run.rest-primary.test.ts
  • src/commands/run/run.ts
  • src/commands/shared/clientSurfaceAttachment.test.ts
  • src/commands/shared/clientSurfaceAttachment.ts
  • src/commands/wait/index.ts
  • src/commands/wait/wait.test.ts
  • src/commands/wait/wait.ts
  • src/transport/http/routes/apiRoutes.test.ts
  • src/transport/http/routes/inspectRoutes.ts
  • test/e2e/commands/inspect.test.ts
  • test/unit-utils/MockFactories.ts
📝 Walkthrough

Walkthrough

This change adds load-aware inspect status contracts, a new wait CLI workflow, REST readiness checks for run, updated output schemas and formatting, HTTP coverage, and English/Chinese documentation for asynchronous server loading.

Changes

Async loading workflow

Layer / File(s) Summary
Status contracts and inspect query plumbing
src/types/serverStatus.ts, src/commands/shared/inspectApiSchemas.ts, src/commands/shared/filterSelectionQuery.ts, src/commands/shared/apiClient.ts, src/commands/inspect/*
Adds shared server statuses, Zod inspect schemas, reusable filter query construction, request-scoped GET options, and load-related inspect output fields.
Loading-aware inspect endpoint
src/transport/http/routes/inspectHelpers.ts, src/transport/http/routes/inspectRoutes.ts, src/transport/http/routes/*test.ts
Inspect responses now include tracked-server state, loading precedence, availability, authorization details, errors, and empty tool inventories before readiness.
Wait command and CLI wiring
src/commands/wait/*, src/commands/shared/clientSurfaceAttachment.ts, src/commands/shared/commandRunner.ts, src/commands/instructions/instructionsUtils.ts, src/index.ts
Adds 1mcp wait [server] with polling, filtering, timeout and terminal-state handling, structured output, REST retry behavior, and instruction playbook updates.
Run REST readiness checks
src/commands/run/run.ts, src/commands/run/*.test.ts
run checks inspect status before REST-to-MCP fallback, reports loading or unavailable states, and validates filtered tool responses with shared schemas.
Async loading and CLI workflow documentation
README.md, docs/en/..., docs/zh/..., docs/.vitepress/config/*
Documents async catalog publication, authenticated inspect status, wait and run behavior, health endpoints, and adds English and Chinese wait navigation and pages.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI as wait CLI
  participant Surface as Reusable client surface
  participant Inspect as /api/v1/inspect
  participant Runtime as Loading tracker
  CLI->>Surface: start authenticated wait workflow
  Surface->>Inspect: poll tracked server status
  Inspect->>Runtime: read loading state
  Runtime-->>Inspect: return status and availability
  Inspect-->>CLI: return connected, terminal, or timeout result
Loading

Possibly related PRs

  • 1mcp-app/agent#282: Provides the CLI mode and shared command plumbing extended by this workflow.
  • 1mcp-app/agent#326: Provides the reusable client-surface architecture extended for wait and forced REST checks.
  • 1mcp-app/agent#332: Provides loading-manager behavior surfaced through inspect status fields.

Poem

A rabbit polls beneath the moon,
“Connected servers will arrive soon!”
With wait and status neatly shown,
REST guards tools before they’re known.
Hop, hop—the catalog blooms!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 2.44% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main CLI wait workflow change.
Linked Issues check ✅ Passed The PR covers #395 and #405 with async-loading docs, inspect/status updates, a wait command, safer run fallback, and matching tests.
Out of Scope Changes check ✅ Passed The changes stay focused on the async startup/status workflow and related docs/tests, with no clear unrelated additions.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/issues-async-395-405

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (2)
docs/zh/commands/inspect.md (1)

21-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Bring the edited public command pages into the documentation contract.

  • docs/zh/commands/inspect.md#L21-L21: Add frontmatter and replace ./wait.md with the absolute /zh/commands/wait link.
  • docs/zh/commands/run.md#L23-L23: Add required frontmatter.

As per coding guidelines, “Include frontmatter for all public documentation pages” and “Use absolute internal links in documentation.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/zh/commands/inspect.md` at line 21, Update docs/zh/commands/inspect.md
at lines 21-21 by adding the required frontmatter and replacing the relative
./wait.md link with the absolute /zh/commands/wait link. Update
docs/zh/commands/run.md at lines 23-23 by adding the required frontmatter,
following the existing public documentation page conventions.

Source: Coding guidelines

src/commands/shared/clientSurfaceAttachment.test.ts (1)

194-215: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the shared mock factories for the new test fixtures.

  • src/commands/shared/clientSurfaceAttachment.test.ts#L194-L215: Create the cached-session fixture through test/unit-utils/MockFactories.ts, extending it if needed.
  • src/commands/wait/wait.test.ts#L7-L39: Create the attachment context and inspect-response fixture data through the shared factories.

As per coding guidelines, “Use test/unit-utils/MockFactories.ts for consistent mock data and mock factories.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands/shared/clientSurfaceAttachment.test.ts` around lines 194 - 215,
Use the shared mock factories from test/unit-utils/MockFactories.ts for both
affected test fixtures: in src/commands/shared/clientSurfaceAttachment.test.ts
lines 194-215, create the cached-session data through the appropriate factory
and extend it with required fields; in src/commands/wait/wait.test.ts lines
7-39, create the attachment context and inspect-response data through the shared
factories. Preserve each test’s existing behavior and assertions.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/en/commands/index.md`:
- Line 82: Update docs/en/commands/index.md lines 82-82 to describe wait as
waiting for configured static servers to become connected and available. Update
docs/en/commands/inspect.md lines 36-36 to state that scripts wait for servers
to be connected and available, and replace the relative ./wait.md link with the
absolute internal /commands/wait link.

In `@docs/en/guide/advanced/fast-startup.md`:
- Line 65: Update the readiness descriptions for the connected state in
docs/en/guide/advanced/fast-startup.md lines 65-65 and
docs/zh/guide/advanced/fast-startup.md lines 65-65 to clarify that tool
invocation requires both connected and available, not connected alone; preserve
the respective English and Chinese wording.

In `@src/commands/run/run.ts`:
- Around line 256-334: Update the status dispatch around the existing
connected-and-available check to explicitly handle server.status === 'connected'
with server.available === false. Route this transitional state through
statusErrorResponse using server_loading semantics, with guidance to wait for
the server to become available rather than suggesting a restart; leave the
existing pending/loading, OAuth, and generic unavailable branches unchanged.

In `@src/commands/wait/wait.ts`:
- Around line 69-70: Update the status handling around the wait command’s
attachment check to handle auth_required separately, preserving its original
error code and the context-aware recovery guidance from
formatClientSurfaceAuthRequiredMessage. Only non-authentication failures should
continue throwing server_status_unavailable with 1mcp inspect.
- Around line 47-55: Update waitCommand to validate and normalize the complete
WaitCommandOptions object with the project’s Zod schema before reading timeout
or starting attachment/polling. Include timeout, filter/tag, and format fields
in the boundary validation, then use the parsed options for subsequent logic
while preserving the existing positive-timeout requirement and WaitCommandError
behavior.

In `@src/transport/http/routes/inspectRoutes.ts`:
- Around line 435-454: Apply the same target authorization or scope gate used
for tool targets before the static-server early return in the inspect route.
Ensure out-of-scope static servers return 404 before exposing status,
authorizationUrl, or error metadata, while preserving the existing payload for
authorized static servers.

---

Nitpick comments:
In `@docs/zh/commands/inspect.md`:
- Line 21: Update docs/zh/commands/inspect.md at lines 21-21 by adding the
required frontmatter and replacing the relative ./wait.md link with the absolute
/zh/commands/wait link. Update docs/zh/commands/run.md at lines 23-23 by adding
the required frontmatter, following the existing public documentation page
conventions.

In `@src/commands/shared/clientSurfaceAttachment.test.ts`:
- Around line 194-215: Use the shared mock factories from
test/unit-utils/MockFactories.ts for both affected test fixtures: in
src/commands/shared/clientSurfaceAttachment.test.ts lines 194-215, create the
cached-session data through the appropriate factory and extend it with required
fields; in src/commands/wait/wait.test.ts lines 7-39, create the attachment
context and inspect-response data through the shared factories. Preserve each
test’s existing behavior and assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7566ba78-fdb3-4ec3-982b-cbde8db4b728

📥 Commits

Reviewing files that changed from the base of the PR and between d31877a and 780bbe3.

📒 Files selected for processing (36)
  • README.md
  • docs/.vitepress/config/en.ts
  • docs/.vitepress/config/zh.ts
  • docs/en/commands/index.md
  • docs/en/commands/inspect.md
  • docs/en/commands/run.md
  • docs/en/commands/wait.md
  • docs/en/guide/advanced/fast-startup.md
  • docs/zh/commands/index.md
  • docs/zh/commands/inspect.md
  • docs/zh/commands/run.md
  • docs/zh/commands/wait.md
  • docs/zh/guide/advanced/fast-startup.md
  • src/commands/inspect/inspect.ts
  • src/commands/inspect/inspectUtils.ts
  • src/commands/instructions/instructionsUtils.ts
  • src/commands/run/run.rest-errors.test.ts
  • src/commands/run/run.rest-fallback.test.ts
  • src/commands/run/run.rest-primary.test.ts
  • src/commands/run/run.ts
  • src/commands/shared/apiClient.ts
  • src/commands/shared/clientSurfaceAttachment.test.ts
  • src/commands/shared/clientSurfaceAttachment.ts
  • src/commands/shared/commandRunner.test.ts
  • src/commands/shared/commandRunner.ts
  • src/commands/shared/filterSelectionQuery.ts
  • src/commands/shared/inspectApiSchemas.ts
  • src/commands/wait/index.ts
  • src/commands/wait/wait.test.ts
  • src/commands/wait/wait.ts
  • src/index.ts
  • src/transport/http/routes/apiRoutes.test.ts
  • src/transport/http/routes/inspectHelpers.test.ts
  • src/transport/http/routes/inspectHelpers.ts
  • src/transport/http/routes/inspectRoutes.ts
  • src/types/serverStatus.ts

Comment thread docs/en/commands/index.md Outdated
Comment thread docs/en/guide/advanced/fast-startup.md Outdated
Comment thread src/commands/run/run.ts
Comment thread src/commands/wait/wait.ts
Comment thread src/commands/wait/wait.ts
Comment thread src/transport/http/routes/inspectRoutes.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant