(
mcpServers: McpServersConfig
)
| 122 | * @returns Array of CLI arguments to pass to codex |
| 123 | */ |
| 124 | export function buildMcpServerConfigArgs( |
| 125 | mcpServers: McpServersConfig |
| 126 | ): string[] { |
| 127 | const configArgs: string[] = []; |
| 128 | |
| 129 | for (const [name, server] of Object.entries(mcpServers)) { |
| 130 | // -c 'mcp_servers.<name>.command="<command>"' |
| 131 | configArgs.push('-c', `mcp_servers.${name}.command="${escapeTomlString(server.command)}"`); |
| 132 | |
| 133 | // -c 'mcp_servers.<name>.args=['arg1','arg2']' |
| 134 | // Use TOML literal strings to avoid shell-quote mangling on Windows. |
| 135 | const argsToml = buildTomlLiteralArray(server.args); |
| 136 | configArgs.push('-c', `mcp_servers.${name}.args=${argsToml}`); |
| 137 | |
| 138 | for (const [toolName, tool] of Object.entries(server.tools ?? {})) { |
| 139 | if (tool.approval_mode) { |
| 140 | configArgs.push( |
| 141 | '-c', |
| 142 | `mcp_servers.${name}.tools.${toolName}.approval_mode="${escapeTomlString(tool.approval_mode)}"` |
| 143 | ); |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | return configArgs; |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * Build -c argument for developer instructions. |
no test coverage detected