@nbakka/mcp-appium 1.0.0 → 1.0.2
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/bin/mcp-appium.js +49 -66
- package/package.json +9 -21
package/bin/mcp-appium.js
CHANGED
|
@@ -1,74 +1,57 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import yargs from "yargs";
|
|
3
|
-
import { hideBin } from "yargs/helpers";
|
|
4
|
-
import MCPClient from "@modelcontextprotocol/sdk/client/mcp.js";
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
alias: "u",
|
|
10
|
-
type: "string",
|
|
11
|
-
demandOption: true,
|
|
12
|
-
describe: "MCP server base URL",
|
|
13
|
-
})
|
|
14
|
-
.command("start_session", "Start Appium session", (yargs) => {
|
|
15
|
-
yargs
|
|
16
|
-
.option("platformName", { type: "string", demandOption: true })
|
|
17
|
-
.option("deviceName", { type: "string", demandOption: true })
|
|
18
|
-
.option("app", { type: "string" })
|
|
19
|
-
.option("automationName", { type: "string" });
|
|
20
|
-
})
|
|
21
|
-
.command("tap <by> <value>", "Tap element", (yargs) => {
|
|
22
|
-
yargs.positional("by", { type: "string" }).positional("value", { type: "string" });
|
|
23
|
-
})
|
|
24
|
-
.command(
|
|
25
|
-
"swipe <startX> <startY> <endX> <endY> [duration]",
|
|
26
|
-
"Swipe gesture",
|
|
27
|
-
(yargs) => {
|
|
28
|
-
yargs
|
|
29
|
-
.positional("startX", { type: "number" })
|
|
30
|
-
.positional("startY", { type: "number" })
|
|
31
|
-
.positional("endX", { type: "number" })
|
|
32
|
-
.positional("endY", { type: "number" })
|
|
33
|
-
.positional("duration", { type: "number", default: 800 });
|
|
34
|
-
}
|
|
35
|
-
)
|
|
36
|
-
.demandCommand(1, "You must provide a command")
|
|
37
|
-
.help().argv;
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { dirname, resolve } from 'path';
|
|
5
|
+
import { spawn } from 'child_process';
|
|
38
6
|
|
|
39
|
-
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
40
9
|
|
|
41
|
-
|
|
42
|
-
const cmd = argv._[0];
|
|
43
|
-
let result;
|
|
10
|
+
const serverPath = resolve(__dirname, '../src/lib/server.js');
|
|
44
11
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
app: argv.app,
|
|
50
|
-
automationName: argv.automationName,
|
|
51
|
-
};
|
|
52
|
-
result = await client.callTool("start_session", { capabilities: caps });
|
|
53
|
-
} else if (cmd === "tap") {
|
|
54
|
-
result = await client.callTool("tap", { by: argv.by, value: argv.value });
|
|
55
|
-
} else if (cmd === "swipe") {
|
|
56
|
-
result = await client.callTool("swipe", {
|
|
57
|
-
startX: argv.startX,
|
|
58
|
-
startY: argv.startY,
|
|
59
|
-
endX: argv.endX,
|
|
60
|
-
endY: argv.endY,
|
|
61
|
-
duration: argv.duration,
|
|
62
|
-
});
|
|
63
|
-
} else {
|
|
64
|
-
throw new Error(`Unknown command: ${cmd}`);
|
|
65
|
-
}
|
|
12
|
+
// Start the server
|
|
13
|
+
const child = spawn('node', [serverPath], {
|
|
14
|
+
stdio: 'inherit'
|
|
15
|
+
});
|
|
66
16
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
console.error("Error:", e.message);
|
|
17
|
+
child.on('error', (error) => {
|
|
18
|
+
console.error(`Error starting server: ${error.message}`);
|
|
70
19
|
process.exit(1);
|
|
71
|
-
|
|
72
|
-
}
|
|
20
|
+
});
|
|
73
21
|
|
|
74
|
-
|
|
22
|
+
// Handle process termination
|
|
23
|
+
process.on('SIGTERM', () => {
|
|
24
|
+
child.kill('SIGTERM');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
process.on('SIGINT', () => {
|
|
28
|
+
child.kill('SIGINT');
|
|
29
|
+
});#!/usr/bin/env node
|
|
30
|
+
|
|
31
|
+
import { fileURLToPath } from 'url';
|
|
32
|
+
import { dirname, resolve } from 'path';
|
|
33
|
+
import { spawn } from 'child_process';
|
|
34
|
+
|
|
35
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
36
|
+
const __dirname = dirname(__filename);
|
|
37
|
+
|
|
38
|
+
const serverPath = resolve(__dirname, '../src/lib/server.js');
|
|
39
|
+
|
|
40
|
+
// Start the server
|
|
41
|
+
const child = spawn('node', [serverPath], {
|
|
42
|
+
stdio: 'inherit'
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
child.on('error', (error) => {
|
|
46
|
+
console.error(`Error starting server: ${error.message}`);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Handle process termination
|
|
51
|
+
process.on('SIGTERM', () => {
|
|
52
|
+
child.kill('SIGTERM');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
process.on('SIGINT', () => {
|
|
56
|
+
child.kill('SIGINT');
|
|
57
|
+
});
|
package/package.json
CHANGED
|
@@ -1,34 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nbakka/mcp-appium",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Selenium WebDriver MCP Server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/lib/server.js",
|
|
7
7
|
"bin": {
|
|
8
|
-
"mcp-appium": "./
|
|
8
|
+
"mcp-appium": "./src/lib/server.js"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"
|
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
12
|
},
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"README.md",
|
|
17
|
-
"LICENSE"
|
|
18
|
-
],
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"author": "",
|
|
15
|
+
"license": "ISC",
|
|
19
16
|
"dependencies": {
|
|
20
17
|
"@modelcontextprotocol/sdk": "^1.7.0",
|
|
21
|
-
|
|
18
|
+
"axios": "^1.4.0",
|
|
22
19
|
"zod": "^3.22.2",
|
|
23
20
|
"yargs": "^17.7.2"
|
|
24
|
-
},
|
|
25
|
-
"publishConfig": {
|
|
26
|
-
"access": "public"
|
|
27
|
-
},
|
|
28
|
-
"author": "Your Name <youremail@example.com>",
|
|
29
|
-
"license": "MIT",
|
|
30
|
-
"repository": {
|
|
31
|
-
"type": "git",
|
|
32
|
-
"url": "https://github.com/nbakka/mcp-appium.git"
|
|
33
21
|
}
|
|
34
|
-
}
|
|
22
|
+
}
|