-
Notifications
You must be signed in to change notification settings - Fork 116
Description
Feature Request: Remove final keyword from MCP Attributes classes
Is your feature request related to a problem? Please describe.
Yes. Currently, the classes McpPrompt, McpResource, and McpResourceTemplate are defined with the final keyword. This strictly prevents inheritance.
In my current implementation, I am building a CustomDiscoverer. I need to extend these classes to add custom metadata and specialized logic required by my discovery process. The final restriction makes it impossible to leverage polymorphism, forcing me to use hacky workarounds or duplicate code.
Describe the solution you'd like
I would like to remove the final keyword from the following classes:
McpPrompt.phpMcpResource.phpMcpResourceTemplate.php
This change will allow these core entities to be extended by developers who need to implement custom behavior while staying compatible with the base types expected by the SDK.
Describe alternatives you've considered
- Duplicating Classes: This is a maintenance nightmare and breaks interoperability with the rest of the library.
Additional context
Removing final aligns with the "Open-Closed Principle" (open for extension, closed for modification), especially for DTO-like or Entity-like classes in a SDK that aims to be flexible.
This is particularly critical for:
- Customizing how resources are identified.
- Injecting additional context into prompts during the discovery phase.
- Supporting advanced use cases in a
CustomDiscovererimplementation.