UNPKG

@tomisakae/accessibility-service-mcp

Version:

MCP server for Android Accessibility Service API automation

75 lines (74 loc) 2.32 kB
import { z } from "zod"; import { apiClient } from "../../api/client.js"; export function registerInputTools(server) { server.tool("input_text", "Nhập text vào field đang focus", { text: z.string().describe("Text cần nhập"), clearFirst: z .boolean() .optional() .default(false) .describe("Xóa text hiện tại trước khi nhập"), }, async ({ text, clearFirst }) => { try { const result = await apiClient.inputText({ text, clearFirst }); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify({ error: error instanceof Error ? error.message : String(error), }, null, 2), }, ], }; } }); server.tool("keyboard_action", "Thực hiện action trên bàn phím ảo - ENTER, BACK, HOME, RECENT, SEARCH, SEND, GO, DONE", { action: z .enum([ "ENTER", "BACK", "HOME", "RECENT", "SEARCH", "SEND", "GO", "DONE", ]) .describe("Action cần thực hiện trên bàn phím"), }, async ({ action }) => { try { const result = await apiClient.keyboardAction({ action }); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify({ error: error instanceof Error ? error.message : String(error), }, null, 2), }, ], }; } }); }