Skip to content

mcp: fix appendBoolFlag to handle explicit false values#3746

Closed
thonmay wants to merge 1 commit into
knative:mainfrom
thonmay:fix/mcp-append-bool-flag
Closed

mcp: fix appendBoolFlag to handle explicit false values#3746
thonmay wants to merge 1 commit into
knative:mainfrom
thonmay:fix/mcp-append-bool-flag

Conversation

@thonmay
Copy link
Copy Markdown

@thonmay thonmay commented May 15, 2026

Changes

Fixes a correctness bug in appendBoolFlag: explicit false values were silently dropped, making it impossible for agents to explicitly disable bool flags like --insecure or --verbose.

Before: only appended the flag when value was true. Explicit false was ignored.

After (tri-state semantics):

  • nil — omit flag entirely (not provided by agent)
  • true--flag
  • false--flag=false

Also fixes argsToMap in tools_test.go to correctly parse --flag=value format. Previously --verbose=false was treated as a boolean flag with empty value instead of a string flag with value false.

Tests added:

  • TestAppendBoolFlag with subtests for nil/true/false cases

All existing tests pass.

/kind bug

Fixes #3705

Fix MCP appendBoolFlag: explicit false values now correctly passed as --flag=false instead of being silently dropped

Previously appendBoolFlag only appended the flag when value was true,
silently dropping explicit false values. This meant agents could not
explicitly disable bool flags like --insecure or --verbose.

Fix uses proper tri-state semantics:
  nil   -> omit flag entirely (not provided)
  true  -> --flag
  false -> --flag=false

Also updates argsToMap in tools_test.go to correctly parse --flag=value
format, and adds TestAppendBoolFlag covering all three cases.

Fixes knative#3705

Signed-off-by: Thonmay <mdthoriqulislam384@gmail.com>
@knative-prow knative-prow Bot added the kind/bug Bugs label May 15, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 15, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: thonmay
Once this PR has been reviewed and has the lgtm label, please assign lkingland for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot requested review from dsimansk and jrangelramos May 15, 2026 08:59
@knative-prow knative-prow Bot added size/M 🤖 PR changes 30-99 lines, ignoring generated files. needs-ok-to-test 🤖 Needs an org member to approve testing labels May 15, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 15, 2026

Hi @thonmay. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@thonmay
Copy link
Copy Markdown
Author

thonmay commented May 15, 2026

Closing this in favor of #3709 which was opened earlier by @Elvand-Lie and addresses the same issue. Sorry for the duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Bugs needs-ok-to-test 🤖 Needs an org member to approve testing size/M 🤖 PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcp: appendBoolFlag silently drops explicit false values

1 participant