remove bad try/catch
This commit is contained in:
+35
-42
@@ -21,49 +21,42 @@ export const codex = agent({
|
|||||||
if (mcpServers && Object.keys(mcpServers).length > 0) {
|
if (mcpServers && Object.keys(mcpServers).length > 0) {
|
||||||
log.info("Configuring MCP servers for Codex...");
|
log.info("Configuring MCP servers for Codex...");
|
||||||
for (const [serverName, serverConfig] of Object.entries(mcpServers)) {
|
for (const [serverName, serverConfig] of Object.entries(mcpServers)) {
|
||||||
try {
|
// Only configure stdio servers (Codex CLI supports stdio MCP servers)
|
||||||
// Only configure stdio servers (Codex CLI supports stdio MCP servers)
|
// Check if it's a stdio server config (has 'command' property)
|
||||||
// Check if it's a stdio server config (has 'command' property)
|
if (!("command" in serverConfig)) {
|
||||||
if (!("command" in serverConfig)) {
|
log.warning(`MCP server '${serverName}' is not a stdio server, skipping...`);
|
||||||
log.warning(`MCP server '${serverName}' is not a stdio server, skipping...`);
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build command and args
|
|
||||||
const command = serverConfig.command;
|
|
||||||
const args = serverConfig.args || [];
|
|
||||||
const envVars = serverConfig.env || {};
|
|
||||||
|
|
||||||
// Build the codex mcp add command with proper argument handling
|
|
||||||
const addArgs = ["mcp", "add", serverName, "--", command, ...args];
|
|
||||||
|
|
||||||
// Add environment variables as --env flags
|
|
||||||
for (const [key, value] of Object.entries(envVars)) {
|
|
||||||
addArgs.push("--env", `${key}=${value}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info(`Adding MCP server '${serverName}'...`);
|
|
||||||
const addResult = spawnSync("node", [cliPath, ...addArgs], {
|
|
||||||
stdio: "pipe",
|
|
||||||
encoding: "utf-8",
|
|
||||||
env: {
|
|
||||||
...process.env,
|
|
||||||
OPENAI_API_KEY: apiKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (addResult.status !== 0) {
|
|
||||||
throw new Error(
|
|
||||||
`codex mcp add failed: ${addResult.stderr || addResult.stdout || "Unknown error"}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
log.info(`✓ MCP server '${serverName}' configured`);
|
|
||||||
} catch (error) {
|
|
||||||
log.warning(
|
|
||||||
`Failed to configure MCP server '${serverName}': ${error instanceof Error ? error.message : String(error)}`
|
|
||||||
);
|
|
||||||
// Continue with other servers
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build command and args
|
||||||
|
const command = serverConfig.command;
|
||||||
|
const args = serverConfig.args || [];
|
||||||
|
const envVars = serverConfig.env || {};
|
||||||
|
|
||||||
|
// Build the codex mcp add command with proper argument handling
|
||||||
|
const addArgs = ["mcp", "add", serverName, "--", command, ...args];
|
||||||
|
|
||||||
|
// Add environment variables as --env flags
|
||||||
|
for (const [key, value] of Object.entries(envVars)) {
|
||||||
|
addArgs.push("--env", `${key}=${value}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(`Adding MCP server '${serverName}'...`);
|
||||||
|
const addResult = spawnSync("node", [cliPath, ...addArgs], {
|
||||||
|
stdio: "pipe",
|
||||||
|
encoding: "utf-8",
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
OPENAI_API_KEY: apiKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (addResult.status !== 0) {
|
||||||
|
throw new Error(
|
||||||
|
`codex mcp add failed: ${addResult.stderr || addResult.stdout || "Unknown error"}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
log.info(`✓ MCP server '${serverName}' configured`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41411,38 +41411,32 @@ var codex = agent({
|
|||||||
if (mcpServers && Object.keys(mcpServers).length > 0) {
|
if (mcpServers && Object.keys(mcpServers).length > 0) {
|
||||||
log.info("Configuring MCP servers for Codex...");
|
log.info("Configuring MCP servers for Codex...");
|
||||||
for (const [serverName, serverConfig] of Object.entries(mcpServers)) {
|
for (const [serverName, serverConfig] of Object.entries(mcpServers)) {
|
||||||
try {
|
if (!("command" in serverConfig)) {
|
||||||
if (!("command" in serverConfig)) {
|
log.warning(`MCP server '${serverName}' is not a stdio server, skipping...`);
|
||||||
log.warning(`MCP server '${serverName}' is not a stdio server, skipping...`);
|
continue;
|
||||||
continue;
|
}
|
||||||
|
const command = serverConfig.command;
|
||||||
|
const args2 = serverConfig.args || [];
|
||||||
|
const envVars = serverConfig.env || {};
|
||||||
|
const addArgs = ["mcp", "add", serverName, "--", command, ...args2];
|
||||||
|
for (const [key, value2] of Object.entries(envVars)) {
|
||||||
|
addArgs.push("--env", `${key}=${value2}`);
|
||||||
|
}
|
||||||
|
log.info(`Adding MCP server '${serverName}'...`);
|
||||||
|
const addResult = spawnSync2("node", [cliPath, ...addArgs], {
|
||||||
|
stdio: "pipe",
|
||||||
|
encoding: "utf-8",
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
OPENAI_API_KEY: apiKey
|
||||||
}
|
}
|
||||||
const command = serverConfig.command;
|
});
|
||||||
const args2 = serverConfig.args || [];
|
if (addResult.status !== 0) {
|
||||||
const envVars = serverConfig.env || {};
|
throw new Error(
|
||||||
const addArgs = ["mcp", "add", serverName, "--", command, ...args2];
|
`codex mcp add failed: ${addResult.stderr || addResult.stdout || "Unknown error"}`
|
||||||
for (const [key, value2] of Object.entries(envVars)) {
|
|
||||||
addArgs.push("--env", `${key}=${value2}`);
|
|
||||||
}
|
|
||||||
log.info(`Adding MCP server '${serverName}'...`);
|
|
||||||
const addResult = spawnSync2("node", [cliPath, ...addArgs], {
|
|
||||||
stdio: "pipe",
|
|
||||||
encoding: "utf-8",
|
|
||||||
env: {
|
|
||||||
...process.env,
|
|
||||||
OPENAI_API_KEY: apiKey
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (addResult.status !== 0) {
|
|
||||||
throw new Error(
|
|
||||||
`codex mcp add failed: ${addResult.stderr || addResult.stdout || "Unknown error"}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
log.info(`\u2713 MCP server '${serverName}' configured`);
|
|
||||||
} catch (error2) {
|
|
||||||
log.warning(
|
|
||||||
`Failed to configure MCP server '${serverName}': ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
log.info(`\u2713 MCP server '${serverName}' configured`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.info("Running Codex via CLI...");
|
log.info("Running Codex via CLI...");
|
||||||
|
|||||||
Reference in New Issue
Block a user