Skip to content

Add title parameter to Builder::addResource() and addResourceTemplate()#310

Merged
chr-hertel merged 1 commit into
mainfrom
feature/builder-resource-title
May 18, 2026
Merged

Add title parameter to Builder::addResource() and addResourceTemplate()#310
chr-hertel merged 1 commit into
mainfrom
feature/builder-resource-title

Conversation

@chr-hertel
Copy link
Copy Markdown
Member

@chr-hertel chr-hertel commented May 17, 2026

Summary

#301 added the title field to the Resource/ResourceTemplate schema classes and the McpResource/McpResourceTemplate attributes, but the manual registration methods on Builder were missed. As a result, manual registration could not set a resource title — inconsistent with addTool() and addPrompt(), which both gained title lately.

Changes

  • Builder::addResource() and Builder::addResourceTemplate() gain a $title parameter, placed between $name and $description to match addTool()/addPrompt().
  • ArrayLoader propagates title into the constructed Resource/ResourceTemplate objects, and its PHPStan array shapes are updated accordingly.
  • CHANGELOG updated under 0.6.0.

BC Break

Inserting $title between $name and $description shifts positional arguments — callers passing $description (and later args) positionally must switch to named arguments. This mirrors the equivalent v0.5.0 breaks for addTool()/addPrompt().

Tests

  • New ArrayLoaderResourceTitleTest covering title propagation for both resources and resource templates.
  • phpstan and php-cs-fixer clean. Full unit suite passes (the 2 pre-existing DiscoveryTest failures are unrelated to this change).

🤖 Generated with Claude Code

#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>
@chr-hertel chr-hertel added Server Issues & PRs related to the Server component enhancement Request for a new feature that's not currently supported labels May 17, 2026
@chr-hertel chr-hertel added this to the 0.6.0 milestone May 17, 2026
@chr-hertel chr-hertel merged commit 1300d2e into main May 18, 2026
20 checks passed
@chr-hertel chr-hertel deleted the feature/builder-resource-title branch May 18, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Request for a new feature that's not currently supported Server Issues & PRs related to the Server component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants