diff --git a/src/client.ts b/src/client.ts index 50731cf..2e9b7ea 100644 --- a/src/client.ts +++ b/src/client.ts @@ -243,15 +243,12 @@ export async function connectToServer( } else { transport = createStdioTransport(config); - // Capture stderr for debugging - attach BEFORE connect - // Always stream stderr immediately so auth prompts are visible + // Capture stderr before connect so failed startups can surface + // helpful diagnostics without streaming server noise by default. const stderrStream = transport.stderr; if (stderrStream) { stderrStream.on('data', (chunk: Buffer) => { - const text = chunk.toString(); - stderrChunks.push(text); - // Always stream stderr immediately so users can see auth prompts - process.stderr.write(`[${serverName}] ${text}`); + stderrChunks.push(chunk.toString()); }); } } @@ -268,16 +265,6 @@ export async function connectToServer( throw error; } - // For successful connections, forward stderr to console - if (!isHttpServer(config)) { - const stderrStream = (transport as StdioClientTransport).stderr; - if (stderrStream) { - stderrStream.on('data', (chunk: Buffer) => { - process.stderr.write(chunk); - }); - } - } - return { client, close: async () => { @@ -328,16 +315,26 @@ function createStdioTransport(config: StdioServerConfig): StdioClientTransport { } /** - * List all tools from a connected client with retry logic + * List all tools from a connected client with retry logic and pagination support */ export async function listTools(client: Client): Promise { return withRetry(async () => { - const result = await client.listTools(); - return result.tools.map((tool: Tool) => ({ - name: tool.name, - description: tool.description, - inputSchema: tool.inputSchema as Record, - })); + const allTools: ToolInfo[] = []; + let cursor: string | undefined; + + do { + const result = await client.listTools(cursor ? { cursor } : undefined); + allTools.push( + ...result.tools.map((tool: Tool) => ({ + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema as Record, + })), + ); + cursor = result.nextCursor as string | undefined; + } while (cursor); + + return allTools; }, 'list tools'); }