-
Notifications
You must be signed in to change notification settings - Fork 84
[Server] Add getRegistry() method to Server class for debugging access #75
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
base: main
Are you sure you want to change the base?
[Server] Add getRegistry() method to Server class for debugging access #75
Conversation
Expose the Registry through the Server class to enable debugging and monitoring tools like Symfony Web Profiler to access discovered capabilities (tools, resources, prompts, and resource templates). Changes: - Add ReferenceProviderInterface parameter to Server constructor - Add getRegistry() method to Server class - Update ServerBuilder to pass registry to Server - Update example to use new Server constructor signature - Add test coverage for getRegistry() method Resolves modelcontextprotocol#74
|
If we make services injectable, it shouldn't be needed to use getters for them since the runtime (or in your case the Symfony DIC) should know them already. Having getters for service dependencies on services leads to misusage for using them to access that service instead of having the explicit dependency. and if the use case is only the profiler toolbar, i'm against adding it. if it is too hard to get the registry instance in a different way, we usually use |
|
My PR was @camilleislasse could you check if #111 helps with your use case? We may close this then. |
|
Thanks for the feedback @soyuka and @chr-hertel! I checked #111 and I see it adds addLoaders(), but I'm not sure how to use it properly for my use case. @chr-hertel I understand the concerns about getters and using Traceable decorators instead. However, I'm struggling to see how to apply that pattern here since the Registry seems to only exist inside Builder::build() as a local variable and isn't passed to the Server. Looking at the code after #111, I could technically create a custom Loader that captures the Registry reference when load() is called, but that feels wrong - like I'd be misusing the Loader mechanism just to get access to something. I might be missing something obvious though. What's the recommended way to access the Registry for profiling purposes? Should I:
|
|
Loaders give you the ability to fill the registry, I'm not sure why you need access to the Registry? Could you expose exactly what you try to do? |
Summary
Expose the Registry through the Server class to enable debugging and monitoring tools like Symfony Web Profiler to access discovered capabilities.
Changes
ReferenceProviderInterface $registryparameter toServerconstructorgetRegistry(): ReferenceProviderInterfacemethod toServerclassServerBuilderto pass registry toServerconstructorServerconstructor signaturegetRegistry()methodUse Case
This enables integration with debugging tools like Symfony Web Profiler by providing access to:
getTools()- All registered toolsgetResources()- All registered resourcesgetPrompts()- All registered promptsgetResourceTemplates()- All registered resource templatesTest Plan
getRegistry()methodResolves #74