Skip to main content
Glama
TiagoDanin

Android Debug Bridge MCP

by TiagoDanin

input_keyevent

Simulate Android device key presses like BACK, HOME, ENTER, or DELETE for automation testing and device control via ADB commands.

Instructions

Send key events (BACK, HOME, ENTER, DELETE)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesKey event to send

Implementation Reference

  • Executes ADB keyevent command using mapped keycodes for BACK, HOME, ENTER, DELETE; captures UI dump afterward and returns formatted response.
    input_keyevent: async (args: any) => {
      const { key } = args as { key: string };
      
      const keyCodeMap = {
        BACK: '4',
        HOME: '3',
        ENTER: '66',
        DELETE: '67',
      };
      
      const keyCode = keyCodeMap[key as keyof typeof keyCodeMap];
      if (!keyCode) {
        throw new McpError(ErrorCode.InvalidParams, `Invalid key: ${key}`);
      }
      
      await executeCommand(`adb shell input keyevent ${keyCode}`);
      
      const uiContent = await captureUIContent(false);
      
      return {
        content: [
          {
            type: 'text',
            text: `Key event sent: ${key} (${keyCode})`,
          },
          ...uiContent,
        ],
      };
    },
  • Input schema defining the 'key' parameter with allowed values: BACK, HOME, ENTER, DELETE.
    {
      name: 'input_keyevent',
      description: 'Send key events (BACK, HOME, ENTER, DELETE)',
      inputSchema: {
        type: 'object',
        properties: {
          key: {
            type: 'string',
            enum: ['BACK', 'HOME', 'ENTER', 'DELETE'],
            description: 'Key event to send',
          },
        },
        required: ['key'],
      },
    },
  • src/index.ts:26-30 (registration)
    Registers tool definitions (including input_keyevent schema) for the MCP ListTools request.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: toolDefinitions,
      };
    });
  • src/index.ts:32-46 (registration)
    Registers generic tool handler dispatcher that invokes input_keyevent handler from toolHandlers object based on tool name.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      try {
        const handler = toolHandlers[name as keyof typeof toolHandlers];
        if (!handler) {
          throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
        }
    
        return await handler(args);
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        throw new McpError(ErrorCode.InternalError, `Tool execution failed: ${errorMessage}`);
      }
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states the action ('Send key events') but doesn't disclose behavioral traits like whether this requires device permissions, if it's synchronous/asynchronous, what happens on failure, or if it affects app state. For a mutation tool with zero annotation coverage, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely concise and front-loaded with a single, clear sentence. Every word earns its place by specifying the action and key examples without redundancy. No structural issues.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given one parameter with full schema coverage and no output schema, the description is minimally adequate. It states the purpose but lacks context on usage guidelines, behavioral transparency, or integration with siblings. For a simple tool, it's functional but could be more helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the schema fully documenting the single 'key' parameter (type, enum, description). The description lists the enum values but adds no meaning beyond what the schema provides, such as context for when to use each key. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Send') and resource ('key events') with specific examples (BACK, HOME, ENTER, DELETE). It distinguishes from siblings like input_tap or input_text by focusing on discrete key events rather than taps or text input. However, it doesn't explicitly differentiate from all siblings (e.g., input_scroll might also involve navigation).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives. The description implies usage for sending specific key events, but doesn't mention when to choose this over input_tap for navigation or input_text for text entry. No prerequisites or exclusions are stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TiagoDanin/Android-Debug-Bridge-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server