Skip to main content
Glama
mobile-next

Mobile Next MCP Server

Official
by mobile-next

Terminate App

mobile_terminate_app
Destructive

Stop and terminate an app on a mobile device by specifying the device identifier and package name. Use this tool to force-close applications during mobile automation testing.

Instructions

Stop and terminate an app on mobile device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deviceYesThe device identifier to use. Use mobile_list_available_devices to find which devices are available to you.
packageNameYesThe package name of the app to terminate

Implementation Reference

  • src/server.ts:281-294 (registration)
    Registration of the 'mobile_terminate_app' MCP tool. Includes input schema for 'device' and 'packageName', and handler that uses getRobotFromDevice to get the platform-specific robot and calls its terminateApp method.
    tool(
    	"mobile_terminate_app",
    	"Terminate App",
    	"Stop and terminate an app on mobile device",
    	{
    		device: z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you."),
    		packageName: z.string().describe("The package name of the app to terminate"),
    	},
    	async ({ device, packageName }) => {
    		const robot = getRobotFromDevice(device);
    		await robot.terminateApp(packageName);
    		return `Terminated app ${packageName}`;
    	}
    );
  • Handler function for the tool. Retrieves the Robot instance for the given device and invokes terminateApp(packageName). The actual termination logic is implemented in platform-specific Robot subclasses (AndroidRobot, IosRobot, MobileDevice).
    async ({ device, packageName }) => {
    	const robot = getRobotFromDevice(device);
    	await robot.terminateApp(packageName);
    	return `Terminated app ${packageName}`;
  • Input schema using Zod for the tool parameters: device (string) and packageName (string).
    {
    	device: z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you."),
    	packageName: z.string().describe("The package name of the app to terminate"),
    },
  • Helper function getRobotFromDevice that determines the device type and returns the appropriate Robot implementation (IosRobot for real iOS, AndroidRobot for Android, MobileDevice for simulators). Used by the tool handler.
    const getRobotFromDevice = (deviceId: string): Robot => {
    
    	// from now on, we must have mobilecli working
    	ensureMobilecliAvailable();
    
    	// Check if it's an iOS device
    	const iosManager = new IosManager();
    	const iosDevices = iosManager.listDevices();
    	const iosDevice = iosDevices.find(d => d.deviceId === deviceId);
    	if (iosDevice) {
    		return new IosRobot(deviceId);
    	}
    
    	// Check if it's an Android device
    	const androidManager = new AndroidDeviceManager();
    	const androidDevices = androidManager.getConnectedDevices();
    	const androidDevice = androidDevices.find(d => d.deviceId === deviceId);
    	if (androidDevice) {
    		return new AndroidRobot(deviceId);
    	}
    
    	// Check if it's a simulator (will later replace all other device types as well)
    	const response = mobilecli.getDevices({
    		platform: "ios",
    		type: "simulator",
    		includeOffline: false,
    	});
    
    	if (response.status === "ok" && response.data && response.data.devices) {
    		for (const device of response.data.devices) {
    			if (device.id === deviceId) {
    				return new MobileDevice(deviceId);
    			}
    		}
    	}
    
    	throw new ActionableError(`Device "${deviceId}" not found. Use the mobile_list_available_devices tool to see available devices.`);
    };
Behavior3/5

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

The annotations include destructiveHint=true, which already indicates this is a destructive operation. The description adds minimal context by specifying 'stop and terminate,' reinforcing the destructive nature, but doesn't disclose additional behavioral traits like whether this requires specific permissions, if it's reversible, or potential side effects. No contradiction with annotations exists.

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?

The description is a single, efficient sentence that directly states the tool's function without unnecessary words. It's front-loaded with the core action, making it easy to parse quickly, and every word earns its place by conveying essential information.

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 the tool's moderate complexity (destructive operation with 2 parameters), no output schema, and annotations covering safety, the description is minimally adequate. It states what the tool does but lacks details on outcomes, error conditions, or integration with sibling tools, leaving gaps in completeness for effective agent use.

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 both parameters well-documented in the schema (device identifier and package name). The description adds no additional meaning beyond what the schema provides, such as examples or edge cases, so it meets the baseline for high schema coverage without compensating value.

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 ('stop and terminate') and resource ('an app on mobile device'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like mobile_uninstall_app (which removes the app) or mobile_launch_app (which starts it), missing full sibling distinction.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., the app must be running), when termination is appropriate versus other actions like uninstalling, or how it differs from simply closing an app. This leaves usage context unclear.

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/mobile-next/mobile-mcp'

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