Merge pull request #127 from 777genius/fix/opencode-preserve-local-mcp-with-http

fix(opencode): keep local MCP fallback with HTTP
This commit is contained in:
Илия 2026-05-16 23:53:57 +03:00 committed by GitHub
commit 44e760007a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -69,7 +69,6 @@ import { CrossTeamService } from '@main/services/team/CrossTeamService';
import { FileContentResolver } from '@main/services/team/FileContentResolver'; import { FileContentResolver } from '@main/services/team/FileContentResolver';
import { GitDiffFallback } from '@main/services/team/GitDiffFallback'; import { GitDiffFallback } from '@main/services/team/GitDiffFallback';
import { import {
clearOpenCodeLocalMcpLaunchEnv,
copyOpenCodeLocalMcpLaunchEnv, copyOpenCodeLocalMcpLaunchEnv,
hasOpenCodeLocalMcpLaunchEnv, hasOpenCodeLocalMcpLaunchEnv,
isOpenCodeMcpHttpBridgeEnabled, isOpenCodeMcpHttpBridgeEnabled,
@ -362,12 +361,7 @@ async function createOpenCodeRuntimeAdapterRegistry(
bridgeEnv.AGENT_TEAMS_MCP_CLAUDE_DIR = getClaudeBasePath(); bridgeEnv.AGENT_TEAMS_MCP_CLAUDE_DIR = getClaudeBasePath();
const useHttpMcpBridge = isOpenCodeMcpHttpBridgeEnabled(bridgeEnv); const useHttpMcpBridge = isOpenCodeMcpHttpBridgeEnabled(bridgeEnv);
const explicitLocalMcpLaunchEnv = snapshotOpenCodeLocalMcpLaunchEnv(bridgeEnv); const explicitLocalMcpLaunchEnv = snapshotOpenCodeLocalMcpLaunchEnv(bridgeEnv);
if (!useHttpMcpBridge) { delete bridgeEnv.CLAUDE_MULTIMODEL_AGENT_TEAMS_MCP_URL;
delete bridgeEnv.CLAUDE_MULTIMODEL_AGENT_TEAMS_MCP_URL;
} else {
delete bridgeEnv.CLAUDE_MULTIMODEL_AGENT_TEAMS_MCP_URL;
clearOpenCodeLocalMcpLaunchEnv(bridgeEnv);
}
const applyMcpLaunchSpecEnv = async ( const applyMcpLaunchSpecEnv = async (
targetEnv: NodeJS.ProcessEnv, targetEnv: NodeJS.ProcessEnv,
options: { emitProgress?: boolean } = {} options: { emitProgress?: boolean } = {}
@ -447,7 +441,6 @@ async function createOpenCodeRuntimeAdapterRegistry(
reportProgress('runtime-mcp-http', 'Starting Agent Teams MCP server...'); reportProgress('runtime-mcp-http', 'Starting Agent Teams MCP server...');
const mcpHttpServer = await agentTeamsMcpHttpServer.ensureStarted(); const mcpHttpServer = await agentTeamsMcpHttpServer.ensureStarted();
bridgeEnv.CLAUDE_MULTIMODEL_AGENT_TEAMS_MCP_URL = mcpHttpServer.url; bridgeEnv.CLAUDE_MULTIMODEL_AGENT_TEAMS_MCP_URL = mcpHttpServer.url;
clearOpenCodeLocalMcpLaunchEnv(bridgeEnv);
reportProgress('runtime-mcp-http-ready', 'Agent Teams MCP server is ready...'); reportProgress('runtime-mcp-http-ready', 'Agent Teams MCP server is ready...');
} catch (error) { } catch (error) {
logger.warn( logger.warn(
@ -457,7 +450,7 @@ async function createOpenCodeRuntimeAdapterRegistry(
); );
} }
} }
if (!bridgeEnv.CLAUDE_MULTIMODEL_AGENT_TEAMS_MCP_URL) { if (useHttpMcpBridge || !bridgeEnv.CLAUDE_MULTIMODEL_AGENT_TEAMS_MCP_URL) {
await ensureOpenCodeLocalMcpLaunchEnv(bridgeEnv, { emitProgress: true }); await ensureOpenCodeLocalMcpLaunchEnv(bridgeEnv, { emitProgress: true });
} }
@ -471,12 +464,10 @@ async function createOpenCodeRuntimeAdapterRegistry(
const mcpHttpServer = await agentTeamsMcpHttpServer.ensureStarted(); const mcpHttpServer = await agentTeamsMcpHttpServer.ensureStarted();
bridgeEnv.CLAUDE_MULTIMODEL_AGENT_TEAMS_MCP_URL = mcpHttpServer.url; bridgeEnv.CLAUDE_MULTIMODEL_AGENT_TEAMS_MCP_URL = mcpHttpServer.url;
nextEnv.CLAUDE_MULTIMODEL_AGENT_TEAMS_MCP_URL = mcpHttpServer.url; nextEnv.CLAUDE_MULTIMODEL_AGENT_TEAMS_MCP_URL = mcpHttpServer.url;
clearOpenCodeLocalMcpLaunchEnv(bridgeEnv); await ensureOpenCodeLocalMcpLaunchEnv(nextEnv);
clearOpenCodeLocalMcpLaunchEnv(nextEnv);
} catch (error) { } catch (error) {
delete bridgeEnv.CLAUDE_MULTIMODEL_AGENT_TEAMS_MCP_URL; delete bridgeEnv.CLAUDE_MULTIMODEL_AGENT_TEAMS_MCP_URL;
delete nextEnv.CLAUDE_MULTIMODEL_AGENT_TEAMS_MCP_URL; delete nextEnv.CLAUDE_MULTIMODEL_AGENT_TEAMS_MCP_URL;
clearOpenCodeLocalMcpLaunchEnv(nextEnv);
await ensureOpenCodeLocalMcpLaunchEnv(nextEnv); await ensureOpenCodeLocalMcpLaunchEnv(nextEnv);
logger.warn( logger.warn(
`[OpenCode] Runtime adapter bridge MCP HTTP server refresh failed: ${ `[OpenCode] Runtime adapter bridge MCP HTTP server refresh failed: ${