Fix MCP parameter rendering for arrays and objects in Claude logs#13969
Fix MCP parameter rendering for arrays and objects in Claude logs#13969
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
🔍 PR Triage ResultsCategory: bug | Risk: low | Priority: 58/100 Scores Breakdown
📋 Recommended Action: fast_trackBug fix with good test coverage. Draft status suggests needs review before merge. Fast-track once CI passes. Triaged by PR Triage Agent on 2026-02-05T18:24:58Z
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where MCP tool parameters containing arrays or objects were rendered as [object Object] in Claude log summaries, making them unreadable. The fix adds type-aware formatting to the formatMcpParameters function that properly serializes arrays and objects to JSON.
Changes:
- Enhanced
formatMcpParametersfunction to handle arrays and objects with JSON serialization - Added comprehensive test coverage for array formatting (empty, small, large, with objects)
- Added test coverage for object formatting and mixed parameter types
- Added integration test for the specific ToolsSearch scenario that triggered the bug
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| actions/setup/js/log_parser_shared.cjs | Enhanced formatMcpParameters to serialize arrays and objects as JSON instead of using default String() conversion |
| actions/setup/js/log_parser_shared.test.cjs | Added 8 new test cases covering array/object formatting, truncation, and mixed types |
| actions/setup/js/parse_claude_log.test.cjs | Added integration test for ToolsSearch with array of objects to verify the bug fix |
Comments suppressed due to low confidence (2)
actions/setup/js/log_parser_shared.cjs:502
- The JSON.stringify call on line 501 could throw an error if an array item contains circular references or unsupported values like BigInt. While this is unlikely in typical MCP parameter usage, consider wrapping this in a try-catch block to gracefully handle edge cases. If JSON.stringify fails, fall back to String(item) to maintain the fix for the [object Object] issue while providing resilience.
const items = rawValue.slice(0, 2).map(item => (typeof item === "object" && item !== null ? JSON.stringify(item) : String(item)));
value = `[${items.join(", ")}, ...${rawValue.length - 2} more]`;
actions/setup/js/log_parser_shared.cjs:506
- The JSON.stringify call on line 506 could throw an error if rawValue contains circular references or unsupported values like BigInt. While this is unlikely in typical MCP parameter usage, consider wrapping this in a try-catch block to gracefully handle edge cases. If JSON.stringify fails, fall back to String(rawValue) to maintain the fix for the [object Object] issue while providing resilience.
value = JSON.stringify(rawValue);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Should properly render the tool in initialization section | ||
| expect(result.markdown).toContain("serena::ToolsSearch"); |
There was a problem hiding this comment.
The comment on line 611 states "Should properly render the tool in initialization section" but the assertion on line 612 is identical to line 608, both checking for "serena::ToolsSearch" without differentiating between the initialization section and the reasoning/tools section. Consider making this test more specific by checking for the tool name in both sections separately, or remove the duplicate assertion if it's not adding value.
| // Should be truncated to 40 chars | ||
| expect(result.length).toBeLessThan(60); | ||
| expect(result).toContain("..."); |
There was a problem hiding this comment.
The test expectation on line 646 may not be verifying the intended behavior correctly. The test creates an array with two 50-character strings, which when formatted would result in a string much longer than 40 characters. However, the assertion checks that the total result length (including the key name "longArray: ") is less than 60 characters. This might pass due to truncation, but it would be clearer to test the specific truncation behavior by checking that the value portion is exactly 43 characters (40 chars + "...") or that it contains the ellipsis at the expected position.
Claude log summaries rendered MCP tool parameters containing arrays or objects as
[object Object]strings, making them unreadable. This affected tools likeserena::ToolsSearchthat pass structured data.Changes
formatMcpParameters: Added type-aware formatting[item1, item2, ...N more]JSON.stringify()String()conversionTests: Added coverage for arrays, objects, nested structures, and the specific ToolsSearch scenario
Example
Before:
After:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.