@@ -246,6 +246,31 @@ async def test_receive_steps_trajectory_error(self):
246246 self .assertEqual (len (steps ), 1 )
247247 self .assertEqual (steps [0 ].content , "I'm working" )
248248
249+ async def test_receive_steps_mcp_load_failure (self ):
250+ harness = self ._make_harness ()
251+
252+ await harness .conn .send ("Hello" )
253+ init_data = await harness .wait_for_response ()
254+ self .assertEqual (init_data .get ("userInput" ), "Hello" )
255+
256+ # Send an error indicating MCP failure.
257+ event = localharness_pb2 .OutputEvent (
258+ trajectory_state_update = localharness_pb2 .TrajectoryStateUpdate (
259+ trajectory_id = "my_cascade" ,
260+ state = localharness_pb2 .TrajectoryStateUpdate .STATE_IDLE ,
261+ error = "MCP load failed for dead_server: connection refused" ,
262+ )
263+ )
264+ await harness .send_event (event )
265+ await harness .close_from_harness_side ()
266+
267+ with self .assertRaisesRegex (
268+ types .AntigravityExecutionError ,
269+ "MCP load failed for dead_server: connection refused" ,
270+ ):
271+ async for _ in harness .conn .receive_steps ():
272+ pass
273+
249274 def test_local_connection_step_from_dict (self ):
250275 """Tests that LocalConnectionStep maps fields correctly."""
251276 step_dict = {
@@ -2230,6 +2255,47 @@ def test_strategy_normalizes_configured_workspaces(self):
22302255 strategy ._workspaces , ["/dev/shm/workspace" , "/tmp/clean-path" ]
22312256 )
22322257
2258+ def test_mcp_servers_propagated (self ):
2259+ """Verifies that mcp_servers are correctly serialized to HarnessConfig."""
2260+ mcp_servers = [
2261+ types .McpStreamableHttpServer (
2262+ name = "my_http_server" ,
2263+ url = "http://localhost:8080/mcp" ,
2264+ headers = {"Authorization" : "Bearer token123" },
2265+ timeout_seconds = 30 ,
2266+ ),
2267+ types .McpStdioServer (
2268+ name = "my_stdio_server" ,
2269+ command = "node" ,
2270+ args = ["server.js" ],
2271+ env = {"NODE_ENV" : "production" },
2272+ timeout_seconds = 10 ,
2273+ ),
2274+ ]
2275+ strategy = self ._make_strategy (mcp_servers = mcp_servers )
2276+ config = strategy ._build_harness_config ()
2277+
2278+ self .assertLen (config .mcp_servers , 2 )
2279+
2280+ # Assert HTTP server fields
2281+ http_server = config .mcp_servers [0 ]
2282+ self .assertEqual (http_server .name , "my_http_server" )
2283+ self .assertTrue (http_server .HasField ("http" ))
2284+ self .assertEqual (http_server .http .url , "http://localhost:8080/mcp" )
2285+ self .assertEqual (
2286+ http_server .http .headers ["Authorization" ], "Bearer token123"
2287+ )
2288+ self .assertEqual (http_server .timeout_seconds , 30 )
2289+
2290+ # Assert Stdio server fields
2291+ stdio_server = config .mcp_servers [1 ]
2292+ self .assertEqual (stdio_server .name , "my_stdio_server" )
2293+ self .assertTrue (stdio_server .HasField ("stdio" ))
2294+ self .assertEqual (stdio_server .stdio .command , "node" )
2295+ self .assertEqual (stdio_server .stdio .args , ["server.js" ])
2296+ self .assertEqual (stdio_server .stdio .env ["NODE_ENV" ], "production" )
2297+ self .assertEqual (stdio_server .timeout_seconds , 10 )
2298+
22332299
22342300class LocalConnectionStrategyApiKeyTest (unittest .IsolatedAsyncioTestCase ):
22352301 """Tests for API key validation in LocalConnectionStrategy."""
0 commit comments