Add title parameter to Builder::addResource() and addResourceTemplate()#310
Merged
Conversation
#301 added the `title` field to the `Resource`/`ResourceTemplate` schema classes and the `McpResource`/`McpResourceTemplate` attributes, but the manual registration methods on `Builder` were never updated — so manual registration could not set a resource title, unlike tools and prompts. Add a `$title` parameter between `$name` and `$description` (matching `addTool()`/`addPrompt()`) and propagate it through `ArrayLoader` when constructing the `Resource`/`ResourceTemplate` objects. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
soyuka
approved these changes
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
#301 added the
titlefield to theResource/ResourceTemplateschema classes and theMcpResource/McpResourceTemplateattributes, but the manual registration methods onBuilderwere missed. As a result, manual registration could not set a resource title — inconsistent withaddTool()andaddPrompt(), which both gainedtitlelately.Changes
Builder::addResource()andBuilder::addResourceTemplate()gain a$titleparameter, placed between$nameand$descriptionto matchaddTool()/addPrompt().ArrayLoaderpropagatestitleinto the constructedResource/ResourceTemplateobjects, and its PHPStan array shapes are updated accordingly.BC Break
Inserting
$titlebetween$nameand$descriptionshifts positional arguments — callers passing$description(and later args) positionally must switch to named arguments. This mirrors the equivalent v0.5.0 breaks foraddTool()/addPrompt().Tests
ArrayLoaderResourceTitleTestcovering title propagation for both resources and resource templates.phpstanandphp-cs-fixerclean. Full unit suite passes (the 2 pre-existingDiscoveryTestfailures are unrelated to this change).🤖 Generated with Claude Code