Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ Thumbs.db

# Generated files
*.d.ts

# Documents
src/tools/documentation/uploads/documents.json
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ Upload a mobile app to LambdaTest cloud storage for testing.
- `appPath`: Local path to the app file (APK/IPA)
- `appName`: Optional custom name for the app

#### `activate_app`

Activate the app passed as input

- **Parameters**:
- `id`: Bundle ID or app-packge

### Element Interaction

#### `generate_locators`
Expand Down
2 changes: 2 additions & 0 deletions src/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import setValue from './interactions/setValue.js';
import getText from './interactions/getText.js';
import screenshot from './interactions/screenshot.js';
import answerAppium from './answerAppium.js';
import activateApp from './interactions/activateApp.js';

export default function registerTools(server: FastMCP): void {
selectPlatform(server);
Expand All @@ -25,6 +26,7 @@ export default function registerTools(server: FastMCP): void {
setValue(server);
getText(server);
screenshot(server);
activateApp(server);

generateTest(server);
console.log('All tools registered');
Expand Down
46 changes: 46 additions & 0 deletions src/tools/interactions/activateApp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { FastMCP } from 'fastmcp/dist/FastMCP.js';
import { getDriver } from '../sessionStore.js';
import { z } from 'zod';

export default function activateApp(server: FastMCP): void {
const activateAppSchema = z.object({
id: z.string().describe('The app id'),
});

server.addTool({
name: 'activate_app',
description: 'Activate app by id',
parameters: activateAppSchema,
annotations: {
readOnlyHint: false,
openWorldHint: false,
},
execute: async (args: { id: string }, context: any): Promise<any> => {
const driver = getDriver();
if (!driver) {
throw new Error('No driver found');
}

try {
await driver.activateApp(args.id);
return {
content: [
{
type: 'text',
text: `App ${args.id} activated correctly.`,
},
],
};
} catch (err: any) {
return {
content: [
{
type: 'text',
text: `Error activating the app ${args.id}: ${err.toString()}`,
},
],
};
}
},
});
}