Skip to content

Fix MCP parameter rendering for arrays and objects in Claude logs#13969

Merged
pelikhan merged 4 commits intomainfrom
copilot/review-tools-search-object
Feb 5, 2026
Merged

Fix MCP parameter rendering for arrays and objects in Claude logs#13969
pelikhan merged 4 commits intomainfrom
copilot/review-tools-search-object

Conversation

Copy link
Contributor

Copilot AI commented Feb 5, 2026

Claude log summaries rendered MCP tool parameters containing arrays or objects as [object Object] strings, making them unreadable. This affected tools like serena::ToolsSearch that pass structured data.

Changes

  • formatMcpParameters: Added type-aware formatting

    • Arrays: render as [item1, item2, ...N more]
    • Objects: render as compact JSON via JSON.stringify()
    • Primitives: unchanged String() conversion
  • Tests: Added coverage for arrays, objects, nested structures, and the specific ToolsSearch scenario

Example

Before:

serena::ToolsSearch(query: search term, tools: [object Object],[object Object],[object Object],...)

After:

serena::ToolsSearch(query: search term, tools: [{"name":"tool1","type":"function"}, {"name":"tool2",...})
Original prompt

Review the javascript rendering of claude logs and handle the "ToolsSearch" object. See:

✓ ToolSearch
└ [object Object],[object Object],[object Object],[object Object],[object Object]

See report: https://github.com/github/gh-aw/actions/runs/21722241500


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 5, 2026 18:00
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Review JavaScript rendering of claude logs for ToolsSearch object Fix MCP parameter rendering for arrays and objects in Claude logs Feb 5, 2026
Copilot AI requested a review from pelikhan February 5, 2026 18:05
@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

🔍 PR Triage Results

Category: bug | Risk: low | Priority: 58/100

Scores Breakdown

  • Impact: 30/50 - Fixes bug causing '[object Object]' rendering in Claude log summaries for MCP tools with structured parameters. Affects tools like serena::ToolsSearch. Medium impact as it improves debugging experience.
  • Urgency: 18/30 - Recent PR (< 1 hour old). Improves log readability for debugging. Moderate urgency - helpful but not blocking.
  • Quality: 10/20 - Good description with before/after examples. Comprehensive test coverage (9 new tests). Draft status, CI pending. Well-documented fix.

📋 Recommended Action: fast_track

Bug 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

AI generated by PR Triage Agent

@pelikhan pelikhan marked this pull request as ready for review February 5, 2026 18:55
Copilot AI review requested due to automatic review settings February 5, 2026 18:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 formatMcpParameters function 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.

Comment on lines +611 to +612
// Should properly render the tool in initialization section
expect(result.markdown).toContain("serena::ToolsSearch");
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +645 to +647
// Should be truncated to 40 chars
expect(result.length).toBeLessThan(60);
expect(result).toContain("...");
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@pelikhan pelikhan merged commit 5b23fd0 into main Feb 5, 2026
51 checks passed
@pelikhan pelikhan deleted the copilot/review-tools-search-object branch February 5, 2026 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants