Skip to content

[Server] Fix "0" prefix offering all completions - #655

Merged
chr-hertel merged 1 commit into
modelcontextprotocol:mainfrom
chr-hertel:fix-zero-completion-prefix
Nov 2, 2026
Merged

chr-hertel merged 1 commit into
modelcontextprotocol:mainfrom
chr-hertel:fix-zero-completion-prefix

Conversation

@chr-hertel

Copy link
Copy Markdown
Member

empty("0") is true, so EnumCompletionProvider and ListCompletionProvider returned every value for the prefix 0 instead of only the ones starting with it. Now only an empty prefix offers everything.

Spotted while reviewing #652, which pinned the behavior in a test - replaced here. #649 adds the same test for the list provider and needs an update after this.

`empty("0")` is true, so `EnumCompletionProvider` and `ListCompletionProvider`
returned every value for that prefix.

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.

🟢 Approval recommended

No active review issues are recorded for the fix that treats "0" as a literal completion prefix.

No open issues 🎉

What changed in this PR

Fixes server-side enum and list completion filtering so "0" is treated as a literal prefix. Only an empty string returns all available values.

Changes:

  • Replace empty() checks with strict empty-string comparisons in both providers.
  • Add regression tests for "0" and update enum coverage to preserve empty-prefix behavior.
  • Document the fix in the changelog.
File Description
tests/​Unit/​Capability/​Completion/​ListCompletionProviderTest.php Verify "0" returns only matching list values.
tests/​Unit/​Capability/​Completion/​EnumCompletionProviderTest.php Verify zero-prefix filtering and empty-prefix behavior.
src/​Capability/​Completion/​ListCompletionProvider.php Restrict unfiltered results to an empty prefix.
src/​Capability/​Completion/​EnumCompletionProvider.php Restrict unfiltered results to an empty prefix.
CHANGELOG.md Record the completion-filtering fix.

Review effort: Balanced

@chr-hertel
chr-hertel merged commit 540cc37 into modelcontextprotocol:main Nov 2, 2026
28 checks passed
@chr-hertel
chr-hertel deleted the fix-zero-completion-prefix branch November 2, 2026 21:56
@chr-hertel chr-hertel added the Server Issues & PRs related to the Server component label Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Server Issues & PRs related to the Server component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants