Skip to content

remove final keyword on MCP attributes classes #239

@fox-john

Description

@fox-john

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.php
  • McpResource.php
  • McpResourceTemplate.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:

  1. Customizing how resources are identified.
  2. Injecting additional context into prompts during the discovery phase.
  3. Supporting advanced use cases in a CustomDiscoverer implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions