diff --git a/docs/legacy/concepts/sampling.mdx b/docs/legacy/concepts/sampling.mdx index 01f1d40f3..3ea8c053f 100644 --- a/docs/legacy/concepts/sampling.mdx +++ b/docs/legacy/concepts/sampling.mdx @@ -33,14 +33,22 @@ Sampling requests use a standardized message format: { role: "user" | "assistant", content: { - type: "text" | "image", + type: "text" | "image" | "audio" | "resource" | "resource_link", // For text: text?: string, - // For images: + // For images/audio: data?: string, // base64 encoded - mimeType?: string + mimeType?: string, + + // For resources: + resource?: { + uri: string, + mimeType: string, + text?: string, // for text resources + blob?: string // for blob resources, base64 encoded + } } } ], @@ -70,7 +78,9 @@ The `messages` array contains the conversation history to send to the LLM. Each - `role`: Either "user" or "assistant" - `content`: The message content, which can be: - Text content with a `text` field - - Image content with `data` (base64) and `mimeType` fields + - Image/audio content with `data` (base64) and `mimeType` fields + - An embedded [resource](/docs/concepts/resources) + - A [resource](/docs/concepts/resources) link ### Model preferences diff --git a/docs/specification/draft/client/sampling.mdx b/docs/specification/draft/client/sampling.mdx index 6410d54e3..859422bc1 100644 --- a/docs/specification/draft/client/sampling.mdx +++ b/docs/specification/draft/client/sampling.mdx @@ -167,6 +167,42 @@ Sampling messages can contain: } ``` +#### Resource Links + +A tool **MAY** return links to [Resources](/specification/draft/server/resources), to provide additional context +or data. In this case, the tool will return a URI that can be subscribed to or fetched by the client: + +```json +{ + "type": "resource_link", + "uri": "file:///project/src/main.rs", + "name": "main.rs", + "description": "Primary application entry point", + "mimeType": "text/x-rust" +} +``` + + + Resource links returned by tools are not guaranteed to appear in the results + of a `resources/list` request. + + +#### Embedded Resources + +[Resources](/specification/draft/server/resources) **MAY** be embedded to provide additional context +or data using a suitable [URI scheme](../server/resources#common-uri-schemes). Servers that use embedded resources **SHOULD** implement the `resources` capability: + +```json +{ + "type": "resource", + "resource": { + "uri": "file:///project/src/main.rs", + "mimeType": "text/x-rust", + "text": "fn main() {\n println!(\"Hello world!\");\n}" + } +} +``` + ### Model Preferences Model selection in MCP requires careful abstraction since servers and clients may use diff --git a/docs/specification/draft/schema.mdx b/docs/specification/draft/schema.mdx index e81c0ec0c..6e8d59e76 100644 --- a/docs/specification/draft/schema.mdx +++ b/docs/specification/draft/schema.mdx @@ -194,7 +194,7 @@ other URI schemes.

interface SamplingMessage {
  content: TextContent | ImageContent | AudioContent;
  role: Role;
}

Describes a message issued to or received from an LLM API.

+
interface SamplingMessage {
  content: ContentBlock;
  role: Role;
}

Describes a message issued to or received from an LLM API.

### `ServerCapabilities` @@ -424,7 +424,7 @@ or file that the server can operate on.

interface CreateMessageResult {
  _meta?: { [key: string]: unknown };
  content: TextContent | ImageContent | AudioContent;
  model: string;
  role: Role;
  stopReason?: string;
  [key: string]: unknown;
}

The client's response to a sampling/create_message request from the server. The client should inform the user before returning the sampled message, to allow them to inspect the response (human in the loop) and decide whether to allow the server to see it.

_meta?: { [key: string]: unknown }

See General fields: _meta for notes on _meta usage.

model: string

The name of the model that generated the message.

stopReason?: string

The reason why sampling stopped, if known.

+
interface CreateMessageResult {
  _meta?: { [key: string]: unknown };
  content: ContentBlock;
  model: string;
  role: Role;
  stopReason?: string;
  [key: string]: unknown;
}

The client's response to a sampling/create_message request from the server. The client should inform the user before returning the sampled message, to allow them to inspect the response (human in the loop) and decide whether to allow the server to see it.

_meta?: { [key: string]: unknown }

See General fields: _meta for notes on _meta usage.

model: string

The name of the model that generated the message.

stopReason?: string

The reason why sampling stopped, if known.

## `tools/call` diff --git a/schema/draft/schema.json b/schema/draft/schema.json index 52b0b2f02..0774d52fe 100644 --- a/schema/draft/schema.json +++ b/schema/draft/schema.json @@ -518,17 +518,7 @@ "type": "object" }, "content": { - "anyOf": [ - { - "$ref": "#/definitions/TextContent" - }, - { - "$ref": "#/definitions/ImageContent" - }, - { - "$ref": "#/definitions/AudioContent" - } - ] + "$ref": "#/definitions/ContentBlock" }, "model": { "description": "The name of the model that generated the message.", @@ -2052,17 +2042,7 @@ "description": "Describes a message issued to or received from an LLM API.", "properties": { "content": { - "anyOf": [ - { - "$ref": "#/definitions/TextContent" - }, - { - "$ref": "#/definitions/ImageContent" - }, - { - "$ref": "#/definitions/AudioContent" - } - ] + "$ref": "#/definitions/ContentBlock" }, "role": { "$ref": "#/definitions/Role" diff --git a/schema/draft/schema.ts b/schema/draft/schema.ts index 379e75f83..154825e46 100644 --- a/schema/draft/schema.ts +++ b/schema/draft/schema.ts @@ -1036,7 +1036,7 @@ export interface CreateMessageResult extends Result, SamplingMessage { */ export interface SamplingMessage { role: Role; - content: TextContent | ImageContent | AudioContent; + content: ContentBlock; } /**