@@ -685,31 +685,66 @@ export interface ListToolsResult extends PaginatedResult {
685685
686686/**
687687 * The server's response to a tool call.
688+ *
689+ * Any errors that originate from the tool SHOULD be reported inside the result
690+ * object, with `isError` set to true, _not_ as an MCP protocol-level error
691+ * response. Otherwise, the LLM would not be able to see that an error occurred
692+ * and self-correct.
693+ *
694+ * However, any errors in _finding_ the tool, an error indicating that the
695+ * server does not support tool calls, or any other exceptional conditions,
696+ * should be reported as an MCP error response.
697+ */
698+ export type CallToolResult =
699+ | CallToolUnstructuredResult
700+ | CallToolStructuredResult ;
701+
702+ /**
703+ * Tool result for tools that do not declare an outputSchema.
688704 */
689- export interface CallToolResult extends Result {
705+ export interface CallToolUnstructuredResult extends Result {
690706 /**
691- * A list of content objects that represent the unstructured result of the tool call.
707+ * A list of content objects that represent the result of the tool call.
708+ *
709+ * If the Tool does not define an outputSchema, this field MUST be present in the result.
692710 */
693711 content : ContentBlock [ ] ;
694712
695713 /**
696- * An optional JSON object that represents the structured result of the tool call .
714+ * Structured output must not be provided in an unstructured tool result .
697715 */
698- structuredContent ?: { [ key : string ] : unknown } ;
716+ structuredContent : never ;
699717
700718 /**
701719 * Whether the tool call ended in an error.
702720 *
703721 * If not set, this is assumed to be false (the call was successful).
722+ */
723+ isError ?: boolean ;
724+ }
725+
726+ /**
727+ * Tool result for tools that do declare an outputSchema.
728+ */
729+ export interface CallToolStructuredResult extends Result {
730+ /**
731+ * An object containing structured tool output.
704732 *
705- * Any errors that originate from the tool SHOULD be reported inside the result
706- * object, with `isError` set to true, _not_ as an MCP protocol-level error
707- * response. Otherwise, the LLM would not be able to see that an error occurred
708- * and self-correct.
733+ * If the Tool defines an outputSchema, this field MUST be present in the result, and contain a JSON object that matches the schema.
734+ */
735+ structuredContent : { [ key : string ] : unknown } ;
736+
737+ /**
738+ * If the Tool defines an outputSchema, this field MAY be present in the result.
739+ * Tools should use this field to provide compatibility with older clients that do not support structured content.
740+ * Clients that support structured content should ignore this field.
741+ */
742+ content ?: ContentBlock [ ] ;
743+
744+ /**
745+ * Whether the tool call ended in an error.
709746 *
710- * However, any errors in _finding_ the tool, an error indicating that the
711- * server does not support tool calls, or any other exceptional conditions,
712- * should be reported as an MCP error response.
747+ * If not set, this is assumed to be false (the call was successful).
713748 */
714749 isError ?: boolean ;
715750}
@@ -933,7 +968,7 @@ export interface CreateMessageResult extends Result, SamplingMessage {
933968 */
934969export interface SamplingMessage {
935970 role : Role ;
936- content : TextContent | ImageContent | AudioContent ;
971+ content : ContentBlock ;
937972}
938973
939974/**
0 commit comments