* Executes an MCP auth handler and sends the result back via RPC. * @internal
(request: McpAuthRequest)
| 688 | * @internal |
| 689 | */ |
| 690 | private async _executeMcpAuthAndRespond(request: McpAuthRequest): Promise<void> { |
| 691 | try { |
| 692 | const result = await this.mcpAuthHandler!(request, { sessionId: this.sessionId }); |
| 693 | const response: McpOauthPendingRequestResponse = |
| 694 | result && "accessToken" in result |
| 695 | ? { kind: "token", ...result } |
| 696 | : { kind: "cancelled" }; |
| 697 | await this.rpc.mcp.oauth.handlePendingRequest({ |
| 698 | requestId: request.requestId, |
| 699 | result: response, |
| 700 | }); |
| 701 | } catch (_error) { |
| 702 | try { |
| 703 | await this.rpc.mcp.oauth.handlePendingRequest({ |
| 704 | requestId: request.requestId, |
| 705 | result: { kind: "cancelled" }, |
| 706 | }); |
| 707 | } catch (rpcError) { |
| 708 | if (!(rpcError instanceof ConnectionError || rpcError instanceof ResponseError)) { |
| 709 | throw rpcError; |
| 710 | } |
| 711 | } |
| 712 | } |
| 713 | } |
| 714 | |
| 715 | /** |
| 716 | * Executes a command handler and sends the result back via RPC. |
no test coverage detected