@@ -43,26 +43,37 @@ type ConnectionInitializer = (connection: acp.ClientSideConnection) => Promise<v
4343export async function createSpawnedAgentFixture (
4444 initializeConnection : ConnectionInitializer ,
4545 extraEnv ?: NodeJS . ProcessEnv ,
46- paths = RuntimePaths . createTemporary ( ) ,
47- client : RecordingClient = new RecordingClient ( ) ,
46+ mcpServers ?: acp . McpServerStdio [ ] ,
47+ paths ?: RuntimePaths ,
48+ client ?: RecordingClient ,
4849) : Promise < SpawnedAgentFixture > {
50+ const resolvedPaths = paths ?? RuntimePaths . createTemporary ( ) ;
51+ const configuredMcpServers = mcpServers ?? [ ] ;
52+ writeCodexHomeConfig ( resolvedPaths . codexHome , {
53+ model : DEFAULT_TEST_MODEL_ID . model ,
54+ model_reasoning_effort : DEFAULT_TEST_MODEL_ID . effort ,
55+ web_search : "disabled" ,
56+ } , configuredMcpServers ) ;
57+
58+ const resolvedClient = client ?? new RecordingClient ( ) ;
4959 const agentProcess = spawn ( "npm" , [ "run" , "--silent" , "start" ] , {
5060 cwd : process . cwd ( ) ,
5161 env : {
5262 ...process . env ,
53- CODEX_HOME : paths . codexHome ,
54- APP_SERVER_LOGS : paths . appServerLogsDir ,
63+ CODEX_HOME : resolvedPaths . codexHome ,
64+ APP_SERVER_LOGS : resolvedPaths . appServerLogsDir ,
5565 ...extraEnv ,
5666 } ,
5767 stdio : [ "pipe" , "pipe" , "pipe" ] ,
5868 } ) ;
5969
6070 const fixture = new SpawnedAgentFixtureImpl (
61- client ,
71+ resolvedClient ,
6272 agentProcess ,
63- paths ,
73+ resolvedPaths ,
6474 initializeConnection ,
65- extraEnv ,
75+ extraEnv ?? { } ,
76+ configuredMcpServers ,
6677 ) ;
6778 await initializeConnection ( fixture . connection ) ;
6879 return fixture ;
@@ -85,11 +96,6 @@ class RuntimePaths {
8596 for ( const dir of [ paths . rootDir , paths . codexHome , paths . workspaceDir , paths . appServerLogsDir ] ) {
8697 fs . mkdirSync ( dir , { recursive : true } ) ;
8798 }
88- writeCodexHomeConfig ( paths . codexHome , {
89- model : DEFAULT_TEST_MODEL_ID . model ,
90- model_reasoning_effort : DEFAULT_TEST_MODEL_ID . effort ,
91- web_search : "disabled" ,
92- } ) ;
9399 return paths ;
94100 }
95101}
@@ -146,7 +152,8 @@ class SpawnedAgentFixtureImpl implements SpawnedAgentFixture {
146152 private readonly agentProcess : ChildProcessWithoutNullStreams ,
147153 private readonly paths : RuntimePaths ,
148154 private readonly initializeConnection : ConnectionInitializer ,
149- private readonly extraEnv ?: NodeJS . ProcessEnv ,
155+ private readonly extraEnv : NodeJS . ProcessEnv ,
156+ private readonly mcpServers : acp . McpServerStdio [ ] ,
150157 ) {
151158 const output = Readable . toWeb ( agentProcess . stdout ) as ReadableStream < Uint8Array > ;
152159 this . connection = new acp . ClientSideConnection (
@@ -168,7 +175,7 @@ class SpawnedAgentFixtureImpl implements SpawnedAgentFixture {
168175
169176 async restart ( ) : Promise < SpawnedAgentFixture > {
170177 await this . stopProcess ( false ) ;
171- return await createSpawnedAgentFixture ( this . initializeConnection , this . extraEnv , this . paths , this . client ) ;
178+ return await createSpawnedAgentFixture ( this . initializeConnection , this . extraEnv , this . mcpServers , this . paths , this . client ) ;
172179 }
173180
174181 writeSkill ( skill : TestSkill , rootDir ?: string ) : void {
0 commit comments