Mobile MCP: let AI agents drive your iOS and Android apps. MCP server for simulators, emulators and real devices. Works with Claude Code, Codex, Cursor and any MCP client.
TypeScript agentandroidandroid-automationappium-alternativeclaude-codecodexcursoremulatoriosios-automationmcpmcp-servermobilemobile-automationmobile-testingreal-devicesimulatorskills
feat: added take-app-screenshot
gmegidishef6fb91eae44
diff --git a/src/index.ts b/src/index.tsindex 18e732d..81c777c 100644--- a/src/index.ts+++ b/src/index.ts@@ -53,6 +53,21 @@ server.tool(});+const resolveLaunchableActivity = async (packageName: string): Promise<string> => {+ const result1 = execSync(`adb shell cmd package resolve-activity ${packageName}`)+ .toString()+ .split("\n")+ .map(line => line.trim())+ .filter(line => line.startsWith("name="))+ .map(line => line.substring("name=".length));++ if (result1.length !== 1) {+ throw new Error(`Error launching app: ${packageName}, got too many entries with 'name': ${result1.join(",")}`);+ }++ return result1[0];+}+server.tool("launch-app","Launch an app on mobile device",@@ -63,22 +78,9 @@ server.tool(log(`gilm launching packageName: "${packageName}"`);try {// FIXME: use appium or monkey for this- const result1 = execSync(`adb shell cmd package resolve-activity ${packageName}`)- .toString()- .split("\n")- .map(line => line.trim())- .filter(line => line.startsWith("name="))- .map(line => line.substring("name=".length));-- if (result1.length !== 1) {- return {- content: [{ type: 'text', text: `Error launching app: ${packageName}, got too many entries with 'name': ${result1.join(",")}` }],- isError: true- };- }-- log(`gilm: starting activity: ${packageName}, ${result1[0]}`);- await driver.startActivity(packageName, result1[0]);+ const activity = await resolveLaunchableActivity(packageName);+ log(`gilm: starting activity: ${packageName}, ${activity}`);+ await driver.startActivity(packageName, activity);return {content: [{ type: 'text', text: `Successfully launched app ${packageName}` }]@@ -261,6 +263,19 @@ server.tool(});+server.tool(+ 'take-app-screenshot',+ 'Take a screenshot of the screen of the mobile device',+ {},+ async ({}) => {+ log(`gilm: taking app screenshot`);+ const screenshot64 = await driver.takeScreenshot();+ return {+ content: [{ type: 'image', data: screenshot64, mimeType: 'image/png' }]+ }+ }+);+async function main() {driver = await remote(wdOpts);