Repository navigation
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Compact MCP CLI help to show full command/option names within 20/30 lines #38056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Compact MCP CLI help to show full command/option names within 20/30 lines #38056
Changes from 1 commit
20b79f1a634c23064789da1dd504c538c02d099bf7f2734eafa8aaea6936fd9f4a7fefFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String.slice()can bisect a surrogate pair: JS string indexing is UTF-16, sonormalized.slice(0, maxLen - 1)can split a surrogate pair (e.g., emoji like🚀, U+1F680) at positionmaxLen - 1, producing a lone high surrogate followed by.... The resulting string is invalid Unicode and may render as?or□in some terminals.💡 Suggested fix
Use
Array.fromto iterate codepoints instead of code units:MCP tool descriptions are mostly ASCII today, so probability is low — but
summarizeHelpTextis a generic utility and the fix is trivial.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[/tdd] When
maxLen === 1, the function returns"..."— the single ellipsis character — with zero content characters.normalized.slice(0, maxLen - 1)=normalized.slice(0, 0)="", so the output is just the marker with nothing before it.None of the current constants reach
maxLen=1, so this is not a production issue today, but the guard is incomplete.💡 Suggestion
Either document the assumption (
@param {number} maxLen - must be >= 2 to preserve at least one content character) or add a guard:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[/tdd]
summarizeHelpTextis a pure, deterministic utility that now drives all help truncation, but it has no dedicated unit tests. Its edge cases — multi-space collapsing, exactly-at-limit strings,maxLen <= 0, and themaxLen - 1slice boundary — are only exercised indirectly throughshowHelp/showToolHelp.💡 Suggested test skeleton
This would also catch the
maxLen=1edge case noted separately.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test only checks the footer string, not that
*markers appear on option lines:field_1andfield_2happen to be the first two properties, so they always survive truncation and receive*in this fixture — but the assertion never verifies it. If therequiredMarkconcatenation were accidentally dropped, this test would still pass.💡 Suggested additions
A companion test with
required: ["field_20"](a field beyond the slice cutoff) would also cover the production bug on line 836 ofmcp_cli_bridge.cjs— that fixture should produce no*markers and therefore no footer.