Skip to content

feat: support experimental WebMCP client.reportProgress and ensure de… - #3

Merged
andreban merged 1 commit into
mainfrom
feature/webmcp-client-report-progress
May 22, 2026
Merged

andreban merged 1 commit into
mainfrom
feature/webmcp-client-report-progress

Conversation

@andreban

@andreban andreban commented May 22, 2026 •

Copy link
Copy Markdown
Owner

Description

This Pull Request implements support for WebMCP's experimental client-side progress reporting feature and fixes delegation tool registration to ensure they are always discoverable by external browser agents.

🚀 Key Changes

  1. WebMCP client.reportProgress Integration (src/lib/WebMCPTools.ts):

    • Updated the execute function signature for registered WebMCP tools to support an optional second parameter: client?: { reportProgress?: (message: string) => void }.
    • Updated the tool runtime's ToolContext.onEvent to automatically stream raw, structured AgentEvent objects directly as a serialized string using JSON.stringify(event) to client.reportProgress.
    • Handled filtering to exclude completion done events (since the final payload is returned via the execution result).
  2. Unconditional Delegation Tool Discovery (src/context/MCPProvider.tsx):

    • Removed the restrictive if (!factory) return; check that was preventing delegation tools (delegate_to_skill, invoke_agent, invoke_planner, invoke_researcher, invoke_writer, invoke_reviewer) from being registered when no local Gemini API key was present on initial mount.
    • Switched to utilizing the stable fallback runner factory (workspaceCtx.factory) so that delegation tools are always advertised to and discoverable by external agents driving the workspace.
  3. Robust Test Environment Setup (src/test/setup.ts):

    • Appended a complete and standard mock for localStorage in the JSDOM Vitest environment, resolving TypeError: localStorage.clear is not a function errors and restoring the entire test suite baseline to 100% health.

🧪 Verification

  • Added Integration Test (src/lib/WebMCPTools.test.ts): Added a test verifying that progress callbacks (client.reportProgress) are correctly called with JSON-serialized AgentEvent strings representing the intermediate thinking steps and text deltas.
  • Green Test Suite: Verified that all 255 unit and integration tests are passing successfully.
  • Linting and Formatting: Confirmed that code is completely lint-free and Prettier formatted.

@andreban
andreban force-pushed the feature/webmcp-client-report-progress branch from 7437b9a to 4f4853d Compare May 22, 2026 09:43
Comment thread src/lib/WebMCPTools.ts
: {};
const ctx: ToolContext = {
onEvent: (event: AgentEvent) => {
if (event.type === "done") return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why not reporting it?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

That's generally the same as the function returning.

@andreban
andreban merged commit 6e722cc into main May 22, 2026
1 check 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.

2 participants