fix:Improve code maintainability: Add a public mcp_server attribute t… #1946
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.
…o FastMCP, implement RootsListChangedNotification handling, simplify capability check logic, and optimize the use of the TRANSPORTS variable
This PR improves code maintainability and functionality by adding a public
mcp_serverproperty to FastMCP, implementing server-side handling forRootsListChangedNotification, simplifying thecheck_client_capabilitymethod, and optimizing the use of the TRANSPORTS variable in the run method.Motivation and Context
The changes address several issues:
_mcp_serverproperty inInMemoryTransportcausing type checking warningsRootsListChangedNotification, making the client method effectively unusable__args__property ofLiteraltype in the run methodThese improvements enhance code maintainability, readability, and robustness while maintaining backward compatibility.
How Has This Been Tested?
All changes have been thoroughly tested using the project's existing test suite:
The tests cover various scenarios including:
Breaking Changes
No breaking changes. All modifications maintain backward compatibility and follow existing code patterns.
Types of changes
Checklist
Additional context
The changes were implemented with a focus on: