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 * MCP server capability advertisement returned by {@link ServerDiscoverResult}. 028 */ 029@Marshalled 030public class ServerCapabilities { 031 032 private ToolCapability tools; 033 private PromptCapability prompts; 034 private ResourceCapability resources; 035 private LoggingCapability logging; 036 private CompletionCapability completions; 037 private Map<String,Object> experimental; 038 private Map<String,Object> extensions; 039 040 /** 041 * Tools capability. 042 * 043 * @return The capability, or {@code null} if not set. 044 */ 045 public ToolCapability getTools() { 046 return tools; 047 } 048 049 /** 050 * Sets tools capability. 051 * 052 * @param value The new value. Can be <jk>null</jk> to unset the property. 053 * @return This object (for method chaining). 054 */ 055 public ServerCapabilities setTools(ToolCapability value) { 056 tools = value; 057 return this; 058 } 059 060 /** 061 * Prompts capability. 062 * 063 * @return The capability, or {@code null} if not set. 064 */ 065 public PromptCapability getPrompts() { 066 return prompts; 067 } 068 069 /** 070 * Sets prompts capability. 071 * 072 * @param value The new value. Can be <jk>null</jk> to unset the property. 073 * @return This object (for method chaining). 074 */ 075 public ServerCapabilities setPrompts(PromptCapability value) { 076 prompts = value; 077 return this; 078 } 079 080 /** 081 * Resources capability. 082 * 083 * @return The capability, or {@code null} if not set. 084 */ 085 public ResourceCapability getResources() { 086 return resources; 087 } 088 089 /** 090 * Sets resources capability. 091 * 092 * @param value The new value. Can be <jk>null</jk> to unset the property. 093 * @return This object (for method chaining). 094 */ 095 public ServerCapabilities setResources(ResourceCapability value) { 096 resources = value; 097 return this; 098 } 099 100 /** 101 * Logging capability. 102 * 103 * @return The capability, or {@code null} if not set. 104 */ 105 public LoggingCapability getLogging() { 106 return logging; 107 } 108 109 /** 110 * Sets logging capability. 111 * 112 * @param value The new value. Can be <jk>null</jk> to unset the property. 113 * @return This object (for method chaining). 114 */ 115 public ServerCapabilities setLogging(LoggingCapability value) { 116 logging = value; 117 return this; 118 } 119 120 /** 121 * Completions capability. 122 * 123 * @return The capability, or {@code null} if not set. 124 */ 125 public CompletionCapability getCompletions() { 126 return completions; 127 } 128 129 /** 130 * Sets completions capability. 131 * 132 * @param value The new value. Can be <jk>null</jk> to unset the property. 133 * @return This object (for method chaining). 134 */ 135 public ServerCapabilities setCompletions(CompletionCapability value) { 136 completions = value; 137 return this; 138 } 139 140 /** 141 * Experimental capability extensions. 142 * 143 * @return The experimental map, or {@code null} if not set. 144 */ 145 public Map<String,Object> getExperimental() { 146 return u(experimental); 147 } 148 149 /** 150 * Sets experimental extensions. 151 * 152 * @param value The new value. Can be <jk>null</jk> to unset the property. 153 * @return This object (for method chaining). 154 */ 155 public ServerCapabilities setExperimental(Map<String,Object> value) { 156 experimental = value; 157 return this; 158 } 159 160 /** 161 * Convenience method to add a single experimental extension entry. 162 * 163 * @param name The extension name. Can be <jk>null</jk> ({@link LinkedHashMap} tolerates a <jk>null</jk> key). 164 * @param value The extension value. Can be <jk>null</jk> (stored as <jk>null</jk>). 165 * @return This object (for method chaining). 166 */ 167 public ServerCapabilities putExperimental(String name, Object value) { 168 if (experimental == null) 169 experimental = map(); 170 experimental.put(name, value); 171 return this; 172 } 173 174 /** 175 * Schema-defined capability extensions (distinct from the free-form {@code experimental} bag). 176 * 177 * @return The extensions map, or {@code null} if not set. 178 */ 179 public Map<String,Object> getExtensions() { 180 return u(extensions); 181 } 182 183 /** 184 * Sets capability extensions. 185 * 186 * @param value The new value. Can be <jk>null</jk> to unset the property. 187 * @return This object (for method chaining). 188 */ 189 public ServerCapabilities setExtensions(Map<String,Object> value) { 190 extensions = value; 191 return this; 192 } 193 194 /** 195 * Convenience method to add a single capability extension entry. 196 * 197 * <p> 198 * The extension map is lazily initialized on first use and preserves insertion order across repeated calls. 199 * 200 * @param name The extension name. Can be <jk>null</jk> ({@link LinkedHashMap} tolerates a <jk>null</jk> key). 201 * @param value The extension value. Can be <jk>null</jk> (stored as <jk>null</jk>). 202 * @return This object (for method chaining). 203 */ 204 public ServerCapabilities putExtensions(String name, Object value) { 205 if (extensions == null) 206 extensions = map(); 207 extensions.put(name, value); 208 return this; 209 } 210}