Junjie
8 天以前 4898d942bd6e3c1119493cf0314b15f2bd54daf3
src/main/java/com/zy/ai/mcp/controller/McpController.java
@@ -87,4 +87,19 @@
            return JsonRpcResponse.err(id, -32000, "Server error", e.getMessage());
        }
    }
}
    public List<Map<String, Object>> listTools() {
        return registry.listTools();
    }
    public Object callTool(String toolName, JSONObject arguments) throws Exception {
        if (toolName == null || toolName.trim().isEmpty()) {
            throw new IllegalArgumentException("missing tool name");
        }
        ToolDefinition def = registry.get(toolName);
        if (def == null) {
            throw new IllegalArgumentException("tool not found: " + toolName);
        }
        return def.getHandler().handle(arguments == null ? new JSONObject() : arguments);
    }
}