001/* 002 * Copyright 2022-2026 Revetware LLC. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package com.soklet; 017 018import org.jspecify.annotations.NonNull; 019 020import javax.annotation.concurrent.ThreadSafe; 021import java.util.Optional; 022 023/** 024 * Concurrently callable selector for one explicit Skills variant group. 025 * 026 * <p>Only accessible, discoverable registrations are supplied. Return one exact 027 * supplied registration instance, not an equal copy, or omit the group with 028 * {@link Optional#empty()}. A foreign registration, null result, or callback 029 * failure fails listing without publishing a partial result. Selection grants 030 * no access; direct URI lookup bypasses it and independently rechecks access. 031 * 032 * <p>A configured selector runs for every nonempty filtered group, including a 033 * singleton. Empty filtered groups do not invoke it. Declared multivariant 034 * groups require an explicit selector, even if filtering leaves one candidate. 035 * The application owns fallback selection and must respect the supplied bounded 036 * language preferences, including zero-weight exclusions. The existing 037 * localization context is available through invocation features rather than a 038 * separate negotiation; Soklet does not replace a custom selector's policy 039 * with automatic regional matching. 040 * 041 * @author <a href="https://www.revetkn.com">Mark Allen</a> 042 */ 043@ThreadSafe 044@FunctionalInterface 045public interface McpSkillVariantSelector { 046 /** 047 * Selects at most one of the supplied canonical registrations for listing. 048 * 049 * @param requestContext admitted request context 050 * @param skillVariantSelectionContext group key, filtered candidates, and bounded client preferences 051 * @param invocationFeatures invocation-scoped optional features 052 * @return one supplied registration instance, or empty to omit the group; never null 053 * @throws Exception if variant selection fails 054 */ 055 @NonNull 056 Optional<@NonNull McpSkillRegistration> select(@NonNull McpRequestContext requestContext, 057 @NonNull McpSkillVariantSelectionContext skillVariantSelectionContext, 058 @NonNull McpInvocationFeatures invocationFeatures) throws Exception; 059}