Skip to content

Enhance tool validation with parallel processing and live progress#114

Merged
Minitour merged 3 commits into
mainfrom
develop
Jun 11, 2026
Merged

Enhance tool validation with parallel processing and live progress#114
Minitour merged 3 commits into
mainfrom
develop

Conversation

@Minitour

Copy link
Copy Markdown
Collaborator

This pull request implements live progress streaming for the project configuration process, improving the user experience for large projects by providing real-time feedback during OAuth2 detection and tool validation. It introduces an NDJSON streaming mode to the /api/projects/:id/configure endpoint, updates the CLI to consume and display progress events, and refactors the server-side logic to emit and handle these events. The final response payload remains unchanged for compatibility.

Live progress streaming for project configuration:

  • Added support for NDJSON streaming in the /api/projects/:id/configure endpoint, allowing the server to emit progress events during OAuth2 detection and tool validation. This enables clients to display live counters and status updates instead of a static spinner. [1] [2] [3] [4]

  • Introduced the ValidationProgressEvent type to standardize progress events emitted during tool validation, including initialization and per-server completion events.

CLI enhancements for progress streaming:

  • Updated the CLI (configureToolsTask in configure-tools.ts) to request NDJSON streaming by setting the Accept header, and to consume and process the streamed progress events, rendering live progress updates in the UI. [1] [2] [3]

  • Exported the TaskWrapper type from the CLI UI utilities to support live task output updates during streaming. [1] [2]

General improvements and refactoring:

  • Refactored the project configuration logic to separate streaming and non-streaming response paths, ensuring backward compatibility and code clarity. [1] [2] [3] [4]

These changes collectively provide a more responsive and informative CLI experience for users configuring projects with many tools and servers, while maintaining compatibility with existing clients.

Minitour and others added 3 commits June 11, 2026 12:39
`capa install` for a 65-tool / 6-server project dropped from ~62s to ~4.8s
(~13x) and now shows a live "N/M validated · last-server ✓" counter
instead of a static spinner.

- `validateTools` groups MCP tools by server and fans out one `listTools`
  per server with `Promise.all`, then matches expected names against the
  returned set in memory. Accepts an optional `onProgress` callback and
  emits `validation_init` / `server_done` events.
- `handleProjectConfigure` extracted into `runProjectConfigure(...)` so
  the existing logic can be reused with progress hooks. OAuth2 detection
  now runs in parallel across servers.
- The endpoint emits NDJSON progress events when the client sends
  `Accept: application/x-ndjson`; otherwise it returns the same single
  JSON body as before — fully backward compatible.
- The CLI's configure-tools task consumes the NDJSON stream and updates
  `task.output` per event, with a graceful fallback to `response.json()`
  for older servers.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Two issues raised by review on the streaming branch of
handleProjectConfigure:

1. After `cancel()`, `controllerRef` was nulled and subsequent `emit`
   calls fell through to `pending.push(...)` — but `start()` will never
   run again, so the buffer grew unbounded for the rest of the (possibly
   long-running) runProjectConfigure work.
2. The `work.then(...)` completion handler called `controller.enqueue`
   and `controller.close` without try/catch. If the client disconnected
   before completion, both throw and surface as an unhandled rejection.

Fix: collapse the two paths through a single `writeLine` that respects
a `streamClosed` flag, set both on client cancel and on terminal write,
and drop the pending buffer on cancel.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
perf(install): parallelize tool validation and stream live progress
@Minitour Minitour merged commit e464f83 into main Jun 11, 2026
14 checks passed
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.

1 participant