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
16 changes: 13 additions & 3 deletions src/commands/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ export interface CallOptions {
configPath?: string;
}

async function writeStdout(text: string): Promise<void> {
await new Promise<void>((resolve, reject) => {
process.stdout.write(`${text}\n`, (error) => {
if (error) reject(error);
else resolve();
});
});
}

/**
* Parse target into server and tool name
*/
Expand Down Expand Up @@ -161,9 +170,10 @@ export async function callCommand(options: CallOptions): Promise<void> {
try {
const result = await connection.callTool(toolName, args);

// Extract text content from MCP response for CLI-friendly output
// Uses formatToolResult which extracts text from MCP content array
console.log(formatToolResult(result));
// Extract text content from MCP response for CLI-friendly output.
// Write directly to stdout and await the callback so large piped output
// does not get truncated if the process exits immediately afterwards.
await writeStdout(formatToolResult(result));
} catch (error) {
// Try to get available tools for better error message
let availableTools: string[] | undefined;
Expand Down