Skip to content

Commit 685f4d8

Browse files
Copilot0xrinegade
andcommitted
Fix MCP Inspector CI test - handle mixed log/JSON output properly
Co-authored-by: 0xrinegade <[email protected]>
1 parent de7362e commit 685f4d8

File tree

1 file changed

+51
-42
lines changed

1 file changed

+51
-42
lines changed

.github/workflows/mcp-inspector.yml

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
"env": {
5858
"SOLANA_RPC_URL": "https://api.devnet.solana.com",
5959
"SOLANA_COMMITMENT": "confirmed",
60-
"RUST_LOG": "debug"
60+
"RUST_LOG": "info"
6161
}
6262
}
6363
}
@@ -79,7 +79,7 @@ jobs:
7979
...process.env,
8080
SOLANA_RPC_URL: 'https://api.devnet.solana.com',
8181
SOLANA_COMMITMENT: 'confirmed',
82-
RUST_LOG: 'debug'
82+
RUST_LOG: 'info'
8383
}
8484
});
8585
@@ -90,49 +90,57 @@ jobs:
9090
9191
// Handle server output
9292
server.stdout.on('data', (data) => {
93-
const response = data.toString();
94-
console.log('Server response:', response);
93+
const lines = data.toString().split('\n');
9594
96-
try {
97-
const jsonResponse = JSON.parse(response);
95+
for (const line of lines) {
96+
if (!line.trim()) continue;
9897
99-
if (jsonResponse.result && jsonResponse.result.protocolVersion) {
100-
console.log('✅ Initialize response received with protocol version:', jsonResponse.result.protocolVersion);
101-
testResults.initialize = true;
98+
try {
99+
const jsonResponse = JSON.parse(line);
102100
103-
// Send tools/list request
104-
const toolsListRequest = {
105-
jsonrpc: "2.0",
106-
id: 2,
107-
method: "tools/list",
108-
params: {}
109-
};
110-
server.stdin.write(JSON.stringify(toolsListRequest) + '\n');
111-
}
112-
113-
if (jsonResponse.result && jsonResponse.result.tools) {
114-
console.log('✅ Tools list response received with', jsonResponse.result.tools.length, 'tools');
115-
testResults.toolsList = true;
116-
117-
// Check if we have the expected Solana RPC methods
118-
const toolNames = jsonResponse.result.tools.map(tool => tool.name);
119-
const expectedMethods = ['getAccountInfo', 'getBalance', 'sendTransaction'];
120-
const hasExpectedMethods = expectedMethods.every(method => toolNames.includes(method));
121-
122-
if (hasExpectedMethods) {
123-
console.log('✅ Expected Solana RPC methods found in tools list');
124-
} else {
125-
console.log('❌ Some expected Solana RPC methods missing from tools list');
126-
process.exit(1);
101+
// Check for initialize response
102+
if (jsonResponse.id === 1 && jsonResponse.result && jsonResponse.result.protocolVersion) {
103+
console.log('✅ Initialize response received with protocol version:', jsonResponse.result.protocolVersion);
104+
testResults.initialize = true;
105+
106+
// Wait a bit then send tools/list request
107+
setTimeout(() => {
108+
const toolsListRequest = {
109+
jsonrpc: "2.0",
110+
id: 2,
111+
method: "tools/list",
112+
params: {}
113+
};
114+
console.log('Sending tools/list request');
115+
server.stdin.write(JSON.stringify(toolsListRequest) + '\n');
116+
}, 1000);
127117
}
128118
129-
// Test passed
130-
console.log('✅ All MCP protocol tests passed');
131-
server.kill();
132-
process.exit(0);
119+
// Check for tools/list response
120+
if (jsonResponse.id === 2 && jsonResponse.result && jsonResponse.result.tools) {
121+
console.log('✅ Tools list response received with', jsonResponse.result.tools.length, 'tools');
122+
testResults.toolsList = true;
123+
124+
// Check if we have the expected Solana RPC methods
125+
const toolNames = jsonResponse.result.tools.map(tool => tool.name);
126+
const expectedMethods = ['getAccountInfo', 'getBalance', 'sendTransaction'];
127+
const hasExpectedMethods = expectedMethods.every(method => toolNames.includes(method));
128+
129+
if (hasExpectedMethods) {
130+
console.log('✅ Expected Solana RPC methods found in tools list');
131+
console.log('✅ All MCP protocol tests passed');
132+
server.kill();
133+
process.exit(0);
134+
} else {
135+
console.log('❌ Some expected Solana RPC methods missing from tools list');
136+
console.log('Missing methods:', expectedMethods.filter(method => !toolNames.includes(method)));
137+
server.kill();
138+
process.exit(1);
139+
}
140+
}
141+
} catch (e) {
142+
// This line is not JSON, probably a log message - ignore
133143
}
134-
} catch (e) {
135-
// Ignore non-JSON output
136144
}
137145
});
138146
@@ -164,12 +172,13 @@ jobs:
164172
165173
server.stdin.write(JSON.stringify(initializeRequest) + '\n');
166174
167-
// Timeout after 30 seconds
175+
// Timeout after 60 seconds to allow for tool list delay
168176
setTimeout(() => {
169-
console.log('❌ Test timeout');
177+
console.log('❌ Test timeout after 60 seconds');
178+
console.log('Test results so far:', testResults);
170179
server.kill();
171180
process.exit(1);
172-
}, 30000);
181+
}, 60000);
173182
EOF
174183
175184
- name: Upload Test Artifacts

0 commit comments

Comments
 (0)