Synchronize MCP tests with matching persisted tool responses #16

Merged
lingjhf merged 1 commits from codex/mcp-test-response-synchronization into main 2026-10-11 21:23:20 +00:00
+16 -2
View File
@@ -332,10 +332,13 @@ void main() {
String workspace = 'application',
String? operation,
}) async {
final id = ++requestId;
final elapsed = Stopwatch()..start();
stdout.writeln('MCP request $id: $name started');
socket.writeln(
jsonEncode({
'jsonrpc': '2.0',
'id': ++requestId,
'id': id,
'method': 'tools/call',
'params': {
'_meta': {
@@ -351,8 +354,19 @@ void main() {
},
}),
);
expect(await lines.moveNext().timeout(const Duration(seconds: 5)), true);
await socket.flush();
// Project tools persist real files. Await their response rather than
// imposing an unrelated transport SLA; the test's timeout bounds hangs.
expect(
await lines.moveNext(),
true,
reason: 'MCP stream closed for $name request $id',
);
stdout.writeln(
'MCP request $id: $name replied after ${elapsed.elapsedMilliseconds}ms',
);
final response = jsonDecode(lines.current) as Map;
expect(response['id'], id, reason: '$response');
expect(response['error'], isNull, reason: '$response');
return (response['result'] as Map)['structuredContent'] as Map;
}