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 * MCP client capability advertisement in {@link InitializeRequest}. 028 */ 029@Marshalled 030public class ClientCapabilities { 031 032 private RootsCapability roots; 033 private Map<String,Object> sampling; 034 private Map<String,Object> experimental; 035 036 /** 037 * Roots capability. 038 * 039 * @return The capability, or {@code null} if not set. 040 */ 041 public RootsCapability getRoots() { 042 return roots; 043 } 044 045 /** 046 * Sets roots capability. 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 ClientCapabilities setRoots(RootsCapability value) { 052 roots = value; 053 return this; 054 } 055 056 /** 057 * Sampling capability (free-form map for forward compatibility). 058 * 059 * @return The sampling map, or {@code null} if not set. 060 */ 061 public Map<String,Object> getSampling() { 062 return u(sampling); 063 } 064 065 /** 066 * Sets sampling capability. 067 * 068 * @param value The new value. Can be <jk>null</jk> to unset the property. 069 * @return This object (for method chaining). 070 */ 071 public ClientCapabilities setSampling(Map<String,Object> value) { 072 sampling = value; 073 return this; 074 } 075 076 /** 077 * Convenience method to add a single sampling capability entry. 078 * 079 * @param name The entry name. Can be <jk>null</jk> ({@link LinkedHashMap} tolerates a <jk>null</jk> key). 080 * @param value The entry value. Can be <jk>null</jk> (stored as <jk>null</jk>). 081 * @return This object (for method chaining). 082 */ 083 public ClientCapabilities putSampling(String name, Object value) { 084 if (sampling == null) 085 sampling = map(); 086 sampling.put(name, value); 087 return this; 088 } 089 090 /** 091 * Experimental capability extensions. 092 * 093 * @return The experimental map, or {@code null} if not set. 094 */ 095 public Map<String,Object> getExperimental() { 096 return u(experimental); 097 } 098 099 /** 100 * Sets experimental extensions. 101 * 102 * @param value The new value. Can be <jk>null</jk> to unset the property. 103 * @return This object (for method chaining). 104 */ 105 public ClientCapabilities setExperimental(Map<String,Object> value) { 106 experimental = value; 107 return this; 108 } 109 110 /** 111 * Convenience method to add a single experimental extension entry. 112 * 113 * @param name The extension name. Can be <jk>null</jk> ({@link LinkedHashMap} tolerates a <jk>null</jk> key). 114 * @param value The extension value. Can be <jk>null</jk> (stored as <jk>null</jk>). 115 * @return This object (for method chaining). 116 */ 117 public ClientCapabilities putExperimental(String name, Object value) { 118 if (experimental == null) 119 experimental = map(); 120 experimental.put(name, value); 121 return this; 122 } 123}