[Server] refactor: registry loader #111
Merged
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.
Refactor capability registration in Server Builder using dedicated loaders. A solution for #74
Motivation and Context
The previous
Server/Builder.phpcontained extensive logic for registering capabilities (tools, resources, prompts) both manually and through discovery. This led to a large and less modularBuilderclass. This change aims to improve the architecture by introducing dedicated loader classes for capability registration.How Has This Been Tested?
Existing tests for server capabilities and discovery should cover the functionality. No new tests were added as this is a refactoring. Let me know if I should add some as I'm not sure this is going to be accepted I didn't wanted to put unnecessary energy into unit testing.
Breaking Changes
No breaking changes are expected as this is an internal refactoring. The public API of the
Server/Builderremains the same.Types of changes
Checklist
Additional context
This refactoring extracts the capability registration logic into
ArrayRegistryLoaderfor manual registrations andDiscoveryRegistryLoaderfor discovery-based registrations. Both implementRegistryLoaderInterface. TheServer/Buildernow orchestrates these loaders, leading to a more extensible design.