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.v20250618; 018 019import org.apache.juneau.bean.mcp.v20250618.*; 020 021/** 022 * Mixin interface that exposes a {@code 2025-06-18} MCP endpoint at {@code POST /mcp} on any Juneau 023 * REST resource. 024 * 025 * <p> 026 * The mixin path and the servlet-subclass path 027 * ({@link McpRestServlet}) are at parity: both bind the revision at compile time and both 028 * expose the same {@link #capabilities()} hook. 029 * 030 * <h5 class='section'>Example:</h5> 031 * <pre> 032 * @Rest(path="/api") 033 * public class MyResource extends BasicRestServlet implements McpEndpoint { 034 * @Override 035 * public McpServerConfig getMcpConfig() { 036 * return new McpServerConfig().addTool(new MyEchoTool()); 037 * } 038 * } 039 * </pre> 040 */ 041public interface McpEndpoint extends org.apache.juneau.rest.server.mcp.McpEndpointMixin { 042 043 @Override /* McpEndpointMixin */ 044 default McpRevision revision() { 045 return new McpRevision(capabilities()); 046 } 047 048 /** 049 * Optional explicit capabilities advertisement for {@code initialize}. 050 * 051 * <p> 052 * Returning <jk>null</jk> (the default) leaves capabilities auto-derived from the registered 053 * tool / prompt / resource lists; a non-<jk>null</jk> value bypasses auto-derivation. 054 * 055 * <p> 056 * Stays a {@code default} interface method (Correction C8), for the same reason 057 * {@link McpRestServlet#capabilities()} stays {@code protected}: only {@link #revision()} 058 * above, declared on this same interface, ever calls it. 059 * 060 * @return The explicit capabilities, or <jk>null</jk> to auto-derive. 061 */ 062 default ServerCapabilities capabilities() { 063 return null; 064 } 065}