mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
* fix(mcp): follow tools/list pagination instead of silently truncating The SDK's listTools() returns a single page; a server that paginates via nextCursor was silently truncated to page one. Follow the cursor bounded by four independent budgets (50 pages / 1000 tools / 5 MB / 60s aggregate wall-clock) plus a repeated-cursor guard — a page cap alone can't stop a server returning a fresh cursor with no new tools. Partial results from earlier pages are kept when a later page fails; only a page-one failure throws. Matches the LibreChat capped-cursor-loop pattern; caps live in MCP_CLIENT_CONSTANTS. * fix(mcp): count UTF-8 bytes, keep empty partials, and log page-cap accurately Review fixes on the tools/list pagination loop: - Buffer.byteLength(..., 'utf8') instead of .length so non-ASCII schemas can't overshoot the 5 MB budget by counting UTF-16 code units. - Track pagesFetched (not tools.length) for the partial-success decision, so a valid-but-empty first page followed by a failing page returns [] instead of throwing and marking the server unhealthy. - Explicit reachedEnd/page-cap distinction so a natural finish on exactly MAX_PAGES isn't mislogged as truncated.