-
Notifications
You must be signed in to change notification settings - Fork 40
Fix null parameter handling in Prompts and Resources handlers #77
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
Fix null parameter handling in Prompts and Resources handlers #77
Conversation
Ensures abilities without input schemas receive null parameters instead of empty arrays or request params. This is consistent with WP_Ability::validate_input() │ │ expectations and matches the fix applied to tools handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes parameter handling in Prompts and Resources handlers to align with the WP_Ability::validate_input() expectations, following a similar fix previously applied to the tools handler. The change ensures null is passed instead of empty arrays when abilities have no input schema.
Key Changes
- PromptsHandler now checks if an ability has no input schema and empty arguments, passing null in such cases
- ResourcesHandler unconditionally passes null for permission checks and execution since resources don't accept parameters
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| includes/Handlers/Resources/ResourcesHandler.php | Updated to pass null instead of $request_params for resource reads |
| includes/Handlers/Prompts/PromptsHandler.php | Added logic to pass null when ability has no input schema and arguments are empty |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
- Remove input_schema from test/resource ability in DummyAbility - Update execute and permission callbacks to not expect parameters - Update ResourcesHandler to call ability methods without parameters when no input is needed Resources that don't require input should not have an input_schema defined, and their callbacks should not expect parameters to be passed.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #77 +/- ##
============================================
- Coverage 68.94% 68.94% -0.01%
- Complexity 821 823 +2
============================================
Files 46 46
Lines 3037 3040 +3
============================================
+ Hits 2094 2096 +2
- Misses 943 944 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Why
Following the fix applied to the tools handler, prompts and resources handlers also need to pass null instead of empty arrays to abilities without input schemas. This ensures consistency across all MCP component types and matches WP_Ability::validate_input() expectations.
What