-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add auth parameter to #[mcp_server] macro and enhance middleware tests #22
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
Add authentication configuration parameter to the #[mcp_server] macro to simplify development setup and improve developer experience. Key features: - auth = "memory" for in-memory storage (development) - auth = "disabled" for disabled authentication (testing) - auth = "file" for file-based storage (production) - Support for custom auth configuration expressions This addresses the issue where the default configuration always creates files instead of using in-memory storage for development, making the macro system more user-friendly for different environments. Examples: - #[mcp_server(name = "Dev Server", auth = "memory")] - #[mcp_server(name = "Test Server", auth = "disabled")] - #[mcp_server(name = "Prod Server", auth = "file", app_name = "my-app")] Includes comprehensive tests and documentation examples.
Add extensive test suite for MCP authentication middleware components to improve code coverage and verify correct functionality. Tests include: - Basic middleware creation and configuration - Anonymous method detection and processing - API key authentication with Bearer tokens - X-API-Key header authentication support - Authentication requirement enforcement - Invalid credential rejection handling - Optional authentication mode testing These tests provide comprehensive coverage for both session_middleware.rs and mcp_auth.rs components, ensuring robust authentication handling across different scenarios and configurations.
Fix clippy warnings to improve code quality and maintainability:
- Add #[allow(clippy::too_many_arguments)] for generate_server_implementation
function which requires multiple parameters for macro generation
- Fix uninlined format args by using format\!("{custom}...") syntax
- Replace map_or with is_some_and for better readability and performance
These changes maintain the same functionality while following Rust
best practices and improving code clarity.
PR Validation ResultsQuick Validation: ✅
Validation Framework: ✅
Compatibility Check: ✅
Summary: ✅ All checks passed |
Increment version to reflect new features and improvements: - Authentication parameter support in #[mcp_server] macro - Enhanced middleware test coverage - Code quality improvements from clippy fixes - Better developer experience for auth configuration This release improves the macro system usability and adds comprehensive testing for authentication middleware components.
fd1bcf0 to
0b3909a
Compare
Fixes duplicate method definition errors (E0592) by using trait-based integration instead of conflicting internal methods. mcp_server now provides default helper methods, mcp_tools implements McpToolsProvider trait without method name conflicts.
- Fixed missing closing braces in edge_case_tests.rs - Corrected indentation in impl blocks for mcp_tools - Fixed trailing whitespace in integration_full_tests.rs
- Fix import ordering in all example files for rustfmt compliance - Implement passthrough for mcp_tools macro to resolve syntax errors - Fix test file issues (private field access, missing imports) - Clean up unused imports and dead code warnings
- Prefix unused variables with underscore - Add #[allow(dead_code)] for test methods that demonstrate API but aren't called
- Add missing StorageConfig import in auth_parameter_test.rs - Fix field access from 'counter' to '_counter' in integration_full_tests.rs - Add dead_code allows and fix format string warnings in auth_configuration.rs - Remove unused import in tool_discovery_test.rs - Add module_inception allow in edge_case_tests.rs All tests now pass and clippy warnings are resolved.
Code Coverage Report 📊Local Coverage: 19.86%
Coverage Details📋 Full Report: View on Codecov |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Fix formatting issues in auth_parameter_test.rs by consolidating multi-line assert statements to single lines as required by rustfmt.
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
This PR introduces several enhancements to improve developer experience and code quality:
🚀 New Features
Authentication Parameter for #[mcp_server] Macro
authparameter to simplify authentication configuration"memory","disabled","file", and custom expressions🧪 Enhanced Test Coverage
Comprehensive Middleware Tests
session_middleware.rsandmcp_auth.rsfunctionality🛠️ Code Quality Improvements
Clippy Fixes
📦 Version Update
Usage Examples
Testing
Breaking Changes
None - this is a backward compatible addition.
Checklist