Skip to content

Commit 68966e3

Browse files
fix: 修复 MCP 服务器忽略 GEMINI_TOOLS_DEFAULT_MODEL 的问题
Co-authored-by: aider (vertex_ai/gemini-2.5-pro) <aider@aider.chat>
1 parent 103e391 commit 68966e3

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

packages/mcp-server/src/config/config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ export async function loadServerConfig(
9393

9494
const sandboxConfig = await loadSandboxConfig(settings, {});
9595

96+
// Prioritize GEMINI_TOOLS_DEFAULT_MODEL, then GEMINI_MODEL, then the hardcoded default.
97+
const model =
98+
process.env.GEMINI_TOOLS_DEFAULT_MODEL ||
99+
process.env.GEMINI_MODEL ||
100+
DEFAULT_GEMINI_MODEL;
101+
96102
return new Config({
97103
sessionId,
98104
embeddingModel: DEFAULT_GEMINI_EMBEDDING_MODEL,
@@ -136,7 +142,7 @@ export async function loadServerConfig(
136142
cwd: process.cwd(),
137143
fileDiscoveryService: fileService,
138144
bugCommand: settings.bugCommand,
139-
model: process.env.GEMINI_MODEL || DEFAULT_GEMINI_MODEL,
145+
model: model,
140146
extensionContextFilePaths,
141147
});
142148
}

packages/mcp-server/src/index.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,8 @@ async function startMcpServer() {
9797
console.log(`Using authentication method: ${selectedAuthType}`);
9898
}
9999

100-
// Check for the custom tools model environment variable
101-
const toolsDefaultModel = process.env.GEMINI_TOOLS_DEFAULT_MODEL;
102-
if (toolsDefaultModel && toolsDefaultModel.trim() !== '') {
103-
config.setModel(toolsDefaultModel.trim());
104-
console.log(`🚀 Using custom model for tools: ${toolsDefaultModel.trim()}`);
105-
} else {
106-
// Log the default model being used if the environment variable is not set
107-
console.log(`⚙️ Using default model for tools: ${config.getModel()}`);
108-
}
100+
// Log the model being used for tools. This is now set in loadServerConfig.
101+
console.log(`⚙️ Using model for tools: ${config.getModel()}`);
109102

110103
// 4. 初始化并启动 MCP 桥接服务 和 OpenAI 服务
111104
const mcpBridge = new GcliMcpBridge(config, cliVersion, debugMode);

0 commit comments

Comments
 (0)