001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.bean.mcp.v20250618; 018 019import static org.apache.juneau.commons.utils.CollectionUtils.*; 020import static org.apache.juneau.commons.utils.Shorts.*; 021 022import java.util.*; 023 024import org.apache.juneau.marshall.*; 025 026/** 027 * Result payload for {@value McpMethods#TOOLS_CALL}. 028 */ 029@Marshalled 030public class CallToolResult { 031 032 private List<Content> content; 033 private Boolean isError; 034 private Object structuredContent; 035 036 /** 037 * Content blocks returned by the tool. 038 * 039 * @return The content list, or {@code null} if not set. 040 */ 041 public List<Content> getContent() { 042 return u(content); 043 } 044 045 /** 046 * Sets the content blocks. 047 * 048 * @param value The new value. Can be <jk>null</jk> to unset the property. 049 * @return This object (for method chaining). 050 */ 051 public CallToolResult setContent(List<Content> value) { 052 content = value; 053 return this; 054 } 055 056 /** 057 * Sets the content blocks. 058 * 059 * @param value The new value. Can be <jk>null</jk> to unset the property. 060 * @return This object (for method chaining). 061 */ 062 public CallToolResult setContent(Content...value) { 063 content = list(value); 064 return this; 065 } 066 067 /** 068 * Appends to the content blocks. 069 * 070 * @param value The values to append. 071 * @return This object (for method chaining). 072 */ 073 public CallToolResult addContent(Content...value) { 074 if (content == null) 075 content = list(); 076 Collections.addAll(content, value); 077 return this; 078 } 079 080 /** 081 * Appends to the content blocks. 082 * 083 * @param value The values to append. 084 * @return This object (for method chaining). 085 */ 086 public CallToolResult addContent(Collection<Content> value) { 087 if (content == null) 088 content = list(); 089 content.addAll(value); 090 return this; 091 } 092 093 /** 094 * When {@code true}, the tool reported an application-level error. 095 * 096 * @return The flag, or {@code null} if not set. 097 */ 098 public Boolean getIsError() { 099 return isError; 100 } 101 102 /** 103 * Sets the error flag. 104 * 105 * @param value The new value. Can be <jk>null</jk> to unset the property. 106 * @return This object (for method chaining). 107 */ 108 public CallToolResult setIsError(Boolean value) { 109 isError = value; 110 return this; 111 } 112 113 /** 114 * Structured result content, mirroring the {@link #getContent() content} in a machine-readable form. 115 * 116 * <p>MCP 2025-06-18 requires this, when present, to be a JSON object, but enforcement of that 117 * constraint belongs to the REST adapter, not this DTO. 118 * 119 * @return The structured content, or {@code null} if not set. 120 */ 121 public Object getStructuredContent() { 122 return structuredContent; 123 } 124 125 /** 126 * Sets the structured content. 127 * 128 * @param value The new value. Can be <jk>null</jk> to unset the property. 129 * @return This object (for method chaining). 130 */ 131 public CallToolResult setStructuredContent(Object value) { 132 structuredContent = value; 133 return this; 134 } 135}