Skip to main content
Glama
TiagoDanin

Android Debug Bridge MCP

by TiagoDanin

capture_screenshot

Capture screenshots from Android devices during testing and save them to designated test folders for documentation and debugging purposes.

Instructions

Capture a screenshot and save it to the test folder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
test_nameYesName of the test folder where to save the screenshot
step_nameYesName of the step for the screenshot file (e.g., "001_login")

Implementation Reference

  • The main handler function that implements the capture_screenshot tool logic. Uses ADB screencap to capture and save the screenshot, then returns it as base64-encoded image.
    capture_screenshot: async (args: any) => {
      const { test_name, step_name } = args as { 
        test_name: string; 
        step_name: string; 
      };
      
      const testPath = path.join(getBaseTestPath(), test_name);
      const screenshotPath = path.join(testPath, `${step_name}_step.png`);
      
      if (!fs.existsSync(testPath)) {
        fs.mkdirSync(testPath, { recursive: true });
      }
      
      await executeCommand(`adb exec-out screencap -p > "${screenshotPath}"`);
      
      // Read the screenshot file and convert to base64
      const imageData = fs.readFileSync(screenshotPath);
      const base64Image = imageData.toString('base64');
      
      return {
        content: [
          {
            type: 'text',
            text: `Screenshot captured: ${screenshotPath}`,
          },
          {
            type: 'image',
            data: base64Image,
            mimeType: 'image/png',
          },
        ],
      };
    },
  • The schema definition for the capture_screenshot tool, including input parameters test_name and step_name.
    {
      name: 'capture_screenshot',
      description: 'Capture a screenshot and save it to the test folder',
      inputSchema: {
        type: 'object',
        properties: {
          test_name: {
            type: 'string',
            description: 'Name of the test folder where to save the screenshot',
          },
          step_name: {
            type: 'string',
            description: 'Name of the step for the screenshot file (e.g., "001_login")',
          },
        },
        required: ['test_name', 'step_name'],
      },
    },
  • src/index.ts:32-46 (registration)
    Registration of tool handlers via MCP server's CallToolRequestSchema. Looks up handler from toolHandlers object by 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}`);
      }
    });
  • src/index.ts:26-30 (registration)
    Registration of tool schemas via MCP server's ListToolsRequestSchema. Returns the toolDefinitions array containing the schema for capture_screenshot.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: toolDefinitions,
      };
    });

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