Skip to content

fix: allow elicitations accepted without content #1285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

owengo
Copy link

@owengo owengo commented Aug 20, 2025

This change allows to handle elicitations without any data, just the user action.

Motivation and Context

The change allows to create very simple "Accept / Reject / Cancel" elicitations without check boxes or input data for the user.

cf: #1284

How Has This Been Tested?

Yes we have an MCP server which allows create and update documents in a database, and we have an elicitation requiring the user to accept the action

Breaking Changes

No, the behavior is exactly the same for all the elicitations which actually require data.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

The behavior is possible with the typescript sdk, but not the python sdk:

   const result = await server.server.elicitInput({
       message: `${confirmationMessage}`,
        requestedSchema: {
         type: "object",
         properties: {
         },
         required: []
       }
     });  
     if (result.action === "accept") { 
       log.warn(`User accepted usage of ${toolName}`, {
         user: userEmail,
       });
       return true;
     } else {
...

@owengo owengo requested a review from a team as a code owner August 20, 2025 13:12
@owengo owengo requested a review from ochafik August 20, 2025 13:12
Copy link

@ochafik ochafik left a comment

Choose a reason for hiding this comment

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

Hi @owengo, thanks for sending this!

Suggesting an alternative fix below, please lemme know your thoughts :-)

@@ -102,6 +102,10 @@ async def elicit_with_validation(
# Validate and parse the content using the schema
validated_data = schema.model_validate(result.content)
return AcceptedElicitation(data=validated_data)
elif result.action == "accept":
Copy link

Choose a reason for hiding this comment

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

I think the fix should be above instead: if result.action == "accept" and result.content is not None:

(an empty content {} is considered falsy in Python)

This otherwise allows for content to be omitted ({"action": "accept"}), which isn't consistent with the spec. We should just cater to the valid {"action": "accept", "content": {}} (use case from #1284) unless the spec is updated :-)

Copy link
Author

Choose a reason for hiding this comment

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

You are right, I have pushed your fix.

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