Skip to content

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.

feat: restrict open url schemes unless env variable set (#299)

Gil Megidisha0aa68980928
diff --git a/src/server.ts b/src/server.ts
index 368e9e0..4fa9b0b 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -523,6 +523,11 @@ export const createMcpServer = (): McpServer => {
},
{ destructiveHint: true },
async ({ device, url }) => {
+ const allowUnsafeUrls = process.env.MOBILEMCP_ALLOW_UNSAFE_URLS === "1";
+ if (!allowUnsafeUrls && !url.startsWith("http://") && !url.startsWith("https://")) {
+ throw new ActionableError("Only http:// and https:// URLs are allowed. Set MOBILEMCP_ALLOW_UNSAFE_URLS=1 to allow other URL schemes.");
+ }
+
const robot = getRobotFromDevice(device);
await robot.openUrl(url);
return `Opened URL: ${url}`;