fix(mcp-agent): surface initialization failures - #1960
Open
dvd233 wants to merge 1 commit into
Open
Conversation
✅ Deploy Preview for tarko ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for agent-tars-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
systemerror event when an MCP server cannot be constructed or initializedclose()idempotentWhy
MCPAgent.initialize()previously logged an MCP connection failure and immediately rethrew it. That stopped the server loop, prevented later MCP servers from becoming available, and left the Web UI without an initialization event it could render.The agent server already subscribes to the agent event stream before calling
initialize(), persists non-streaming events, returns initialization events from session creation, and the Web UI already renderssystemevents. Emitting the failure through that existing path therefore surfaces a clear error without adding a parallel UI-only error channel.The regression test was red on
main: initialization rejected on the first failed server instead of reaching the healthy server. It now verifies that:systemevent withlevel: "error"close()is called againRelated work
#1834 addresses a lower-level case where MCP tool-list errors can be swallowed. This PR handles the next layer: any propagated construction or initialization failure is surfaced to the event stream and isolated to that server. The changes are independent and merge cleanly.
Validation
vitest run --config vitest.config.mts— 3 passed, 4 existing snapshot tests skippedrslib build— ESM, CJS, and declaration outputCloses #1338
Checklist