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;
018
019import org.jspecify.annotations.NonNull;
020
021import javax.annotation.concurrent.ThreadSafe;
022import java.util.List;
023import java.util.Optional;
024
025/**
026 * Immutable request-specific context for a dynamic {@code resources/list}
027 * operation.
028 *
029 * <p>Soklet preserves a cursor as an opaque, bounded string. The application
030 * decides whether it is authentic, unexpired, authorized for the current
031 * principal, bound to a retained snapshot and catalog revision, and portable
032 * to the instance handling this request.
033 *
034 * @author <a href="https://www.revetkn.com">Mark Allen</a>
035 */
036@ThreadSafe
037public interface McpResourceListContext {
038        /**
039         * Returns the opaque cursor supplied by the client.
040         *
041         * <p>The application owns the cursor's format, integrity, lifetime,
042         * authorization binding, and cross-instance portability. A present empty
043         * string is preserved as a present protocol value. Invalid, expired,
044         * tampered, cross-principal, missing-snapshot, and wrong-revision values
045         * should produce the same neutral application error; Soklet does not
046         * classify those failures.
047         *
048         * @return client cursor, or empty when the request omitted {@code cursor}
049         */
050        @NonNull
051        Optional<@NonNull String> getCursor();
052
053        /**
054         * Returns descriptors derived from this endpoint's exact-URI resource
055         * registrations.
056         *
057         * <p>The immutable list is in deterministic registration order and excludes
058         * URI-template registrations and resources not enabled for the request's
059         * selected protocol revision. It is convenience registration data, not an
060         * authorization-filtered result. A custom handler remains the sole authority
061         * for the returned page.
062         *
063         * @return immutable exact-resource descriptors in registration order
064         */
065        @NonNull
066        List<@NonNull McpResourceDescriptor> getRegisteredResourceDescriptors();
067}