Skip to content

Commit 628e7c6

Browse files
authored
Add Resource Annotations section to MCP documentation (#10931)
* Add Resource Annotations section to MCP documentation * Fix Audience role casing in MCP documentation for consistency
1 parent c515575 commit 628e7c6

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

mcp.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- [Resource URI and MIME Type](#resource-uri-and-mime-type)
2828
- [Resource Request](#resource-request)
2929
- [Resource Dependency Injection](#resource-dependency-injection)
30+
- [Resource Annotations](#resource-annotations)
3031
- [Conditional Resource Registration](#conditional-resource-registration)
3132
- [Resource Responses](#resource-responses)
3233
- [Metadata](#metadata)
@@ -1030,6 +1031,39 @@ class WeatherGuidelinesResource extends Resource
10301031
}
10311032
```
10321033

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+
10331067
<a name="conditional-resource-registration"></a>
10341068
### Conditional Resource Registration
10351069

0 commit comments

Comments
 (0)