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 * http://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 */
016
017package com.soklet.annotation;
018
019import org.jspecify.annotations.NonNull;
020
021import java.lang.annotation.ElementType;
022import java.lang.annotation.Retention;
023import java.lang.annotation.RetentionPolicy;
024import java.lang.annotation.Target;
025
026/**
027 * Binds a {@link McpResource} method parameter to a URI-template variable.
028 * <p>
029 * Resource URI parameters are strings. A blank {@link #name()} uses the
030 * source-level Java parameter name captured by Soklet's annotation processor;
031 * an explicit name keeps the public template contract stable across Java
032 * refactoring.
033 * <p>
034 * Values are UTF-8 percent-decoded exactly once. An encoded slash
035 * ({@code %2F}) becomes {@code /}; {@code %252F} becomes the literal string
036 * {@code %2F}. Captures can be empty and can contain decoded NUL, CR or LF;
037 * validate them for the intended application use. A Level 1 variable cannot
038 * capture an unencoded slash. The
039 * application owns path authorization and filesystem containment checks.
040 *
041 * @author <a href="https://www.revetkn.com">Mark Allen</a>
042 */
043@Target(ElementType.PARAMETER)
044@Retention(RetentionPolicy.RUNTIME)
045public @interface McpResourceUriParameter {
046        /**
047         * The URI-template variable name.
048         *
049         * @return variable name, or an empty string to use the Java parameter name
050         */
051        @NonNull
052        String name() default "";
053}