Skip to content

Conversation

camilleislasse
Copy link

Summary

Expose the Registry through the Server class to enable debugging and monitoring tools like Symfony Web Profiler to access discovered capabilities.

Changes

  • Add ReferenceProviderInterface $registry parameter to Server constructor
  • Add getRegistry(): ReferenceProviderInterface method to Server class
  • Update ServerBuilder to pass registry to Server constructor
  • Update standalone example to use new Server constructor signature
  • Add test coverage for getRegistry() method

Use Case

This enables integration with debugging tools like Symfony Web Profiler by providing access to:

  • getTools() - All registered tools
  • getResources() - All registered resources
  • getPrompts() - All registered prompts
  • getResourceTemplates() - All registered resource templates

Test Plan

  • All existing tests pass
  • New test added for getRegistry() method
  • PHP CS Fixer validation passes
  • PHPStan static analysis passes
  • Manual testing with various MCP capabilities confirmed working

Resolves #74

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
@chr-hertel
Copy link
Member

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 Traceable* decorator to gather insights for the profiler.

@chr-hertel chr-hertel added the Server Issues & PRs related to the Server component label Sep 21, 2025
@chr-hertel chr-hertel changed the title Add getRegistry() method to Server class for debugging access [Server] Add getRegistry() method to Server class for debugging access Sep 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Server Issues & PRs related to the Server component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Server] Expose Server Registry for debugging and profiling tools

2 participants