Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"commander": "^14.0.2",
"eventsource-parser": "^3.0.6",
"express": "^5.1.0",
"jose": "^6.1.2",
"zod": "^3.25.76"
}
}
34 changes: 23 additions & 11 deletions src/runner/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export interface ClientExecutionResult {
async function executeClient(
command: string,
serverUrl: string,
timeout: number = 30000
timeout: number = 30000,
context?: Record<string, unknown>
): Promise<ClientExecutionResult> {
const commandParts = command.split(' ');
const executable = commandParts[0];
Expand All @@ -25,30 +26,37 @@ async function executeClient(
let stderr = '';
let timedOut = false;

// Build environment with optional context
const env = { ...process.env };
if (context) {
env.MCP_CONFORMANCE_CONTEXT = JSON.stringify(context);
}

return new Promise((resolve) => {
const process = spawn(executable, args, {
const childProcess = spawn(executable, args, {
shell: true,
stdio: 'pipe'
stdio: 'pipe',
env
});

const timeoutHandle = setTimeout(() => {
timedOut = true;
process.kill();
childProcess.kill();
}, timeout);

if (process.stdout) {
process.stdout.on('data', (data) => {
if (childProcess.stdout) {
childProcess.stdout.on('data', (data) => {
stdout += data.toString();
});
}

if (process.stderr) {
process.stderr.on('data', (data) => {
if (childProcess.stderr) {
childProcess.stderr.on('data', (data) => {
stderr += data.toString();
});
}

process.on('close', (code) => {
childProcess.on('close', (code) => {
clearTimeout(timeoutHandle);
resolve({
exitCode: code || 0,
Expand All @@ -58,7 +66,7 @@ async function executeClient(
});
});

process.on('error', (error) => {
childProcess.on('error', (error) => {
clearTimeout(timeoutHandle);
resolve({
exitCode: -1,
Expand Down Expand Up @@ -90,12 +98,16 @@ export async function runConformanceTest(
const urls = await scenario.start();

console.error(`Executing client: ${clientCommand} ${urls.serverUrl}`);
if (urls.context) {
console.error(`With context: ${JSON.stringify(urls.context)}`);
}

try {
const clientOutput = await executeClient(
clientCommand,
urls.serverUrl,
timeout
timeout,
urls.context
);

// Print stdout/stderr if client exited with nonzero code
Expand Down
Loading
Loading