@@ -188,13 +188,17 @@ export async function createTask(opts: CreateTaskOptions): Promise<string> {
188188
189189 // Start MCP server BEFORE adding task to store — the store update triggers
190190 // a reactive render of TerminalView which spawns the PTY immediately.
191- // If mcpConfigPath isn 't set yet, the --mcp-config arg is missing .
191+ // If MCP launch args aren 't set yet, the coordinator agent starts without MCP wiring .
192192 let mcpConfigPath : string | undefined ;
193+ let mcpLaunchArgs : string [ ] | undefined ;
193194 if ( opts . coordinatorMode ) {
194195 // When running in Docker, sub-agents will be spawned via `docker exec` into this container.
195196 const dockerContainerName = dockerMode ? `parallel-code-${ agentId . slice ( 0 , 12 ) } ` : undefined ;
196197 try {
197- const mcpResult = await invoke < { configPath : string | undefined } > ( IPC . StartMCPServer , {
198+ const mcpResult = await invoke < {
199+ configPath : string | undefined ;
200+ mcpLaunchArgs ?: string [ ] ;
201+ } > ( IPC . StartMCPServer , {
198202 coordinatorTaskId : taskId ,
199203 projectId,
200204 projectRoot,
@@ -207,6 +211,7 @@ export async function createTask(opts: CreateTaskOptions): Promise<string> {
207211 dockerImage,
208212 } ) ;
209213 mcpConfigPath = mcpResult . configPath ?? undefined ;
214+ mcpLaunchArgs = mcpResult . mcpLaunchArgs ;
210215 console . warn ( '[MCP] Coordinator config path:' , mcpConfigPath ) ;
211216 await invoke ( IPC . MCP_CoordinatorRegistered , {
212217 coordinatorTaskId : taskId ,
@@ -270,6 +275,7 @@ export async function createTask(opts: CreateTaskOptions): Promise<string> {
270275 : undefined ,
271276 controlledBy : opts . coordinatorMode ? 'coordinator' : undefined ,
272277 mcpConfigPath,
278+ mcpLaunchArgs,
273279 // Coordinator tasks call StartMCPServer before entering the store, so MCP is ready immediately.
274280 mcpStartupStatus : opts . coordinatorMode ? ( 'ready' as const ) : undefined ,
275281 } ;
@@ -1236,6 +1242,10 @@ export function markTaskMcpReady(taskId: string): void {
12361242 if ( store . tasks [ taskId ] ) setStore ( 'tasks' , taskId , 'mcpStartupStatus' , 'ready' ) ;
12371243}
12381244
1245+ export function setTaskMcpLaunchArgs ( taskId : string , args : string [ ] | undefined ) : void {
1246+ if ( store . tasks [ taskId ] ) setStore ( 'tasks' , taskId , 'mcpLaunchArgs' , args ) ;
1247+ }
1248+
12391249export function markTaskMcpError ( taskId : string , errorMsg : string ) : void {
12401250 if ( ! store . tasks [ taskId ] ) return ;
12411251 // eslint-disable-next-line no-control-regex -- strip escape chars to prevent injection
@@ -1260,7 +1270,7 @@ export function retryTaskMcpStartup(taskId: string): Promise<void> {
12601270 task . dockerMode && task . agentIds [ 0 ]
12611271 ? `parallel-code-${ task . agentIds [ 0 ] . slice ( 0 , 12 ) } `
12621272 : undefined ;
1263- return invoke ( IPC . StartMCPServer , {
1273+ return invoke < { mcpLaunchArgs ?: string [ ] } > ( IPC . StartMCPServer , {
12641274 coordinatorTaskId : task . id ,
12651275 projectId : task . projectId ,
12661276 projectRoot,
@@ -1272,7 +1282,10 @@ export function retryTaskMcpStartup(taskId: string): Promise<void> {
12721282 dockerContainerName,
12731283 dockerImage : task . dockerImage ,
12741284 } )
1275- . then ( ( ) => markTaskMcpReady ( taskId ) )
1285+ . then ( ( result ) => {
1286+ setTaskMcpLaunchArgs ( taskId , result ?. mcpLaunchArgs ) ;
1287+ markTaskMcpReady ( taskId ) ;
1288+ } )
12761289 . catch ( ( err : unknown ) => markTaskMcpError ( taskId , String ( err ) ) ) ;
12771290 }
12781291
0 commit comments