Add rag utility

This commit is contained in:
shahondin1624
2026-02-14 17:59:18 +01:00
parent 3030088124
commit a717b21d26
2 changed files with 15 additions and 3 deletions

View File

@@ -66,6 +66,17 @@ public abstract class McpValidatedTool implements McpTool {
return new CallToolResultBuilder().addText(text).build();
}
protected McpSchema.CallToolResult success(String text, Map<String, Object> structured) {
return new CallToolResultBuilder()
.addText(text)
.structuredContent(structured)
.build();
}
protected McpSchema.CallToolResult successResult(Object resultValue) {
return success(String.valueOf(resultValue), Map.of("result", resultValue));
}
protected McpSchema.CallToolResult error(String text) {
return new CallToolResultBuilder().isError(true).addText(text).build();
}

View File

@@ -1,12 +1,13 @@
package mcp.registry;
import io.modelcontextprotocol.server.McpStatelessSyncServer;
import io.modelcontextprotocol.spec.McpSchema;
import mcp.tools.McpTool;
import org.junit.jupiter.api.Test;
import java.util.Set;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.*;
public class ToolRegistryTest {