From 8baf498014dd8ea3914825e1ada950e42f3ce85b Mon Sep 17 00:00:00 2001 From: evalstate <1936278+evalstate@users.noreply.github.com> Date: Thu, 13 Mar 2025 15:51:26 +0000 Subject: [PATCH 1/6] switched prompt/sampling messages to array content blocks --- schema/draft/schema.json | 81 ++++++++++++++++++++++------------------ schema/draft/schema.ts | 4 +- 2 files changed, 47 insertions(+), 38 deletions(-) diff --git a/schema/draft/schema.json b/schema/draft/schema.json index a48ec722a..9c074d52c 100644 --- a/schema/draft/schema.json +++ b/schema/draft/schema.json @@ -448,17 +448,20 @@ "type": "object" }, "content": { - "anyOf": [ - { - "$ref": "#/definitions/TextContent" - }, - { - "$ref": "#/definitions/ImageContent" - }, - { - "$ref": "#/definitions/AudioContent" - } - ] + "items": { + "anyOf": [ + { + "$ref": "#/definitions/TextContent" + }, + { + "$ref": "#/definitions/ImageContent" + }, + { + "$ref": "#/definitions/AudioContent" + } + ] + }, + "type": "array" }, "model": { "description": "The name of the model that generated the message.", @@ -1394,20 +1397,23 @@ "description": "Describes a message returned as part of a prompt.\n\nThis is similar to `SamplingMessage`, but also supports the embedding of\nresources from the MCP server.", "properties": { "content": { - "anyOf": [ - { - "$ref": "#/definitions/TextContent" - }, - { - "$ref": "#/definitions/ImageContent" - }, - { - "$ref": "#/definitions/AudioContent" - }, - { - "$ref": "#/definitions/EmbeddedResource" - } - ] + "items": { + "anyOf": [ + { + "$ref": "#/definitions/TextContent" + }, + { + "$ref": "#/definitions/ImageContent" + }, + { + "$ref": "#/definitions/AudioContent" + }, + { + "$ref": "#/definitions/EmbeddedResource" + } + ] + }, + "type": "array" }, "role": { "$ref": "#/definitions/Role" @@ -1767,17 +1773,20 @@ "description": "Describes a message issued to or received from an LLM API.", "properties": { "content": { - "anyOf": [ - { - "$ref": "#/definitions/TextContent" - }, - { - "$ref": "#/definitions/ImageContent" - }, - { - "$ref": "#/definitions/AudioContent" - } - ] + "items": { + "anyOf": [ + { + "$ref": "#/definitions/TextContent" + }, + { + "$ref": "#/definitions/ImageContent" + }, + { + "$ref": "#/definitions/AudioContent" + } + ] + }, + "type": "array" }, "role": { "$ref": "#/definitions/Role" diff --git a/schema/draft/schema.ts b/schema/draft/schema.ts index 035a0c395..9f64521ad 100644 --- a/schema/draft/schema.ts +++ b/schema/draft/schema.ts @@ -604,7 +604,7 @@ export type Role = "user" | "assistant"; */ export interface PromptMessage { role: Role; - content: TextContent | ImageContent | AudioContent | EmbeddedResource; + content: (TextContent | ImageContent | AudioContent | EmbeddedResource)[]; } /** @@ -809,7 +809,7 @@ export interface CreateMessageResult extends Result, SamplingMessage { */ export interface SamplingMessage { role: Role; - content: TextContent | ImageContent | AudioContent; + content: (TextContent | ImageContent | AudioContent)[]; } /** From 32fa4656694864ae8955ee5d9158b90221c6bc29 Mon Sep 17 00:00:00 2001 From: evalstate <1936278+evalstate@users.noreply.github.com> Date: Sun, 25 May 2025 13:11:25 -0700 Subject: [PATCH 2/6] move changes to draft schema --- schema/2025-03-26/schema.ts | 4 ++-- schema/draft/schema.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/schema/2025-03-26/schema.ts b/schema/2025-03-26/schema.ts index c5062825b..a4b3a9d95 100644 --- a/schema/2025-03-26/schema.ts +++ b/schema/2025-03-26/schema.ts @@ -642,7 +642,7 @@ export type Role = "user" | "assistant"; */ export interface PromptMessage { role: Role; - content: (TextContent | ImageContent | AudioContent | EmbeddedResource)[]; + content: TextContent | ImageContent | AudioContent | EmbeddedResource; } /** @@ -915,7 +915,7 @@ export interface CreateMessageResult extends Result, SamplingMessage { */ export interface SamplingMessage { role: Role; - content: (TextContent | ImageContent | AudioContent)[]; + content: TextContent | ImageContent | AudioContent; } /** diff --git a/schema/draft/schema.ts b/schema/draft/schema.ts index 2f359e0d6..cf06c0873 100644 --- a/schema/draft/schema.ts +++ b/schema/draft/schema.ts @@ -642,7 +642,7 @@ export type Role = "user" | "assistant"; */ export interface PromptMessage { role: Role; - content: TextContent | ImageContent | AudioContent | EmbeddedResource; + content: (TextContent | ImageContent | AudioContent | EmbeddedResource)[]; } /** @@ -701,7 +701,7 @@ export interface CallToolResult extends Result { * Whether the tool call ended in an error. * * If not set, this is assumed to be false (the call was successful). - * + * * Any errors that originate from the tool SHOULD be reported inside the result * object, with `isError` set to true, _not_ as an MCP protocol-level error * response. Otherwise, the LLM would not be able to see that an error occurred @@ -812,7 +812,7 @@ export interface Tool { }; /** - * An optional JSON Schema object defining the structure of the tool's output returned in + * An optional JSON Schema object defining the structure of the tool's output returned in * the structuredContent field of a CallToolResult. */ outputSchema?: { @@ -933,7 +933,7 @@ export interface CreateMessageResult extends Result, SamplingMessage { */ export interface SamplingMessage { role: Role; - content: TextContent | ImageContent | AudioContent; + content: (TextContent | ImageContent | AudioContent | EmbeddedResource)[]; } /** From c13b1d1ddbd6a42bc6e4f77af22e57409252081c Mon Sep 17 00:00:00 2001 From: evalstate <1936278+evalstate@users.noreply.github.com> Date: Sun, 25 May 2025 13:11:52 -0700 Subject: [PATCH 3/6] remove ER --- schema/draft/schema.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/draft/schema.ts b/schema/draft/schema.ts index cf06c0873..d9191e7db 100644 --- a/schema/draft/schema.ts +++ b/schema/draft/schema.ts @@ -933,7 +933,7 @@ export interface CreateMessageResult extends Result, SamplingMessage { */ export interface SamplingMessage { role: Role; - content: (TextContent | ImageContent | AudioContent | EmbeddedResource)[]; + content: (TextContent | ImageContent | AudioContent)[]; } /** From 9661bf69c1ae95a9d93772694f1fa90da0db430e Mon Sep 17 00:00:00 2001 From: evalstate <1936278+evalstate@users.noreply.github.com> Date: Sun, 25 May 2025 13:12:41 -0700 Subject: [PATCH 4/6] Generate JSON Schema --- schema/2025-03-26/schema.json | 81 +++++++++++++++------------------- schema/draft/schema.json | 83 +++++++++++++++++++---------------- 2 files changed, 82 insertions(+), 82 deletions(-) diff --git a/schema/2025-03-26/schema.json b/schema/2025-03-26/schema.json index 93f95bc0e..a1e3f2679 100644 --- a/schema/2025-03-26/schema.json +++ b/schema/2025-03-26/schema.json @@ -432,20 +432,17 @@ "type": "object" }, "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/TextContent" - }, - { - "$ref": "#/definitions/ImageContent" - }, - { - "$ref": "#/definitions/AudioContent" - } - ] - }, - "type": "array" + "anyOf": [ + { + "$ref": "#/definitions/TextContent" + }, + { + "$ref": "#/definitions/ImageContent" + }, + { + "$ref": "#/definitions/AudioContent" + } + ] }, "model": { "description": "The name of the model that generated the message.", @@ -1410,23 +1407,20 @@ "description": "Describes a message returned as part of a prompt.\n\nThis is similar to `SamplingMessage`, but also supports the embedding of\nresources from the MCP server.", "properties": { "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/TextContent" - }, - { - "$ref": "#/definitions/ImageContent" - }, - { - "$ref": "#/definitions/AudioContent" - }, - { - "$ref": "#/definitions/EmbeddedResource" - } - ] - }, - "type": "array" + "anyOf": [ + { + "$ref": "#/definitions/TextContent" + }, + { + "$ref": "#/definitions/ImageContent" + }, + { + "$ref": "#/definitions/AudioContent" + }, + { + "$ref": "#/definitions/EmbeddedResource" + } + ] }, "role": { "$ref": "#/definitions/Role" @@ -1762,20 +1756,17 @@ "description": "Describes a message issued to or received from an LLM API.", "properties": { "content": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/TextContent" - }, - { - "$ref": "#/definitions/ImageContent" - }, - { - "$ref": "#/definitions/AudioContent" - } - ] - }, - "type": "array" + "anyOf": [ + { + "$ref": "#/definitions/TextContent" + }, + { + "$ref": "#/definitions/ImageContent" + }, + { + "$ref": "#/definitions/AudioContent" + } + ] }, "role": { "$ref": "#/definitions/Role" diff --git a/schema/draft/schema.json b/schema/draft/schema.json index 62bfb110d..59f5ccd0e 100644 --- a/schema/draft/schema.json +++ b/schema/draft/schema.json @@ -438,17 +438,20 @@ "type": "object" }, "content": { - "anyOf": [ - { - "$ref": "#/definitions/TextContent" - }, - { - "$ref": "#/definitions/ImageContent" - }, - { - "$ref": "#/definitions/AudioContent" - } - ] + "items": { + "anyOf": [ + { + "$ref": "#/definitions/TextContent" + }, + { + "$ref": "#/definitions/ImageContent" + }, + { + "$ref": "#/definitions/AudioContent" + } + ] + }, + "type": "array" }, "model": { "description": "The name of the model that generated the message.", @@ -1413,20 +1416,23 @@ "description": "Describes a message returned as part of a prompt.\n\nThis is similar to `SamplingMessage`, but also supports the embedding of\nresources from the MCP server.", "properties": { "content": { - "anyOf": [ - { - "$ref": "#/definitions/TextContent" - }, - { - "$ref": "#/definitions/ImageContent" - }, - { - "$ref": "#/definitions/AudioContent" - }, - { - "$ref": "#/definitions/EmbeddedResource" - } - ] + "items": { + "anyOf": [ + { + "$ref": "#/definitions/TextContent" + }, + { + "$ref": "#/definitions/ImageContent" + }, + { + "$ref": "#/definitions/AudioContent" + }, + { + "$ref": "#/definitions/EmbeddedResource" + } + ] + }, + "type": "array" }, "role": { "$ref": "#/definitions/Role" @@ -1762,17 +1768,20 @@ "description": "Describes a message issued to or received from an LLM API.", "properties": { "content": { - "anyOf": [ - { - "$ref": "#/definitions/TextContent" - }, - { - "$ref": "#/definitions/ImageContent" - }, - { - "$ref": "#/definitions/AudioContent" - } - ] + "items": { + "anyOf": [ + { + "$ref": "#/definitions/TextContent" + }, + { + "$ref": "#/definitions/ImageContent" + }, + { + "$ref": "#/definitions/AudioContent" + } + ] + }, + "type": "array" }, "role": { "$ref": "#/definitions/Role" @@ -2057,7 +2066,7 @@ "type": "string" }, "outputSchema": { - "description": "An optional JSON Schema object defining the structure of the tool's output returned in \nthe structuredContent field of a CallToolResult.", + "description": "An optional JSON Schema object defining the structure of the tool's output returned in\nthe structuredContent field of a CallToolResult.", "properties": { "properties": { "additionalProperties": { From 36634e5bd7fa4a37fd8e112c59d8b867013a7567 Mon Sep 17 00:00:00 2001 From: evalstate <1936278+evalstate@users.noreply.github.com> Date: Sun, 25 May 2025 13:17:32 -0700 Subject: [PATCH 5/6] Update changelog --- docs/specification/draft/changelog.mdx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/specification/draft/changelog.mdx b/docs/specification/draft/changelog.mdx index da22e5c71..768382151 100644 --- a/docs/specification/draft/changelog.mdx +++ b/docs/specification/draft/changelog.mdx @@ -8,13 +8,14 @@ the previous revision, [2025-03-26](/specification/2025-03-26). ## Major changes 1. Removed support for JSON-RPC **[batching](https://www.jsonrpc.org/specification#batch)** - (PR [#416](https://github.com/modelcontextprotocol/specification/pull/416)) + (PR [#416](https://github.com/modelcontextprotocol/specification/pull/416)) 2. Added support for [structured tool output](https://modelcontextprotocol.io/specification/draft/server/tools#structured-content) (PR [#371](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/371)) 3. TODO ## Other schema changes +- PromptMessage and SamplingMessage now contain Arrays of content. - TODO ## Full changelog From 0e7dbe1a58702dc19d6c99b96e57e0a54d17ed98 Mon Sep 17 00:00:00 2001 From: evalstate <1936278+evalstate@users.noreply.github.com> Date: Sun, 25 May 2025 13:22:10 -0700 Subject: [PATCH 6/6] update draft docs to reflect changes in schema --- docs/specification/draft/client/sampling.mdx | 12 +++++++----- docs/specification/draft/server/prompts.mdx | 10 ++++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/docs/specification/draft/client/sampling.mdx b/docs/specification/draft/client/sampling.mdx index 9db8d4ab9..76b855247 100644 --- a/docs/specification/draft/client/sampling.mdx +++ b/docs/specification/draft/client/sampling.mdx @@ -29,7 +29,7 @@ Applications **SHOULD**: - Provide UI that makes it easy and intuitive to review sampling requests - Allow users to view and edit prompts before sending - Present generated responses for review before delivery - + ## Capabilities @@ -90,10 +90,12 @@ To request a language model generation, servers send a `sampling/createMessage` "id": 1, "result": { "role": "assistant", - "content": { - "type": "text", - "text": "The capital of France is Paris." - }, + "content": [ + { + "type": "text", + "text": "The capital of France is Paris." + } + ], "model": "claude-3-sonnet-20240307", "stopReason": "endTurn" } diff --git a/docs/specification/draft/server/prompts.mdx b/docs/specification/draft/server/prompts.mdx index 46b527e59..abb7cefa8 100644 --- a/docs/specification/draft/server/prompts.mdx +++ b/docs/specification/draft/server/prompts.mdx @@ -120,10 +120,12 @@ auto-completed through [the completion API](/specification/draft/server/utilitie "messages": [ { "role": "user", - "content": { - "type": "text", - "text": "Please review this Python code:\ndef hello():\n print('world')" - } + "content": [ + { + "type": "text", + "text": "Please review this Python code:\ndef hello():\n print('world')" + } + ] } ] }