Update mcp tool universe

Add rag utility
This commit is contained in:
shahondin1624
2026-02-14 17:59:18 +01:00
parent 4ac555546a
commit 1bcd277a1b
5 changed files with 18 additions and 7 deletions

View File

@@ -39,6 +39,12 @@
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>de.shahondin1624</groupId>
<artifactId>rag</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

View File

@@ -1,14 +1,15 @@
package mcp.app;
import de.shahondin1624.knowledgegraph.DatabaseLauncher;
import de.shahondin1624.rag.LocalRagService;
import mcp.server.McpServlet;
import mcp.server.ToolRegistrationServlet;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.server.Server;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.nio.file.Paths;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -18,11 +19,15 @@ public class McpLauncher {
public static void main(String[] args) throws Exception {
logger.info("Starting MCP App Launcher...");
new DatabaseLauncher().start();
// new DatabaseLauncher().start();
// Initialize RAG Service and index documentation
LocalRagService ragService = LocalRagService.getInstance();
ragService.indexDirectory(Paths.get("/home/shahondin1624/Projects/rag/test-data"));
// Scan both library tools and app tools
Set<String> classpaths = Stream.concat(
Stream.of("mcp.tools", "mcp.app.tools", "de.shahondin1624.knowledgegraph.tooling"),
Stream.of("mcp.tools", "mcp.app.tools", /*"de.shahondin1624.knowledgegraph.tooling", */ "de.shahondin1624.rag.tooling"),
args.length > 0 ? Stream.of(args[0].split(",")) : Stream.empty()
).collect(Collectors.toSet());

View File

@@ -52,6 +52,6 @@ public class CalculatorTool extends McpValidatedTool {
Expression expression = new ExpressionBuilder(expressionStr).build();
double result = expression.evaluate();
return success(String.valueOf(result));
return successResult(result);
}
}

View File

@@ -55,6 +55,6 @@ public class CurrentDateTimeTool extends McpValidatedTool {
public McpSchema.CallToolResult callValidated(McpSchema.CallToolRequest request, Map<String, Object> arguments) {
String now = LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
logger.info("CurrentDateTimeTool called, returning: {}", now);
return success(now);
return successResult(now);
}
}

View File

@@ -50,6 +50,6 @@ public class EchoTool extends McpValidatedTool {
public McpSchema.CallToolResult callValidated(McpSchema.CallToolRequest request, Map<String, Object> arguments) {
String message = (String) arguments.get("message");
logger.debug("EchoTool called with message: {}", message);
return success(message);
return successResult(message);
}
}