Add title parameter to Builder::addResource() and addResourceTemplate() (#310)
#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>
This commit is contained in:
parent
a820497b62
commit
1300d2ee7d
2 changed files with 84 additions and 0 deletions
|
|
@ -56,6 +56,7 @@ final class ArrayLoader implements LoaderInterface
|
|||
* handler: Handler,
|
||||
* uri: string,
|
||||
* name: ?string,
|
||||
* title: ?string,
|
||||
* description: ?string,
|
||||
* mimeType: ?string,
|
||||
* size: int|null,
|
||||
|
|
@ -67,6 +68,7 @@ final class ArrayLoader implements LoaderInterface
|
|||
* handler: Handler,
|
||||
* uriTemplate: string,
|
||||
* name: ?string,
|
||||
* title: ?string,
|
||||
* description: ?string,
|
||||
* mimeType: ?string,
|
||||
* annotations: ?Annotations,
|
||||
|
|
@ -157,6 +159,7 @@ final class ArrayLoader implements LoaderInterface
|
|||
$resource = new Resource(
|
||||
uri: $data['uri'],
|
||||
name: $name,
|
||||
title: $data['title'] ?? null,
|
||||
description: $description,
|
||||
mimeType: $data['mimeType'] ?? null,
|
||||
annotations: $data['annotations'] ?? null,
|
||||
|
|
@ -197,6 +200,7 @@ final class ArrayLoader implements LoaderInterface
|
|||
$template = new ResourceTemplate(
|
||||
uriTemplate: $data['uriTemplate'],
|
||||
name: $name,
|
||||
title: $data['title'] ?? null,
|
||||
description: $description,
|
||||
mimeType: $data['mimeType'] ?? null,
|
||||
annotations: $data['annotations'] ?? null,
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ final class Builder
|
|||
* handler: Handler,
|
||||
* uri: string,
|
||||
* name: ?string,
|
||||
* title: ?string,
|
||||
* description: ?string,
|
||||
* mimeType: ?string,
|
||||
* size: int|null,
|
||||
|
|
@ -134,6 +135,7 @@ final class Builder
|
|||
* handler: Handler,
|
||||
* uriTemplate: string,
|
||||
* name: ?string,
|
||||
* title: ?string,
|
||||
* description: ?string,
|
||||
* mimeType: ?string,
|
||||
* annotations: ?Annotations,
|
||||
|
|
@ -433,6 +435,7 @@ final class Builder
|
|||
* Manually registers a resource handler.
|
||||
*
|
||||
* @param Handler $handler
|
||||
* @param ?string $title Optional human-readable title for display in UI
|
||||
* @param ?Icon[] $icons
|
||||
* @param array<string, mixed>|null $meta
|
||||
*/
|
||||
|
|
@ -440,6 +443,7 @@ final class Builder
|
|||
\Closure|array|string $handler,
|
||||
string $uri,
|
||||
?string $name = null,
|
||||
?string $title = null,
|
||||
?string $description = null,
|
||||
?string $mimeType = null,
|
||||
?int $size = null,
|
||||
|
|
@ -451,6 +455,7 @@ final class Builder
|
|||
'handler',
|
||||
'uri',
|
||||
'name',
|
||||
'title',
|
||||
'description',
|
||||
'mimeType',
|
||||
'size',
|
||||
|
|
@ -466,12 +471,14 @@ final class Builder
|
|||
* Manually registers a resource template handler.
|
||||
*
|
||||
* @param Handler $handler
|
||||
* @param ?string $title Optional human-readable title for display in UI
|
||||
* @param array<string, mixed>|null $meta
|
||||
*/
|
||||
public function addResourceTemplate(
|
||||
\Closure|array|string $handler,
|
||||
string $uriTemplate,
|
||||
?string $name = null,
|
||||
?string $title = null,
|
||||
?string $description = null,
|
||||
?string $mimeType = null,
|
||||
?Annotations $annotations = null,
|
||||
|
|
@ -481,6 +488,7 @@ final class Builder
|
|||
'handler',
|
||||
'uriTemplate',
|
||||
'name',
|
||||
'title',
|
||||
'description',
|
||||
'mimeType',
|
||||
'annotations',
|
||||
|
|
|
|||
Loading…
Reference in a new issue