Skip to content

Commit 0b7a30e

Browse files
authored
fix: add broadcast MCP servers before and after OAuth connection establishment (#671)
1 parent c1bb26d commit 0b7a30e

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

packages/agents/src/index.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,14 +1537,20 @@ export class Agent<
15371537
const result = await this.mcp.handleCallbackRequest(request);
15381538

15391539
// If auth was successful, establish the connection in the background
1540-
// establishConnection() will fire onServerStateChanged event which triggers another broadcast
15411540
if (result.authSuccess) {
1542-
this.mcp.establishConnection(result.serverId).catch((error) => {
1543-
console.error(
1544-
"[Agent handleMcpOAuthCallback] Background connection failed:",
1545-
error
1546-
);
1547-
});
1541+
this.broadcastMcpServers();
1542+
1543+
this.mcp
1544+
.establishConnection(result.serverId)
1545+
.catch((error) => {
1546+
console.error(
1547+
"[Agent handleMcpOAuthCallback] Connection establishment failed:",
1548+
error
1549+
);
1550+
})
1551+
.finally(() => {
1552+
this.broadcastMcpServers();
1553+
});
15481554
}
15491555

15501556
// Return the HTTP response for the OAuth callback

0 commit comments

Comments
 (0)