@mobilenext/mobile-mcp 0.0.51 → 0.0.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -14,6 +14,9 @@ const startSseServer = async (host, port) => {
14
14
  const app = (0, express_1.default)();
15
15
  const server = (0, server_1.createMcpServer)();
16
16
  const authToken = process.env.MOBILEMCP_AUTH;
17
+ if (!authToken) {
18
+ (0, logger_1.error)("WARNING: MOBILEMCP_AUTH is not set. The SSE server will accept unauthenticated connections. Set MOBILEMCP_AUTH to require Bearer token authentication.");
19
+ }
17
20
  if (authToken) {
18
21
  app.use((req, res, next) => {
19
22
  if (req.headers.authorization !== `Bearer ${authToken}`) {
@@ -23,6 +26,18 @@ const startSseServer = async (host, port) => {
23
26
  next();
24
27
  });
25
28
  }
29
+ // Block cross-origin requests — MCP clients are not browsers
30
+ app.use((req, res, next) => {
31
+ if (req.headers.origin) {
32
+ res.status(403).json({ error: "Cross-origin requests are not allowed" });
33
+ return;
34
+ }
35
+ if (req.method === "OPTIONS") {
36
+ res.status(403).end();
37
+ return;
38
+ }
39
+ next();
40
+ });
26
41
  let transport = null;
27
42
  app.post("/mcp", (req, res) => {
28
43
  if (transport) {
@@ -31,9 +46,13 @@ const startSseServer = async (host, port) => {
31
46
  });
32
47
  app.get("/mcp", (req, res) => {
33
48
  if (transport) {
34
- transport.close();
49
+ res.status(409).json({ error: "Another client is already connected. Disconnect the existing client first." });
50
+ return;
35
51
  }
36
52
  transport = new sse_js_1.SSEServerTransport("/mcp", res);
53
+ transport.onclose = () => {
54
+ transport = null;
55
+ };
37
56
  server.connect(transport);
38
57
  });
39
58
  app.listen(port, host, () => {
package/lib/mobilecli.js CHANGED
@@ -51,7 +51,7 @@ class Mobilecli {
51
51
  // We're inside node_modules, go to the last node_modules in the path
52
52
  const nodeModulesParts = pathParts.slice(0, lastNodeModulesIndex + 1);
53
53
  const lastNodeModulesPath = nodeModulesParts.join(node_path_1.sep);
54
- const mobilecliPath = (0, node_path_1.join)(lastNodeModulesPath, "@mobilenext", "mobilecli", "bin", binaryName);
54
+ const mobilecliPath = (0, node_path_1.join)(lastNodeModulesPath, "mobilecli", "bin", binaryName);
55
55
  if ((0, node_fs_1.existsSync)(mobilecliPath)) {
56
56
  return mobilecliPath;
57
57
  }
@@ -59,7 +59,7 @@ class Mobilecli {
59
59
  // Not in node_modules, look one directory up from current script
60
60
  const scriptDir = (0, node_path_1.dirname)(__filename);
61
61
  const parentDir = (0, node_path_1.dirname)(scriptDir);
62
- const mobilecliPath = (0, node_path_1.join)(parentDir, "node_modules", "@mobilenext", "mobilecli", "bin", binaryName);
62
+ const mobilecliPath = (0, node_path_1.join)(parentDir, "node_modules", "mobilecli", "bin", binaryName);
63
63
  if ((0, node_fs_1.existsSync)(mobilecliPath)) {
64
64
  return mobilecliPath;
65
65
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mobilenext/mobile-mcp",
3
3
  "mcpName": "io.github.mobile-next/mobile-mcp",
4
- "version": "0.0.51",
4
+ "version": "0.0.52",
5
5
  "description": "Mobile MCP",
6
6
  "repository": {
7
7
  "type": "git",
@@ -34,7 +34,7 @@
34
34
  "zod-to-json-schema": "3.25.0"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@mobilenext/mobilecli": "0.1.60"
37
+ "mobilecli": "0.2.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@eslint/eslintrc": "^3.2.0",