mobile-agent-mcp 0.1.1
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/CHANGELOG.md +32 -0
- package/LICENSE +21 -0
- package/NOTICE +4 -0
- package/README.md +115 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +142 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +115 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +137 -0
- package/dist/config.js.map +1 -0
- package/dist/driver/adb.d.ts +2 -0
- package/dist/driver/adb.d.ts.map +1 -0
- package/dist/driver/adb.js +12 -0
- package/dist/driver/adb.js.map +1 -0
- package/dist/driver/dev-server.d.ts +9 -0
- package/dist/driver/dev-server.d.ts.map +1 -0
- package/dist/driver/dev-server.js +24 -0
- package/dist/driver/dev-server.js.map +1 -0
- package/dist/driver/devices.d.ts +2 -0
- package/dist/driver/devices.d.ts.map +1 -0
- package/dist/driver/devices.js +46 -0
- package/dist/driver/devices.js.map +1 -0
- package/dist/driver/doctor.d.ts +11 -0
- package/dist/driver/doctor.d.ts.map +1 -0
- package/dist/driver/doctor.js +64 -0
- package/dist/driver/doctor.js.map +1 -0
- package/dist/driver/exec.d.ts +17 -0
- package/dist/driver/exec.d.ts.map +1 -0
- package/dist/driver/exec.js +60 -0
- package/dist/driver/exec.js.map +1 -0
- package/dist/driver/maestro.d.ts +11 -0
- package/dist/driver/maestro.d.ts.map +1 -0
- package/dist/driver/maestro.js +73 -0
- package/dist/driver/maestro.js.map +1 -0
- package/dist/driver/open-url.d.ts +3 -0
- package/dist/driver/open-url.d.ts.map +1 -0
- package/dist/driver/open-url.js +26 -0
- package/dist/driver/open-url.js.map +1 -0
- package/dist/driver/screenshot.d.ts +3 -0
- package/dist/driver/screenshot.d.ts.map +1 -0
- package/dist/driver/screenshot.js +27 -0
- package/dist/driver/screenshot.js.map +1 -0
- package/dist/errors.d.ts +19 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +45 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/tools.d.ts +12 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +152 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/mcp-server.d.ts +3 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +34 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/runtime.d.ts +20 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +71 -0
- package/dist/runtime.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +4 -0
- package/dist/version.js.map +1 -0
- package/mobile-agent.config.example.json +20 -0
- package/package.json +73 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { formatError } from '../errors.js';
|
|
2
|
+
export const MCP_TOOLS = [
|
|
3
|
+
{
|
|
4
|
+
name: 'list_devices',
|
|
5
|
+
description: 'Booted iOS sims, Android emulators, USB devices, Maestro version.',
|
|
6
|
+
inputSchema: { type: 'object', properties: {} },
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
name: 'doctor',
|
|
10
|
+
description: 'Run before a long flow. OK/WARN/FAIL on config, flows, tools.',
|
|
11
|
+
inputSchema: { type: 'object', properties: {} },
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'screenshot',
|
|
15
|
+
description: 'PNG under screenshotDir. Returns absolute path.',
|
|
16
|
+
inputSchema: {
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
platform: { type: 'string', enum: ['ios', 'android'] },
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'run_maestro_flow',
|
|
25
|
+
description: 'Flow name or path under flowsDir. Extra env merges with config.',
|
|
26
|
+
inputSchema: {
|
|
27
|
+
type: 'object',
|
|
28
|
+
properties: {
|
|
29
|
+
flow: { type: 'string' },
|
|
30
|
+
platform: { type: 'string', enum: ['ios', 'android'] },
|
|
31
|
+
env: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
additionalProperties: { type: 'string' },
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
required: ['flow'],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'run_smoke_flows',
|
|
41
|
+
description: 'Runs smokeFlows from config, in order.',
|
|
42
|
+
inputSchema: {
|
|
43
|
+
type: 'object',
|
|
44
|
+
properties: {
|
|
45
|
+
platform: { type: 'string', enum: ['ios', 'android'] },
|
|
46
|
+
env: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
additionalProperties: { type: 'string' },
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'adb_reverse',
|
|
55
|
+
description: 'USB Android: reverse tcp ports to the host. Default 8081.',
|
|
56
|
+
inputSchema: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
properties: {
|
|
59
|
+
ports: {
|
|
60
|
+
type: 'array',
|
|
61
|
+
items: { type: 'number' },
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'open_url',
|
|
68
|
+
description: 'Deep link or URL on sim/device.',
|
|
69
|
+
inputSchema: {
|
|
70
|
+
type: 'object',
|
|
71
|
+
properties: {
|
|
72
|
+
url: { type: 'string' },
|
|
73
|
+
platform: { type: 'string', enum: ['ios', 'android'] },
|
|
74
|
+
},
|
|
75
|
+
required: ['url'],
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'open_dev_url',
|
|
80
|
+
description: 'Opens devServerUrl from config (e.g. exp://…).',
|
|
81
|
+
inputSchema: {
|
|
82
|
+
type: 'object',
|
|
83
|
+
properties: {
|
|
84
|
+
platform: { type: 'string', enum: ['ios', 'android'] },
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
function stringEnv(value) {
|
|
90
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
const out = {};
|
|
94
|
+
for (const [key, v] of Object.entries(value)) {
|
|
95
|
+
if (typeof v === 'string') {
|
|
96
|
+
out[key] = v;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return Object.keys(out).length ? out : undefined;
|
|
100
|
+
}
|
|
101
|
+
export function handleMcpToolCall(runtime, name, args) {
|
|
102
|
+
try {
|
|
103
|
+
switch (name) {
|
|
104
|
+
case 'list_devices':
|
|
105
|
+
return { text: runtime.listDevices() };
|
|
106
|
+
case 'doctor':
|
|
107
|
+
return { text: runtime.doctor(), isError: runtime.doctorFailed() };
|
|
108
|
+
case 'screenshot':
|
|
109
|
+
return {
|
|
110
|
+
text: runtime.screenshot(typeof args?.platform === 'string' ? args.platform : undefined),
|
|
111
|
+
};
|
|
112
|
+
case 'run_maestro_flow': {
|
|
113
|
+
const flow = args?.flow;
|
|
114
|
+
if (typeof flow !== 'string' || !flow.trim()) {
|
|
115
|
+
throw new Error('flow is required');
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
text: runtime.runFlow(flow, typeof args?.platform === 'string' ? args.platform : undefined, stringEnv(args?.env)),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
case 'run_smoke_flows':
|
|
122
|
+
return {
|
|
123
|
+
text: runtime.runSmoke(typeof args?.platform === 'string' ? args.platform : undefined, stringEnv(args?.env)),
|
|
124
|
+
};
|
|
125
|
+
case 'adb_reverse': {
|
|
126
|
+
const ports = Array.isArray(args?.ports)
|
|
127
|
+
? args.ports.filter((port) => typeof port === 'number')
|
|
128
|
+
: undefined;
|
|
129
|
+
return { text: runtime.adbReverse(ports) };
|
|
130
|
+
}
|
|
131
|
+
case 'open_url': {
|
|
132
|
+
const url = args?.url;
|
|
133
|
+
if (typeof url !== 'string' || !url.trim()) {
|
|
134
|
+
throw new Error('url is required');
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
text: runtime.openUrl(url, typeof args?.platform === 'string' ? args.platform : undefined),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
case 'open_dev_url':
|
|
141
|
+
return {
|
|
142
|
+
text: runtime.openDevUrl(typeof args?.platform === 'string' ? args.platform : undefined),
|
|
143
|
+
};
|
|
144
|
+
default:
|
|
145
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
return { text: formatError(error), isError: true };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAS3C,MAAM,CAAC,MAAM,SAAS,GAAwB;IAC5C;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,mEAAmE;QAChF,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;KAChD;IACD;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,+DAA+D;QAC5E,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;KAChD;IACD;QACE,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,iDAAiD;QAC9D,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAA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AU,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7C,CAAC;YACD,KAAK,UAAU,CAAC,CAAC,CAAC;gBAChB,MAAM,GAAG,GAAG,IAAI,EAAE,GAAG,CAAC;gBACtB,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;oBAC3C,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;gBACrC,CAAC;gBACD,OAAO;oBACL,IAAI,EAAE,OAAO,CAAC,OAAO,CACnB,GAAG,EACH,OAAO,IAAI,EAAE,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAC/D;iBACF,CAAC;YACJ,CAAC;YACD,KAAK,cAAc;gBACjB,OAAO;oBACL,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,IAAI,EAAE,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;iBACzF,CAAC;YACJ;gBACE,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACrD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { handleMcpToolCall, MCP_TOOLS } from './mcp/tools.js';
|
|
6
|
+
import { createRuntime } from './runtime.js';
|
|
7
|
+
import { PACKAGE_NAME, PACKAGE_VERSION } from './version.js';
|
|
8
|
+
const runtime = createRuntime();
|
|
9
|
+
const server = new Server({ name: PACKAGE_NAME, version: PACKAGE_VERSION }, { capabilities: { tools: {} } });
|
|
10
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
11
|
+
tools: MCP_TOOLS,
|
|
12
|
+
}));
|
|
13
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
14
|
+
const { name, arguments: args } = request.params;
|
|
15
|
+
const result = handleMcpToolCall(runtime, name, args ?? undefined);
|
|
16
|
+
return {
|
|
17
|
+
content: [{ type: 'text', text: result.text }],
|
|
18
|
+
...(result.isError ? { isError: true } : {}),
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
async function main() {
|
|
22
|
+
const transport = new StdioServerTransport();
|
|
23
|
+
await server.connect(transport);
|
|
24
|
+
}
|
|
25
|
+
function shutdown() {
|
|
26
|
+
process.exit(0);
|
|
27
|
+
}
|
|
28
|
+
process.on('SIGINT', shutdown);
|
|
29
|
+
process.on('SIGTERM', shutdown);
|
|
30
|
+
main().catch((error) => {
|
|
31
|
+
process.stderr.write(`[${PACKAGE_NAME}] fatal: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=mcp-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AACnG,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AAClB,CAAC;AAED,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC/B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAEhC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,IAAI,YAAY,YAAY,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CACvF,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type LoadConfigOptions } from './config.js';
|
|
2
|
+
export declare class Runtime {
|
|
3
|
+
private readonly options;
|
|
4
|
+
private config;
|
|
5
|
+
private lastDoctor;
|
|
6
|
+
constructor(options?: LoadConfigOptions);
|
|
7
|
+
private cfg;
|
|
8
|
+
listDevices(): string;
|
|
9
|
+
screenshot(platform?: string): string;
|
|
10
|
+
runFlow(flow: string, platform?: string, env?: Record<string, string>): string;
|
|
11
|
+
runSmoke(platform?: string, env?: Record<string, string>): string;
|
|
12
|
+
adbReverse(ports?: number[]): string;
|
|
13
|
+
openUrl(url: string, platform?: string): string;
|
|
14
|
+
openDevUrl(platform?: string): string;
|
|
15
|
+
doctor(): string;
|
|
16
|
+
doctorFailed(): boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function createRuntime(options?: LoadConfigOptions): Runtime;
|
|
19
|
+
export declare const MobileAgentRuntime: typeof Runtime;
|
|
20
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,iBAAiB,EAAc,MAAM,aAAa,CAAC;AAejF,qBAAa,OAAO;IAIN,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC,OAAO,CAAC,MAAM,CAAgC;IAC9C,OAAO,CAAC,UAAU,CAA8B;gBAEnB,OAAO,GAAE,iBAAsB;IAI5D,OAAO,CAAC,GAAG;IAIX,WAAW;IAIX,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM;IAI5B,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAQrE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAcxD,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE;IAI3B,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAItC,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM;IAS5B,MAAM;IAKN,YAAY;CAIb;AAED,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,iBAAiB,WAExD;AAED,eAAO,MAAM,kBAAkB,gBAAU,CAAC"}
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { assertPlatform, loadConfig } from './config.js';
|
|
2
|
+
import { adbReverse } from './driver/adb.js';
|
|
3
|
+
import { resolveDevServerEnv } from './driver/dev-server.js';
|
|
4
|
+
import { listDevices } from './driver/devices.js';
|
|
5
|
+
import { doctorHasFailures, formatDoctorReport, runDoctor, } from './driver/doctor.js';
|
|
6
|
+
import { runMaestroFlow, runMaestroFlows } from './driver/maestro.js';
|
|
7
|
+
import { openUrl } from './driver/open-url.js';
|
|
8
|
+
import { captureScreenshot } from './driver/screenshot.js';
|
|
9
|
+
import { AgentError, ErrorCode } from './errors.js';
|
|
10
|
+
export class Runtime {
|
|
11
|
+
options;
|
|
12
|
+
config;
|
|
13
|
+
lastDoctor = null;
|
|
14
|
+
constructor(options = {}) {
|
|
15
|
+
this.options = options;
|
|
16
|
+
this.config = loadConfig(this.options);
|
|
17
|
+
}
|
|
18
|
+
cfg() {
|
|
19
|
+
return this.config;
|
|
20
|
+
}
|
|
21
|
+
listDevices() {
|
|
22
|
+
return listDevices();
|
|
23
|
+
}
|
|
24
|
+
screenshot(platform) {
|
|
25
|
+
return captureScreenshot(this.cfg(), assertPlatform(platform));
|
|
26
|
+
}
|
|
27
|
+
runFlow(flow, platform, env) {
|
|
28
|
+
return runMaestroFlow(this.cfg(), {
|
|
29
|
+
flow,
|
|
30
|
+
platform: assertPlatform(platform),
|
|
31
|
+
env,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
runSmoke(platform, env) {
|
|
35
|
+
const config = this.cfg();
|
|
36
|
+
if (!config.smokeFlows.length) {
|
|
37
|
+
throw new AgentError('smokeFlows is empty in mobile-agent.config.json', ErrorCode.NOT_CONFIGURED);
|
|
38
|
+
}
|
|
39
|
+
return runMaestroFlows(config, config.smokeFlows, {
|
|
40
|
+
platform: assertPlatform(platform),
|
|
41
|
+
env,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
adbReverse(ports) {
|
|
45
|
+
return adbReverse(ports ?? [8081]);
|
|
46
|
+
}
|
|
47
|
+
openUrl(url, platform) {
|
|
48
|
+
return openUrl(url, assertPlatform(platform));
|
|
49
|
+
}
|
|
50
|
+
openDevUrl(platform) {
|
|
51
|
+
const env = resolveDevServerEnv(this.cfg().devServerUrl);
|
|
52
|
+
const url = Object.values(env)[0];
|
|
53
|
+
if (!url) {
|
|
54
|
+
throw new AgentError('devServerUrl missing in config', ErrorCode.NOT_CONFIGURED);
|
|
55
|
+
}
|
|
56
|
+
return openUrl(url, assertPlatform(platform));
|
|
57
|
+
}
|
|
58
|
+
doctor() {
|
|
59
|
+
this.lastDoctor = runDoctor(this.cfg());
|
|
60
|
+
return formatDoctorReport(this.lastDoctor);
|
|
61
|
+
}
|
|
62
|
+
doctorFailed() {
|
|
63
|
+
const checks = this.lastDoctor ?? runDoctor(this.cfg());
|
|
64
|
+
return doctorHasFailures(checks);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export function createRuntime(options) {
|
|
68
|
+
return new Runtime(options);
|
|
69
|
+
}
|
|
70
|
+
export const MobileAgentRuntime = Runtime;
|
|
71
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA0B,UAAU,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAEL,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,GACV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,OAAO,OAAO;IAIW;IAHrB,MAAM,CAAgC;IACtC,UAAU,GAAyB,IAAI,CAAC;IAEhD,YAA6B,UAA6B,EAAE;QAA/B,YAAO,GAAP,OAAO,CAAwB;QAC1D,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAEO,GAAG;QACT,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,WAAW;QACT,OAAO,WAAW,EAAE,CAAC;IACvB,CAA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cAAc,CAAC,CAAC;QACnF,CAAC;QACD,OAAO,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IAChD,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QACxC,OAAO,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC7C,CAAC;IAED,YAAY;QACV,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QACxD,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;CACF;AAED,MAAM,UAAU,aAAa,CAAC,OAA2B;IACvD,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,QAAc,CAAC;AAC3C,eAAO,MAAM,YAAY,QAAW,CAAC"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAExD,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC,OAAO,CAAC;AAC3C,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC,IAAI,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"projectRoot": ".",
|
|
3
|
+
"flowsDir": "e2e/maestro/flows",
|
|
4
|
+
"screenshotDir": "artifacts/mobile-screenshots",
|
|
5
|
+
"smokeFlows": ["smoke-login", "smoke-logout"],
|
|
6
|
+
"devServerUrl": {
|
|
7
|
+
"scheme": "exp",
|
|
8
|
+
"port": 8081,
|
|
9
|
+
"hostEnv": "EXPO_DEV_HOST",
|
|
10
|
+
"outputEnvKey": "EXPO_URL"
|
|
11
|
+
},
|
|
12
|
+
"maestro": {
|
|
13
|
+
"bin": "maestro",
|
|
14
|
+
"defaultEnv": {},
|
|
15
|
+
"appId": {
|
|
16
|
+
"ios": "com.example.app.ios",
|
|
17
|
+
"android": "com.example.app"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mobile-agent-mcp",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Drive iOS sims, Android emulators, and USB devices from Cursor, Claude, or shell. Maestro flows, screenshots, adb, simctl. MCP + CLI.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Anthony Batista",
|
|
8
|
+
"url": "https://entkreis.de"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/anthonysbr/mobile-agent-mcp#readme",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/anthonysbr/mobile-agent-mcp.git"
|
|
14
|
+
},
|
|
15
|
+
"bugs": "https://github.com/anthonysbr/mobile-agent-mcp/issues",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"bin": {
|
|
26
|
+
"mobile-agent": "dist/cli.js",
|
|
27
|
+
"mobile-agent-mcp": "dist/mcp-server.js"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"LICENSE",
|
|
32
|
+
"NOTICE",
|
|
33
|
+
"README.md",
|
|
34
|
+
"CHANGELOG.md",
|
|
35
|
+
"mobile-agent.config.example.json"
|
|
36
|
+
],
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=20"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsc",
|
|
42
|
+
"dev": "tsc --watch",
|
|
43
|
+
"start:mcp": "node dist/mcp-server.js",
|
|
44
|
+
"test": "vitest run",
|
|
45
|
+
"typecheck": "tsc --noEmit",
|
|
46
|
+
"lint": "biome check src tests",
|
|
47
|
+
"format": "biome check --write src tests",
|
|
48
|
+
"check": "pnpm lint && pnpm typecheck && pnpm test && pnpm build",
|
|
49
|
+
"prepublishOnly": "pnpm build"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
53
|
+
"commander": "^13.1.0",
|
|
54
|
+
"zod": "^3.24.2"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@biomejs/biome": "2.4.16",
|
|
58
|
+
"@types/node": "^22.13.10",
|
|
59
|
+
"typescript": "^5.7.2",
|
|
60
|
+
"vitest": "^2.1.8"
|
|
61
|
+
},
|
|
62
|
+
"keywords": [
|
|
63
|
+
"mcp",
|
|
64
|
+
"maestro",
|
|
65
|
+
"mobile",
|
|
66
|
+
"e2e",
|
|
67
|
+
"adb",
|
|
68
|
+
"simctl",
|
|
69
|
+
"agent",
|
|
70
|
+
"ios",
|
|
71
|
+
"android"
|
|
72
|
+
]
|
|
73
|
+
}
|