-
Notifications
You must be signed in to change notification settings - Fork 0
fix(macros): support non-String parameter types in mcp_resource #78
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Previously, all URI template parameters were converted to String regardless of the method's actual parameter type, causing type mismatches for methods expecting integers, floats, booleans, etc. Changes: - Added method_param_types field to ResourceInfo struct - Generate proper .parse() calls for non-String types with error handling - String parameters still use direct .to_string() for efficiency Added comprehensive edge case tests covering: - Multiple URI parameters - Non-String types (u32, u64, i64, f64, bool) - Mixed String and non-String parameters - Static resources (no parameters) - Complex return types - Async resources - Mixed tools and resources - Custom error types
Code Coverage Report 📊Local Coverage: 23.48%
Coverage Details📋 Full Report: View on Codecov |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
PR Validation ResultsQuick Validation: ✅
Summary: ✅ All checks passed |
Add 19 new test cases covering: - Parse failure handling for non-string types - Error propagation from resource methods - Complex URI patterns with prefix/suffix - JSON content verification - Empty resource lists - Self-referential resources - Long URIs and parameter order verification - Async error handling
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixed a bug where the
mcp_resourcemacro always converted URI template parameters toString, regardless of the method's actual parameter type.Before: Resource methods with non-String parameters (like
u64,i32,f64,bool) would fail to compile because the macro generated code that passedStringvalues.After: The macro now properly parses URI parameters to match the method's parameter types using
.parse().Changes
method_param_typesfield toResourceInfostruct to track parameter types.parse()calls for non-String types with error handling.to_string()for efficiencyTest Plan