Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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()}`,
},
],
};
}
},
});
}