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.rest.server.mcp; 018 019import org.apache.juneau.marshall.collections.*; 020 021/** 022 * Revision-neutral carrier for a tool's input schema. 023 * 024 * <p> 025 * Deliberately a carrier, not a structured bean: the core has no opinion about which JSON Schema 026 * dialect or keyword set a revision supports. Each revision's adapter is responsible for validating 027 * that the carried map is expressible in its own wire schema type, and for rejecting configurations 028 * that are not. 029 * 030 * <p> 031 * The supplied map is <em>not</em> copied; callers must not mutate a map after handing it over. 032 */ 033public final class McpSchema { 034 035 private final JsonMap raw; 036 037 private McpSchema(JsonMap raw) { 038 this.raw = raw; 039 } 040 041 /** 042 * Creates a schema carrier around a raw JSON Schema object. 043 * 044 * @param raw The schema as a JSON object. Can be <jk>null</jk>, which yields an empty schema. 045 * @return A new carrier. Never <jk>null</jk>. 046 */ 047 public static McpSchema of(JsonMap raw) { 048 return new McpSchema(raw == null ? new JsonMap() : raw); 049 } 050 051 /** 052 * The carried schema. 053 * 054 * @return The schema map. Never <jk>null</jk>; not a copy. 055 */ 056 public JsonMap toJsonMap() { 057 return raw; 058 } 059}