| 3 | import { MCPServersManager } from "@/main/services/mcp-servers-manager"; |
| 4 | |
| 5 | export class MCPServersManagerBridge extends Bridge.define("mcp-servers-manager", () => { |
| 6 | const service = Container.inject(MCPServersManager); |
| 7 | |
| 8 | return { |
| 9 | createServer: service.createServer.bind(service), |
| 10 | updateServer: service.updateServer.bind(service), |
| 11 | deleteServer: service.deleteServer.bind(service), |
| 12 | activateServer: service.activateServer.bind(service), |
| 13 | deactivateServer: service.deactivateServer.bind(service), |
| 14 | liveServers: () => { |
| 15 | const abort = new AbortController(); |
| 16 | |
| 17 | return new ReadableStream<Awaited<ReturnType<typeof service.liveServers>>["initialResults"]>({ |
| 18 | cancel: () => { |
| 19 | abort.abort(); |
| 20 | }, |
| 21 | start: (controller) => { |
| 22 | service |
| 23 | .liveServers() |
| 24 | .then((live) => { |
| 25 | if (abort.signal.aborted) { |
| 26 | return; |
| 27 | } |
| 28 | |
| 29 | live.refresh().catch(); |
| 30 | controller.enqueue(live.initialResults); |
| 31 | |
| 32 | abort.signal.addEventListener("abort", live.subscribe(controller.enqueue.bind(controller))); |
| 33 | }) |
| 34 | .catch((error) => { |
| 35 | controller.error(error); |
| 36 | }); |
| 37 | }, |
| 38 | }); |
| 39 | }, |
| 40 | }; |
| 41 | }) {} |
nothing calls this directly
no test coverage detected