Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/server/mcp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,11 @@ describe("resource()", () => {
{
description: "Test resource",
mimeType: "text/plain",
annotations: {
audience: ["assistant"],
priority: 0.42,
lastModified: "2025-01-12T15:00:58Z"
}
},
async () => ({
contents: [
Expand Down Expand Up @@ -2140,6 +2145,11 @@ describe("resource()", () => {
expect(result.resources).toHaveLength(1);
expect(result.resources[0].description).toBe("Test resource");
expect(result.resources[0].mimeType).toBe("text/plain");
expect(result.resources[0].annotations).toEqual({
audience: ["assistant"],
priority: 0.42,
lastModified: "2025-01-12T15:00:58Z"
});
});

/***
Expand Down
7 changes: 7 additions & 0 deletions src/spec.types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,13 @@ function checkBlobResourceContents(
sdk = spec;
spec = sdk;
}
function checkResourceAnnotations(
sdk: RemovePassthrough<SDKTypes.ResourceAnnotations>,
spec: SpecTypes.Annotations
) {
sdk = spec;
spec = sdk;
}
function checkResource(
sdk: RemovePassthrough<SDKTypes.Resource>,
spec: SpecTypes.Resource
Expand Down
28 changes: 28 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,28 @@ export const BlobResourceContentsSchema = ResourceContentsSchema.extend({
blob: Base64Schema,
});

/**
* Optional annotations providing clients additional context about a resource.
*/
export const ResourceAnnotationsSchema = z
.object({
/**
* Intended audience(s) for the resource.
*/
audience: z.optional(z.array(z.enum(["user", "assistant"]))),

/**
* Importance hint for the resource, from 0 (least) to 1 (most).
*/
priority: z.optional(z.number().min(0).max(1)),

/**
* ISO 8601 timestamp for the most recent modification.
*/
lastModified: z.optional(z.string().datetime({ offset: true })),
})
.passthrough();

/**
* A known resource that the server is capable of reading.
*/
Expand All @@ -539,6 +561,11 @@ export const ResourceSchema = BaseMetadataSchema.extend({
*/
mimeType: z.optional(z.string()),

/**
* Optional annotations for the client.
*/
annotations: z.optional(ResourceAnnotationsSchema),

/**
* An optional list of icons for this resource.
*/
Expand Down Expand Up @@ -1608,6 +1635,7 @@ export type PaginatedResult = Infer<typeof PaginatedResultSchema>;
export type ResourceContents = Infer<typeof ResourceContentsSchema>;
export type TextResourceContents = Infer<typeof TextResourceContentsSchema>;
export type BlobResourceContents = Infer<typeof BlobResourceContentsSchema>;
export type ResourceAnnotations = Infer<typeof ResourceAnnotationsSchema>;
export type Resource = Infer<typeof ResourceSchema>;
export type ResourceTemplate = Infer<typeof ResourceTemplateSchema>;
export type ListResourcesRequest = Infer<typeof ListResourcesRequestSchema>;
Expand Down