From 9e5ec027236de29161d5a1ac615bb8029c489f38 Mon Sep 17 00:00:00 2001 From: bzsurbhi Date: Mon, 19 May 2025 16:00:14 -0700 Subject: [PATCH 1/2] fix: add status field in Resource class and Resource as a return type in CallToolResult --- schema/draft/schema.json | 16 ++++++++++++++++ schema/draft/schema.ts | 20 +++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/schema/draft/schema.json b/schema/draft/schema.json index e8a816ef5..38746bf0f 100644 --- a/schema/draft/schema.json +++ b/schema/draft/schema.json @@ -134,6 +134,9 @@ }, { "$ref": "#/definitions/EmbeddedResource" + }, + { + "$ref": "#/definitions/Resource" } ] }, @@ -177,6 +180,9 @@ }, { "$ref": "#/definitions/EmbeddedResource" + }, + { + "$ref": "#/definitions/Resource" } ] }, @@ -1622,6 +1628,16 @@ "description": "A description of what this resource represents.\n\nThis 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.", "type": "string" }, + "status": { + "description": "The status of this resource.", + "enum": [ + "pending", + "ready", + "error", + "deleted" + ], + "type": "string" + }, "mimeType": { "description": "The MIME type of this resource, if known.", "type": "string" diff --git a/schema/draft/schema.ts b/schema/draft/schema.ts index 8aeecad77..e6a621172 100644 --- a/schema/draft/schema.ts +++ b/schema/draft/schema.ts @@ -439,6 +439,17 @@ export interface ResourceUpdatedNotification extends Notification { }; } +/** + * The status of this resource. + * + * This can be used by clients to determine whether the resource is available for use. + */ +export type ResourceStatus = + | "pending" + | "ready" + | "error" + | "deleted" + /** * A known resource that the server is capable of reading. */ @@ -464,6 +475,13 @@ export interface Resource { */ description?: string; + /** + * The status of this resource. + * + * This can be used by clients to determine whether the resource is available for use. + */ + status?: ResourceStatus; + /** * The MIME type of this resource, if known. */ @@ -697,7 +715,7 @@ export interface ListToolsResult extends PaginatedResult { */ export type CallToolResult = CallToolUnstructuredResult | CallToolStructuredResult; -export type ContentList = (TextContent | ImageContent | AudioContent | EmbeddedResource)[]; +export type ContentList = (TextContent | ImageContent | AudioContent | EmbeddedResource | Resource)[]; /** * Tool result for tools that do not declare an outputSchema. From a58e38a5e673a789086c62dedc9a0cf22c5e46b7 Mon Sep 17 00:00:00 2001 From: bzsurbhi Date: Thu, 22 May 2025 12:19:32 -0700 Subject: [PATCH 2/2] chore: update resourceStatus enum --- schema/draft/schema.json | 39 +++++++++++++++++++++++---------------- schema/draft/schema.ts | 2 +- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/schema/draft/schema.json b/schema/draft/schema.json index 38746bf0f..d10c0b7d7 100644 --- a/schema/draft/schema.json +++ b/schema/draft/schema.json @@ -123,6 +123,9 @@ "description": "If the Tool defines an outputSchema, this field MAY be present in the result.\nTools should use this field to provide compatibility with older clients that do not support structured content.\nClients that support structured content should ignore this field.", "items": { "anyOf": [ + { + "$ref": "#/definitions/Resource" + }, { "$ref": "#/definitions/TextContent" }, @@ -134,9 +137,6 @@ }, { "$ref": "#/definitions/EmbeddedResource" - }, - { - "$ref": "#/definitions/Resource" } ] }, @@ -169,6 +169,9 @@ "description": "A list of content objects that represent the result of the tool call.\n\nIf the Tool does not define an outputSchema, this field MUST be present in the result.", "items": { "anyOf": [ + { + "$ref": "#/definitions/Resource" + }, { "$ref": "#/definitions/TextContent" }, @@ -180,9 +183,6 @@ }, { "$ref": "#/definitions/EmbeddedResource" - }, - { - "$ref": "#/definitions/Resource" } ] }, @@ -422,6 +422,9 @@ "ContentList": { "items": { "anyOf": [ + { + "$ref": "#/definitions/Resource" + }, { "$ref": "#/definitions/TextContent" }, @@ -1628,16 +1631,6 @@ "description": "A description of what this resource represents.\n\nThis 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.", "type": "string" }, - "status": { - "description": "The status of this resource.", - "enum": [ - "pending", - "ready", - "error", - "deleted" - ], - "type": "string" - }, "mimeType": { "description": "The MIME type of this resource, if known.", "type": "string" @@ -1650,6 +1643,10 @@ "description": "The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.\n\nThis can be used by Hosts to display file sizes and estimate context window usage.", "type": "integer" }, + "status": { + "$ref": "#/definitions/ResourceStatus", + "description": "The status of this resource.\n\nThis can be used by clients to determine whether the resource is available for use." + }, "uri": { "description": "The URI of this resource.", "format": "uri", @@ -1723,6 +1720,16 @@ ], "type": "object" }, + "ResourceStatus": { + "description": "The status of this resource.\n\nThis can be used by clients to determine whether the resource is available for use.", + "enum": [ + "available", + "deleted", + "error", + "pending" + ], + "type": "string" + }, "ResourceTemplate": { "description": "A template description for resources available on the server.", "properties": { diff --git a/schema/draft/schema.ts b/schema/draft/schema.ts index e6a621172..9271cf764 100644 --- a/schema/draft/schema.ts +++ b/schema/draft/schema.ts @@ -446,7 +446,7 @@ export interface ResourceUpdatedNotification extends Notification { */ export type ResourceStatus = | "pending" - | "ready" + | "available" | "error" | "deleted"