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; 022 023/** 024 * Programmatic MCP tool handler contract. 025 * 026 * @author <a href="https://www.revetkn.com">Mark Allen</a> 027 */ 028@ThreadSafe 029public interface McpToolHandler { 030 /** 031 * Provides the MCP tool name. 032 * 033 * @return the tool name 034 */ 035 @NonNull 036 String getName(); 037 038 /** 039 * Provides the MCP tool description. 040 * 041 * @return the tool description 042 */ 043 @NonNull 044 String getDescription(); 045 046 /** 047 * Provides the input schema used for framework validation and client advertisement. 048 * 049 * @return the tool input schema 050 */ 051 @NonNull 052 McpSchema getInputSchema(); 053 054 /** 055 * Handles an MCP {@code tools/call} request. 056 * 057 * @param context the tool handler context 058 * @return the tool result 059 * @throws Exception if the tool call fails 060 */ 061 @NonNull 062 McpToolResult handle(@NonNull McpToolHandlerContext context) throws Exception; 063}