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
fix: set isError: true for ActionableError tool results (#489) (#495)
Gil Megidish557b0c64636d
diff --git a/src/server.ts b/src/server.tsindex d77813b..f8b9cb3 100644--- a/src/server.ts+++ b/src/server.ts@@ -159,6 +159,7 @@ export const createMcpServer = (): McpServer => {if (error instanceof ActionableError) {return {content: [{ type: "text", text: `${error.message}. Please fix the issue and try again.` }],+ isError: true,};} else {// a real exceptiondiff --git a/test/server-errors.test.ts b/test/server-errors.test.tsnew file mode 100644index 0000000..9863442--- /dev/null+++ b/test/server-errors.test.ts@@ -0,0 +1,30 @@+import { expect, test } from "@playwright/test";+import { Client, InMemoryTransport } from "@modelcontextprotocol/client";+import { createMcpServer } from "../src/server";++const createConnectedClient = async () => {+ process.env.MOBILEMCP_DISABLE_TELEMETRY = "1";+ const server = createMcpServer();+ const client = new Client({ name: "errors-test", version: "1.0.0" });+ const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();+ await server.connect(serverTransport);+ await client.connect(clientTransport);+ return client;+};++// a batch step naming an unknown tool makes the batch tool throw an ActionableError, no device needed+const callToolThatThrowsActionableError = async (client: Client): Promise<any> => {+ return client.callTool({+ name: "mobile_batch_commands",+ arguments: { device: "nope", steps: [{ name: "mobile_does_not_exist", arguments: {} }] },+ });+};++// regression test for #489: a failed tool call must not look like a success to the client+test("reports an ActionableError as a tool error", async () => {+ const client = await createConnectedClient();+ const result = await callToolThatThrowsActionableError(client);++ expect(result.isError).toBe(true);+ expect(result.content[0].text).toBe("Unknown tool in step 1: mobile_does_not_exist. Please fix the issue and try again.");+});