Skip to content

Return empty completion when no handler matches a valid ref#996

Merged
Kehrlann merged 1 commit into
modelcontextprotocol:mainfrom
jstar0:fix/completion-empty-result
Jun 24, 2026
Merged

Return empty completion when no handler matches a valid ref#996
Kehrlann merged 1 commit into
modelcontextprotocol:mainfrom
jstar0:fix/completion-empty-result

Conversation

@jstar0

@jstar0 jstar0 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Return empty completion when no handler matches a valid ref

Fixes #991.

Summary

completion/complete currently returns -32602 when a prompt or resource template exists and the requested argument is valid, but no completion handler is registered for that specific reference. In that case there are simply no suggestions to return.

Changes

  • Return an empty completion result for valid prompt/resource-template completion requests when no matching completion handler exists.
  • Keep prompt/resource existence checks and argument validation before the completion-handler lookup, so unknown refs and invalid arguments keep their existing error behavior.
  • Add stateful and stateless integration coverage for prompt and resource-template no-handler completions.

Verification

./mvnw -pl mcp-core -am test
./mvnw -pl mcp-test -am -Dtest=McpCompletionTests,HttpServletStatelessIntegrationTests#testCompletionShouldReturnExpectedSuggestions+testCompletionWithoutMatchingHandlerReturnsEmptyResult+testResourceTemplateCompletionWithoutMatchingHandlerReturnsEmptyResult -Dsurefire.failIfNoSpecifiedTests=false test

@Kehrlann Kehrlann force-pushed the fix/completion-empty-result branch from bdacaeb to 8c197e1 Compare June 24, 2026 12:06
@Kehrlann Kehrlann self-requested a review June 24, 2026 12:07
@Kehrlann Kehrlann self-assigned this Jun 24, 2026

@Kehrlann Kehrlann 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.

Hey @jstar0! Thank you for your contribution.

@Kehrlann Kehrlann merged commit 301f8b0 into modelcontextprotocol:main Jun 24, 2026
21 checks passed
Kehrlann added a commit that referenced this pull request Jun 24, 2026
Polish gh-996

Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>
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.

completion/complete should return EMPTY_COMPLETION_RESULT when no handler registered

2 participants