You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add title field to Resource and ResourceTemplate (#301)
The MCP specification (2025-11-25) defines an optional title field for
Resource and ResourceTemplate as a human-readable display label, distinct
from name (a short identifier). Tool and Prompt already implement this
field; Resource and ResourceTemplate were missing it.
Changes:
- Add title parameter to Resource and ResourceTemplate constructors
- Add title to fromArray(), jsonSerialize(), and PHPStan type arrays
- Add title to McpResource and McpResourceTemplate attributes
- Pass title through Discoverer when constructing schema objects
- Add tests for deserialization, serialization, and null omission
Fixes#296
Copy file name to clipboardExpand all lines: src/Schema/Resource.php
+12-6Lines changed: 12 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,7 @@
22
22
* @phpstan-type ResourceData array{
23
23
* uri: string,
24
24
* name: string,
25
+
* title?: string,
25
26
* description?: string,
26
27
* mimeType?: string,
27
28
* annotations?: AnnotationsData,
@@ -47,19 +48,19 @@ class Resource implements \JsonSerializable
47
48
48
49
/**
49
50
* @param string $uri the URI of this resource
50
-
* @param string $name A human-readable name for this resource. This can be used by clients to populate UI elements.
51
-
* @param ?string $description A description of what this resource represents. This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model.
51
+
* @param string $name a short identifier for this resource
52
+
* @param ?string $title optional human-readable title for display in UI
53
+
* @param ?string $description A description of what this resource represents. This can be used by clients to improve the LLM's understanding of available resources.
52
54
* @param ?string $mimeType the MIME type of this resource, if known
53
55
* @param ?Annotations $annotations optional annotations for the client
54
-
* @param ?int $size The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
56
+
* @param ?int $size the size of the raw resource content, in bytes (before base64 encoding or any tokenization), if known
55
57
* @param ?Icon[] $icons optional icons representing the resource
Copy file name to clipboardExpand all lines: src/Schema/ResourceTemplate.php
+13-5Lines changed: 13 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,7 @@
21
21
* @phpstan-type ResourceTemplateData array{
22
22
* uriTemplate: string,
23
23
* name: string,
24
+
* title?: string,
24
25
* description?: string|null,
25
26
* mimeType?: string|null,
26
27
* annotations?: AnnotationsData|null,
@@ -44,15 +45,17 @@ class ResourceTemplate implements \JsonSerializable
44
45
45
46
/**
46
47
* @param string $uriTemplate a URI template (according to RFC 6570) that can be used to construct resource URIs
47
-
* @param string $name A human-readable name for the type of resource this template refers to. This can be used by clients to populate UI elements.
48
-
* @param string|null $description This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model.
49
-
* @param string|null $mimeType The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type.
50
-
* @param Annotations|null $annotations optional annotations for the client
0 commit comments