|
27 | 27 | - [Resource URI and MIME Type](#resource-uri-and-mime-type) |
28 | 28 | - [Resource Request](#resource-request) |
29 | 29 | - [Resource Dependency Injection](#resource-dependency-injection) |
| 30 | + - [Resource Annotations](#resource-annotations) |
30 | 31 | - [Conditional Resource Registration](#conditional-resource-registration) |
31 | 32 | - [Resource Responses](#resource-responses) |
32 | 33 | - [Metadata](#metadata) |
@@ -1030,6 +1031,39 @@ class WeatherGuidelinesResource extends Resource |
1030 | 1031 | } |
1031 | 1032 | ``` |
1032 | 1033 |
|
| 1034 | +<a name="resource-annotations"></a> |
| 1035 | +### Resource Annotations |
| 1036 | + |
| 1037 | +You may enhance your resources with [annotations](https://modelcontextprotocol.io/specification/2025-06-18/schema#resourceannotations) to provide additional metadata to AI clients. Annotations are added to resources via attributes: |
| 1038 | + |
| 1039 | +```php |
| 1040 | +<?php |
| 1041 | + |
| 1042 | +namespace App\Mcp\Resources; |
| 1043 | + |
| 1044 | +use Laravel\Mcp\Enums\Role; |
| 1045 | +use Laravel\Mcp\Server\Annotations\Audience; |
| 1046 | +use Laravel\Mcp\Server\Annotations\LastModified; |
| 1047 | +use Laravel\Mcp\Server\Annotations\Priority; |
| 1048 | +use Laravel\Mcp\Server\Resource; |
| 1049 | + |
| 1050 | +#[Audience(Role::User)] |
| 1051 | +#[Priority(0.9)] |
| 1052 | +#[LastModified('2025-01-12T15:00:58Z')] |
| 1053 | +class UserDashboardResource extends Resource |
| 1054 | +{ |
| 1055 | + // |
| 1056 | +} |
| 1057 | +``` |
| 1058 | + |
| 1059 | +Available annotations include: |
| 1060 | + |
| 1061 | +| Annotation | Type | Description | |
| 1062 | +| ---------------- | -------------- | ----------------------------------------------------------------------------------------------- | |
| 1063 | +| `#[Audience]` | Role or array | Specifies the intended audience (`Role::User`, `Role::Assistant`, or both). | |
| 1064 | +| `#[Priority]` | float | A numerical score between 0.0 and 1.0 indicating resource importance. | |
| 1065 | +| `#[LastModified]`| string | An ISO 8601 timestamp showing when the resource was last updated. | |
| 1066 | + |
1033 | 1067 | <a name="conditional-resource-registration"></a> |
1034 | 1068 | ### Conditional Resource Registration |
1035 | 1069 |
|
|
0 commit comments