| 1359 | // --------------------------------------------------------------------------- |
| 1360 | |
| 1361 | const mcpUrlForActiveLocalServer = (input: { |
| 1362 | readonly connection: ExecutorServerConnection; |
| 1363 | readonly elicitationMode: "browser" | "model"; |
| 1364 | readonly artifacts: boolean; |
| 1365 | readonly searchTools: boolean; |
| 1366 | readonly toolMode: "codemode" | "passthrough"; |
| 1367 | }): URL => { |
| 1368 | const url = new URL("/mcp", input.connection.origin); |
| 1369 | if (input.elicitationMode === "browser") { |
| 1370 | url.searchParams.set("elicitation_mode", "browser"); |
| 1371 | } |
| 1372 | // Artifacts are on by default; only the opt-out is spelled out, so the |
| 1373 | // default endpoint stays clean. |
| 1374 | if (!input.artifacts) { |
| 1375 | url.searchParams.set("artifacts", "false"); |
| 1376 | } |
| 1377 | // Per-integration search tools are off by default; only the opt-in is |
| 1378 | // spelled out. |
| 1379 | if (input.searchTools) { |
| 1380 | url.searchParams.set("search_tools", "true"); |
| 1381 | } |
| 1382 | // Passthrough is the non-default surface; only it is spelled out. |
| 1383 | if (input.toolMode === "passthrough") { |
| 1384 | url.searchParams.set("mode", "passthrough"); |
| 1385 | } |
| 1386 | return url; |
| 1387 | }; |
| 1388 | |
| 1389 | /** |
| 1390 | * Bridge a stdio MCP client to a local server's HTTP `/mcp` endpoint. `executor |