@@ -266,7 +266,17 @@ export interface ClientCapabilities {
266266 /**
267267 * Present if the client supports sampling from an LLM.
268268 */
269- sampling ?: object ;
269+ sampling ?: {
270+ /**
271+ * Whether the client supports context inclusion via includeContext parameter.
272+ * If not declared, servers SHOULD only use `includeContext: "none"` (or omit it).
273+ */
274+ context ?: object ;
275+ /**
276+ * Whether the client supports tool use via tools and toolChoice parameters.
277+ */
278+ tools ?: object ;
279+ } ;
270280 /**
271281 * Present if the client supports elicitation from the server.
272282 */
@@ -1176,7 +1186,11 @@ export interface CreateMessageRequestParams extends RequestParams {
11761186 */
11771187 systemPrompt ?: string ;
11781188 /**
1179- * A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.
1189+ * A request to include context from one or more MCP servers (including the caller), to be attached to the prompt.
1190+ * The client MAY ignore this request.
1191+ *
1192+ * Default is "none". Values "thisServer" and "allServers" are soft-deprecated. Servers SHOULD only use these values if the client
1193+ * declares ClientCapabilities.sampling.context. These values may be removed in future spec releases.
11801194 */
11811195 includeContext ?: "none" | "thisServer" | "allServers" ;
11821196 /**
@@ -1194,6 +1208,32 @@ export interface CreateMessageRequestParams extends RequestParams {
11941208 * Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.
11951209 */
11961210 metadata ?: object ;
1211+ /**
1212+ * Tools that the model may use during generation.
1213+ * The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
1214+ */
1215+ tools ?: Tool [ ] ;
1216+ /**
1217+ * Controls how the model uses tools.
1218+ * The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
1219+ * Default is `{ mode: "auto" }`.
1220+ */
1221+ toolChoice ?: ToolChoice ;
1222+ }
1223+
1224+ /**
1225+ * Controls tool selection behavior for sampling requests.
1226+ *
1227+ * @category `sampling/createMessage`
1228+ */
1229+ export interface ToolChoice {
1230+ /**
1231+ * Controls the tool use ability of the model:
1232+ * - "auto": Model decides whether to use tools (default)
1233+ * - "required": Model MUST use at least one tool before completing
1234+ * - "none": Model MUST NOT use any tools
1235+ */
1236+ mode ?: "auto" | "required" | "none" ;
11971237}
11981238
11991239/**
@@ -1216,19 +1256,38 @@ export interface CreateMessageResult extends Result, SamplingMessage {
12161256 * The name of the model that generated the message.
12171257 */
12181258 model : string ;
1259+
12191260 /**
12201261 * The reason why sampling stopped, if known.
1262+ *
1263+ * Standard values:
1264+ * - "endTurn": Natural end of the assistant's turn
1265+ * - "stopSequence": A stop sequence was encountered
1266+ * - "maxTokens": Maximum token limit was reached
1267+ * - "toolUse": The model wants to use one or more tools
1268+ *
1269+ * This field is an open string to allow for provider-specific stop reasons.
12211270 */
1222- stopReason ?: "endTurn" | "stopSequence" | "maxTokens" | string ;
1271+ stopReason ?: "endTurn" | "stopSequence" | "maxTokens" | "toolUse" | string ;
12231272}
12241273
12251274/**
12261275 * Describes a message issued to or received from an LLM API.
12271276 */
12281277export interface SamplingMessage {
12291278 role : Role ;
1230- content : TextContent | ImageContent | AudioContent ;
1279+ content : SamplingMessageContentBlock | SamplingMessageContentBlock [ ] ;
1280+ /**
1281+ * See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
1282+ */
1283+ _meta ?: { [ key : string ] : unknown } ;
12311284}
1285+ export type SamplingMessageContentBlock =
1286+ | TextContent
1287+ | ImageContent
1288+ | AudioContent
1289+ | ToolUseContent
1290+ | ToolResultContent ;
12321291
12331292/**
12341293 * Optional annotations for the client. The client can use annotations to inform how objects are used or displayed
@@ -1352,6 +1411,87 @@ export interface AudioContent {
13521411 _meta ?: { [ key : string ] : unknown } ;
13531412}
13541413
1414+ /**
1415+ * A request from the assistant to call a tool.
1416+ *
1417+ * @category `sampling/createMessage`
1418+ */
1419+ export interface ToolUseContent {
1420+ type : "tool_use" ;
1421+
1422+ /**
1423+ * A unique identifier for this tool use.
1424+ *
1425+ * This ID is used to match tool results to their corresponding tool uses.
1426+ */
1427+ id : string ;
1428+
1429+ /**
1430+ * The name of the tool to call.
1431+ */
1432+ name : string ;
1433+
1434+ /**
1435+ * The arguments to pass to the tool, conforming to the tool's input schema.
1436+ */
1437+ input : object ;
1438+
1439+ /**
1440+ * Optional metadata about the tool use. Clients SHOULD preserve this field when
1441+ * including tool uses in subsequent sampling requests to enable caching optimizations.
1442+ *
1443+ * See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
1444+ */
1445+ _meta ?: { [ key : string ] : unknown } ;
1446+ }
1447+
1448+ /**
1449+ * The result of a tool use, provided by the user back to the assistant.
1450+ *
1451+ * @category `sampling/createMessage`
1452+ */
1453+ export interface ToolResultContent {
1454+ type : "tool_result" ;
1455+
1456+ /**
1457+ * The ID of the tool use this result corresponds to.
1458+ *
1459+ * This MUST match the ID from a previous ToolUseContent.
1460+ */
1461+ toolUseId : string ;
1462+
1463+ /**
1464+ * The unstructured result content of the tool use.
1465+ *
1466+ * This has the same format as CallToolResult.content and can include text, images,
1467+ * audio, resource links, and embedded resources.
1468+ */
1469+ content : ContentBlock [ ] ;
1470+
1471+ /**
1472+ * An optional structured result object.
1473+ *
1474+ * If the tool defined an outputSchema, this SHOULD conform to that schema.
1475+ */
1476+ structuredContent ?: object ;
1477+
1478+ /**
1479+ * Whether the tool use resulted in an error.
1480+ *
1481+ * If true, the content typically describes the error that occurred.
1482+ * Default: false
1483+ */
1484+ isError ?: boolean ;
1485+
1486+ /**
1487+ * Optional metadata about the tool result. Clients SHOULD preserve this field when
1488+ * including tool results in subsequent sampling requests to enable caching optimizations.
1489+ *
1490+ * See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
1491+ */
1492+ _meta ?: { [ key : string ] : unknown } ;
1493+ }
1494+
13551495/**
13561496 * The server's preferences for model selection, requested of the client during sampling.
13571497 *
0 commit comments