Skip to content
Open
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
11 changes: 10 additions & 1 deletion src/commands/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* - Errors always go to stderr
*/

import { once } from 'node:events';
import {
type McpConnection,
debug,
Expand Down Expand Up @@ -104,6 +105,14 @@ async function parseArgs(
}
}

async function writeStdout(output: string): Promise<void> {
if (process.stdout.write(`${output}\n`)) {
return;
}

await once(process.stdout, 'drain');
}

/**
* Execute the call command
*/
Expand Down Expand Up @@ -163,7 +172,7 @@ export async function callCommand(options: CallOptions): Promise<void> {

// Extract text content from MCP response for CLI-friendly output
// Uses formatToolResult which extracts text from MCP content array
console.log(formatToolResult(result));
await writeStdout(formatToolResult(result));
} catch (error) {
// Try to get available tools for better error message
let availableTools: string[] | undefined;
Expand Down