Skip to content

Fix MCP null argument binding and culture-dependent history - #227

Merged
Mike Krüger (mkrueger) merged 4 commits into
mainfrom
dev/mkrueger/fix-mcp-argument-binding
Oct 2, 2026
Merged

Mike Krüger (mkrueger) merged 4 commits into
mainfrom
dev/mkrueger/fix-mcp-argument-binding

Conversation

@mkrueger

@mkrueger Mike Krüger (mkrueger) commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

  1. Explicit null arguments failed to bind. MCP clients often send null for optional arguments, for example watch with {"interval": null}. BindMember unwrapped Nullable<T>, and ConvertJsonElement then called GetDouble()/GetInt32()/GetBoolean() on a JSON null, so the call failed with "Invalid value ...".
  2. Echoed history used the current culture. FormatOptionForHistory/FormatPositionalsForHistory used ToString(). On de-DE, watch --interval 1.5 was recorded as --interval "1,5", so the recorded command line did not replay correctly.

Changes

  • An explicit JSON null for an option or parameter is treated as omitted. It is not bound, not echoed into history, and not counted as a supplied required parameter, so a required parameter passed as null still reports the existing missing-parameter error.
  • The paging continuation argument keeps rejecting null, because a null token must not be sent back: it indicates exhaustion unless resultIncomplete is true, which indicates truncated results that cannot be resumed. The rm safety options partition-key (including pk) and etag also reject explicit null before confirmation rather than dropping their safeguards.
  • History values are formatted with CultureInfo.InvariantCulture, including array elements.
  • docs/mcp.md and the tool schema document null handling, the continuation exception, and incomplete non-resumable results.
  • CallTool_EchoCommand_ReturnsSuccessResult now uses a unique message. Other tests record the same echo "hello" "world" line, and history de-duplication made its "history grows by one" assertion depend on test order.

Tests

ToolOperationsCallToolTests covers null for a nullable value-typed option, a string option, and a required parameter, plus invariant history formatting under de-DE. The existing null continuation rejection tests are unchanged.

Treat explicit JSON null option and parameter values as omitted before
binding, so nullable value-typed options such as watch --interval no
longer fail with "Invalid value". A null continuation token is still
rejected because it signals an exhausted result set.

Render echoed history values with the invariant culture so recorded
command lines stay replayable, and make the echo MCP test independent
of other tests that record the same history line.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation matches the stated behavior and includes appropriate regression coverage and documentation.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes MCP null argument binding and culture-safe command history replay.

Changes:

  • Treats explicit null arguments as omitted while preserving continuation-token validation.
  • Formats history values using invariant culture.
  • Adds focused tests and MCP documentation.
File Description
docs/​mcp.md Documents null argument behavior.
ToolOperations.cs Implements null omission and invariant formatting.
ToolOperationsCallToolTests.cs Covers null binding, culture formatting, and history isolation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-code-quality

github-code-quality Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: C#

C# / code-coverage/dotnet

The overall line coverage in commit 05a5921 in the dev/mkrueger/fix-mcp... branch remains at 66%, unchanged from commit 6011539 in the main branch.


Updated October 02, 2026 10:39 UTC

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 2, 2026 09:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation, documentation, and focused regression coverage are consistent and complete.

Review effort: Balanced
Findings: None

@mkrueger
Mike Krüger (mkrueger) enabled auto-merge (squash) October 2, 2026 10:12
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 2, 2026 10:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The new documentation incorrectly treats every null continuation token as exhaustion, overlooking non-resumable truncated results.

Review effort: Balanced
Findings: 1 Low severity

Open (1)

Comment thread docs/mcp.md Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 2, 2026 10:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation, documentation, and focused regression coverage are consistent and complete.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@mkrueger
Mike Krüger (mkrueger) merged commit dc14571 into main Oct 2, 2026
12 checks passed
@mkrueger
Mike Krüger (mkrueger) deleted the dev/mkrueger/fix-mcp-argument-binding branch October 2, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants