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: add get_more_tools so agents can report missing capabilities (#491)
Gil Megidish2a6a224076ad
diff --git a/src/server.ts b/src/server.tsindex ec88455..d77813b 100644--- a/src/server.ts+++ b/src/server.ts@@ -310,6 +310,25 @@ export const createMcpServer = (): McpServer => {throw new ActionableError(`Device "${deviceId}" not found. Use the mobile_list_available_devices tool to see available devices.`);};+ // ponytail: same tool as @posthog/mcp's reportMissing, without pulling in the sdk+ // nothing to report to when telemetry is off, so don't advertise the tool at all+ if (!process.env.MOBILEMCP_DISABLE_TELEMETRY) {+ tool(+ "get_more_tools",+ "Get More Tools",+ "Check for additional tools whenever your task might benefit from specialized capabilities - even if existing tools could work as a fallback. " ++ "The context is sent to the mobile-mcp developers, so never include PII, secrets, credentials or other private information in it.",+ {+ context: z.string().describe("A description of your goal and what kind of tool would help accomplish it."),+ },+ { readOnlyHint: true, openWorldHint: true },+ async ({ context }) => {+ posthog("$mcp_missing_capability", { "$mcp_intent": context }).then();+ return "Unfortunately, we have shown you the full tool list. We have noted your feedback and will work to improve the tool list in the future.";+ }+ );+ }+tool("mobile_list_available_devices","List Devices",diff --git a/test/server-get-more-tools.test.ts b/test/server-get-more-tools.test.tsnew file mode 100644index 0000000..e2a9478--- /dev/null+++ b/test/server-get-more-tools.test.ts@@ -0,0 +1,45 @@+import { expect, test } from "@playwright/test";+import { Client, InMemoryTransport } from "@modelcontextprotocol/client";+import { createMcpServer } from "../src/server";++const listToolNamesWithTelemetry = async (isTelemetryEnabled: boolean): Promise<string[]> => {+ const previousTelemetrySetting = process.env.MOBILEMCP_DISABLE_TELEMETRY;+ const previousFetch = globalThis.fetch;+ // never reach posthog from tests+ globalThis.fetch = async () => new Response();+ if (isTelemetryEnabled) {+ delete process.env.MOBILEMCP_DISABLE_TELEMETRY;+ } else {+ process.env.MOBILEMCP_DISABLE_TELEMETRY = "1";+ }++ try {+ const server = createMcpServer();+ const client = new Client({ name: "get-more-tools-test", version: "1.0.0" });+ const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();+ await server.connect(serverTransport);+ await client.connect(clientTransport);+ try {+ const result = await client.listTools();+ return result.tools.map(tool => tool.name);+ } finally {+ await client.close();+ await server.close();+ }+ } finally {+ globalThis.fetch = previousFetch;+ if (previousTelemetrySetting === undefined) {+ delete process.env.MOBILEMCP_DISABLE_TELEMETRY;+ } else {+ process.env.MOBILEMCP_DISABLE_TELEMETRY = previousTelemetrySetting;+ }+ }+};++test("get_more_tools is offered when telemetry is enabled", async () => {+ expect(await listToolNamesWithTelemetry(true)).toContain("get_more_tools");+});++test("get_more_tools is not registered at all when telemetry is disabled", async () => {+ expect(await listToolNamesWithTelemetry(false)).not.toContain("get_more_tools");+});