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.v20260728;
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 * Parameters for {@value McpMethods#TOOLS_CALL}.
028 */
029@Marshalled
030public class CallToolRequest extends RequestParams<CallToolRequest> {
031
032   private String name;
033   private Map<String,Object> arguments;
034   private Map<String,Object> inputResponses;
035   private String requestState;
036
037   /**
038    * Tool name to invoke.
039    *
040    * @return The name, or {@code null} if not set.
041    */
042   public String getName() {
043      return name;
044   }
045
046   /**
047    * Sets the tool name.
048    *
049    * @param value The new value.  Can be <jk>null</jk> to unset the property.
050    * @return This object (for method chaining).
051    */
052   public CallToolRequest setName(String value) {
053      name = value;
054      return this;
055   }
056
057   /**
058    * Tool arguments (free-form object map).
059    *
060    * @return The arguments map, or {@code null} if not set.
061    */
062   public Map<String,Object> getArguments() {
063      return u(arguments);
064   }
065
066   /**
067    * Sets tool arguments.
068    *
069    * @param value The new value.  Can be <jk>null</jk> to unset the property.
070    * @return This object (for method chaining).
071    */
072   public CallToolRequest setArguments(Map<String,Object> value) {
073      arguments = value;
074      return this;
075   }
076
077   /**
078    * Convenience method to add a single tool argument.
079    *
080    * @param name The argument name.  Can be <jk>null</jk> ({@link LinkedHashMap} tolerates a <jk>null</jk> key).
081    * @param value The argument value.  Can be <jk>null</jk> (stored as <jk>null</jk>).
082    * @return This object (for method chaining).
083    */
084   public CallToolRequest putArgument(String name, Object value) {
085      if (arguments == null)
086         arguments = map();
087      arguments.put(name, value);
088      return this;
089   }
090
091   /**
092    * Server-assigned-id-keyed map of collected answers to a prior {@code input_required} pause, echoed back on a
093    * resume call.
094    *
095    * @return The map, or {@code null} if not set.
096    */
097   public Map<String,Object> getInputResponses() {
098      return u(inputResponses);
099   }
100
101   /**
102    * Sets the collected-answers map.
103    *
104    * @param value The new value.  Can be <jk>null</jk> to unset the property.
105    * @return This object (for method chaining).
106    */
107   public CallToolRequest setInputResponses(Map<String,Object> value) {
108      inputResponses = value;
109      return this;
110   }
111
112   /**
113    * Convenience method to add a single collected answer.
114    *
115    * @param id The server-assigned id.  Can be <jk>null</jk> ({@link LinkedHashMap} tolerates a <jk>null</jk> key).
116    * @param value The answer value.  Can be <jk>null</jk> (stored as <jk>null</jk>).
117    * @return This object (for method chaining).
118    */
119   public CallToolRequest putInputResponse(String id, Object value) {
120      if (inputResponses == null)
121         inputResponses = map();
122      inputResponses.put(id, value);
123      return this;
124   }
125
126   /**
127    * The opaque continuation token echoed back from a prior {@code input_required} result.
128    *
129    * @return The token, or {@code null} if not set.
130    */
131   public String getRequestState() {
132      return requestState;
133   }
134
135   /**
136    * Sets the echoed continuation token.
137    *
138    * @param value The new value.  Can be <jk>null</jk> to unset the property.
139    * @return This object (for method chaining).
140    */
141   public CallToolRequest setRequestState(String value) {
142      requestState = value;
143      return this;
144   }
145}