feat: add uixt tool list_packages

This commit is contained in:
lilong.129
2025-05-21 16:24:54 +08:00
parent 044eb07a35
commit 495443a2c4
7 changed files with 49 additions and 1 deletions

View File

@@ -101,6 +101,14 @@ func (ums *MCPServer4XTDriver) addTools() {
ums.tools = append(ums.tools, selectDeviceTool)
ums.handlerMap[selectDeviceTool.Name] = ums.handleSelectDevice
// ListPackages Tool
listPackagesTool := mcp.NewTool("list_packages",
mcp.WithDescription("List all the apps/packages on the device."),
)
ums.mcpServer.AddTool(listPackagesTool, ums.handleListPackages)
ums.tools = append(ums.tools, listPackagesTool)
ums.handlerMap[listPackagesTool.Name] = ums.handleListPackages
// TapXY Tool
tapParams := append(
[]mcp.ToolOption{mcp.WithDescription("Taps on the device screen at the given coordinates.")},
@@ -181,6 +189,20 @@ func (ums *MCPServer4XTDriver) handleSelectDevice(ctx context.Context, request m
return mcp.NewToolResultText(fmt.Sprintf("Selected device: %s", uuid)), nil
}
// handleListPackages handles the list_packages tool call.
func (ums *MCPServer4XTDriver) handleListPackages(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
driverExt, err := ums.setupXTDriver(ctx, request.Params.Arguments)
if err != nil {
return nil, err
}
apps, err := driverExt.IDriver.GetDevice().ListPackages()
if err != nil {
return nil, err
}
return mcp.NewToolResultText(fmt.Sprintf("Device packages: %v", apps)), nil
}
// handleTapXY handles the tap_xy tool call.
func (ums *MCPServer4XTDriver) handleTapXY(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
driverExt, err := ums.setupXTDriver(ctx, request.Params.Arguments)