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
019/**
020 * Revision-neutral classification of a dispatch failure.
021 *
022 * <p>
023 * The core raises a <em>kind</em>; each revision maps kinds to its own JSON-RPC error codes via
024 * {@link McpRevision#errorCode(McpErrorKind)}. Several kinds legitimately map to the same code on a
025 * given revision — the point of the enum is that the core never has to know which.
026 */
027public enum McpErrorKind {
028
029   /** The JSON-RPC envelope itself was unusable (absent or empty {@code method}, null envelope). */
030   INVALID_REQUEST,
031
032   /** The requested top-level JSON-RPC method is not implemented by this revision. */
033   UNKNOWN_METHOD,
034
035   /** A {@code tools/call} named a tool that is not registered. */
036   TOOL_NOT_FOUND,
037
038   /** A {@code prompts/get} named a prompt that is not registered. */
039   PROMPT_NOT_FOUND,
040
041   /** A {@code resources/read} named a resource that is not registered. */
042   RESOURCE_NOT_FOUND,
043
044   /** A required parameter was missing, or a parameter had the wrong JSON shape. */
045   INVALID_PARAMS,
046
047   /** A handler threw an unexpected exception. */
048   INTERNAL_ERROR,
049
050   /**
051    * The request body could not be parsed as JSON.
052    *
053    * <p>
054    * No dispatch path raises this kind today — JSON parsing happens in the REST layer before
055    * dispatch is reached. The constant exists so a revision's code table is complete; that is not
056    * the same claim as the path being reachable.
057    */
058   PARSE_ERROR
059}