appium-mcp 1.79.0 → 1.79.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 +6 -0
- package/dist/tools/gestures/drag-and-drop.d.ts.map +1 -1
- package/dist/tools/gestures/drag-and-drop.js +34 -10
- package/dist/tools/gestures/drag-and-drop.js.map +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/src/resources/submodules.zip +0 -0
- package/src/tools/gestures/drag-and-drop.ts +47 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [1.79.1](https://github.com/appium/appium-mcp/compare/v1.79.0...v1.79.1) (2026-05-28)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **gestures:** support ai-element UUIDs in drag and drop ([#339](https://github.com/appium/appium-mcp/issues/339)) ([de91697](https://github.com/appium/appium-mcp/commit/de916975c4315135c147a189545db4b617694d5b))
|
|
6
|
+
|
|
1
7
|
## [1.79.0](https://github.com/appium/appium-mcp/compare/v1.78.1...v1.79.0) (2026-05-27)
|
|
2
8
|
|
|
3
9
|
### Features
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drag-and-drop.d.ts","sourceRoot":"","sources":["../../../src/tools/gestures/drag-and-drop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"drag-and-drop.d.ts","sourceRoot":"","sources":["../../../src/tools/gestures/drag-and-drop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,OAAO,EAAE,MAAM,SAAS,CAAC;AA6FtD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAiHzD"}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { elementUUIDScheme } from '../../schema.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getWindowRect, performActions } from '../../command.js';
|
|
4
|
+
import { isAIEnabled } from '../ai/config.js';
|
|
4
5
|
import { errorResult, resolveDriver, textResult, toolErrorMessage, } from '../tool-response.js';
|
|
6
|
+
import { aiDisabledResult, isAiElementUUID, resolveTargetRect, } from './handlers/ai-element.js';
|
|
5
7
|
const DROP_PAUSE_DURATION_MS = 150;
|
|
8
|
+
const AI_UUID_HINT = isAIEnabled()
|
|
9
|
+
? `Supports AI coordinate UUIDs (format: ai-element:x,y:bbox) returned by appium_ai. `
|
|
10
|
+
: '';
|
|
6
11
|
const dragAndDropSchema = z.object({
|
|
7
12
|
sourceElementUUID: elementUUIDScheme
|
|
8
13
|
.optional()
|
|
9
|
-
.describe(
|
|
14
|
+
.describe(AI_UUID_HINT +
|
|
15
|
+
`UUID of source element to drag from. Either sourceElementUUID or sourceX+sourceY must be provided.`),
|
|
10
16
|
sourceX: z
|
|
11
17
|
.number()
|
|
12
18
|
.int()
|
|
@@ -21,7 +27,8 @@ const dragAndDropSchema = z.object({
|
|
|
21
27
|
.describe('Source Y coordinate. Required if sourceElementUUID is not provided.'),
|
|
22
28
|
targetElementUUID: elementUUIDScheme
|
|
23
29
|
.optional()
|
|
24
|
-
.describe(
|
|
30
|
+
.describe(AI_UUID_HINT +
|
|
31
|
+
`UUID of target element to drop on. Either targetElementUUID or targetX+targetY must be provided.`),
|
|
25
32
|
targetX: z
|
|
26
33
|
.number()
|
|
27
34
|
.int()
|
|
@@ -71,14 +78,22 @@ export default function dragAndDrop(server) {
|
|
|
71
78
|
return resolved.result;
|
|
72
79
|
}
|
|
73
80
|
const { driver } = resolved;
|
|
81
|
+
if ((args.sourceElementUUID &&
|
|
82
|
+
isAiElementUUID(args.sourceElementUUID) &&
|
|
83
|
+
!isAIEnabled()) ||
|
|
84
|
+
(args.targetElementUUID &&
|
|
85
|
+
isAiElementUUID(args.targetElementUUID) &&
|
|
86
|
+
!isAIEnabled())) {
|
|
87
|
+
return aiDisabledResult();
|
|
88
|
+
}
|
|
74
89
|
try {
|
|
75
|
-
const source = await resolvePoint(driver, args.sourceElementUUID, args.sourceX, args.sourceY);
|
|
90
|
+
const source = await resolvePoint(driver, args.sourceElementUUID, args.sourceX, args.sourceY, 'source');
|
|
76
91
|
if ('error' in source) {
|
|
77
|
-
return errorResult(
|
|
92
|
+
return errorResult(source.error);
|
|
78
93
|
}
|
|
79
|
-
const target = await resolvePoint(driver, args.targetElementUUID, args.targetX, args.targetY);
|
|
94
|
+
const target = await resolvePoint(driver, args.targetElementUUID, args.targetX, args.targetY, 'target');
|
|
80
95
|
if ('error' in target) {
|
|
81
|
-
return errorResult(
|
|
96
|
+
return errorResult(target.error);
|
|
82
97
|
}
|
|
83
98
|
const { width, height } = await getWindowRect(driver);
|
|
84
99
|
if (source.x < 0 ||
|
|
@@ -124,16 +139,25 @@ export default function dragAndDrop(server) {
|
|
|
124
139
|
},
|
|
125
140
|
});
|
|
126
141
|
}
|
|
127
|
-
async function resolvePoint(driver, uuid, x, y) {
|
|
142
|
+
async function resolvePoint(driver, uuid, x, y, role) {
|
|
128
143
|
if (uuid) {
|
|
129
|
-
|
|
144
|
+
// ai-element UUIDs are coordinates, not real element ids — resolve via
|
|
145
|
+
// the shared helper (bbox centre for AI, getElementRect for real elements).
|
|
146
|
+
const rect = await resolveTargetRect(driver, uuid);
|
|
147
|
+
if ('error' in rect) {
|
|
148
|
+
return rect;
|
|
149
|
+
}
|
|
130
150
|
return {
|
|
131
151
|
x: Math.floor(rect.x + rect.width / 2),
|
|
132
152
|
y: Math.floor(rect.y + rect.height / 2),
|
|
133
153
|
};
|
|
134
154
|
}
|
|
135
155
|
if (x === undefined || y === undefined) {
|
|
136
|
-
return {
|
|
156
|
+
return {
|
|
157
|
+
error: role === 'source'
|
|
158
|
+
? 'drag_and_drop requires either sourceElementUUID, or both sourceX and sourceY.'
|
|
159
|
+
: 'drag_and_drop requires either targetElementUUID, or both targetX and targetY.',
|
|
160
|
+
};
|
|
137
161
|
}
|
|
138
162
|
return { x, y };
|
|
139
163
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drag-and-drop.js","sourceRoot":"","sources":["../../../src/tools/gestures/drag-and-drop.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"drag-and-drop.js","sourceRoot":"","sources":["../../../src/tools/gestures/drag-and-drop.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,WAAW,EACX,aAAa,EACb,UAAU,EACV,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAElC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC,MAAM,YAAY,GAAG,WAAW,EAAE;IAChC,CAAC,CAAC,oFAAoF;IACtF,CAAC,CAAC,EAAE,CAAC;AAEP,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,iBAAiB,EAAE,iBAAiB;SACjC,QAAQ,EAAE;SACV,QAAQ,CACP,YAAY;QACV,oGAAoG,CACvG;IACH,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,EAAE;SACV,QAAQ,CACP,qEAAqE,CACtE;IACH,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,EAAE;SACV,QAAQ,CACP,qEAAqE,CACtE;IACH,iBAAiB,EAAE,iBAAiB;SACjC,QAAQ,EA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CAAC,CAAC,+EAA+E;SACtF,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAClB,CAAC"}
|
package/package.json
CHANGED
package/server.json
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
"name": "io.github.appium/appium-mcp",
|
|
4
4
|
"title": "MCP Appium - Mobile Development and Automation Server",
|
|
5
5
|
"description": "MCP server for Appium mobile automation on iOS and Android devices with test creation tools.",
|
|
6
|
-
"version": "1.79.
|
|
6
|
+
"version": "1.79.1",
|
|
7
7
|
"packages": [
|
|
8
8
|
{
|
|
9
9
|
"registryType": "npm",
|
|
10
10
|
"identifier": "appium-mcp",
|
|
11
|
-
"version": "1.79.
|
|
11
|
+
"version": "1.79.1",
|
|
12
12
|
"transport": {
|
|
13
13
|
"type": "stdio"
|
|
14
14
|
}
|
|
Binary file
|
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
import type { ContentResult, FastMCP } from 'fastmcp';
|
|
2
|
+
import type { DriverInstance } from '../../session-store.js';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
import { elementUUIDScheme } from '../../schema.js';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
getWindowRect,
|
|
7
|
-
performActions,
|
|
8
|
-
} from '../../command.js';
|
|
5
|
+
import { getWindowRect, performActions } from '../../command.js';
|
|
6
|
+
import { isAIEnabled } from '../ai/config.js';
|
|
9
7
|
import {
|
|
10
8
|
errorResult,
|
|
11
9
|
resolveDriver,
|
|
12
10
|
textResult,
|
|
13
11
|
toolErrorMessage,
|
|
14
12
|
} from '../tool-response.js';
|
|
15
|
-
import
|
|
13
|
+
import {
|
|
14
|
+
aiDisabledResult,
|
|
15
|
+
isAiElementUUID,
|
|
16
|
+
resolveTargetRect,
|
|
17
|
+
} from './handlers/ai-element.js';
|
|
16
18
|
|
|
17
19
|
const DROP_PAUSE_DURATION_MS = 150;
|
|
18
20
|
|
|
21
|
+
const AI_UUID_HINT = isAIEnabled()
|
|
22
|
+
? `Supports AI coordinate UUIDs (format: ai-element:x,y:bbox) returned by appium_ai. `
|
|
23
|
+
: '';
|
|
24
|
+
|
|
19
25
|
const dragAndDropSchema = z.object({
|
|
20
26
|
sourceElementUUID: elementUUIDScheme
|
|
21
27
|
.optional()
|
|
22
28
|
.describe(
|
|
23
|
-
|
|
29
|
+
AI_UUID_HINT +
|
|
30
|
+
`UUID of source element to drag from. Either sourceElementUUID or sourceX+sourceY must be provided.`
|
|
24
31
|
),
|
|
25
32
|
sourceX: z
|
|
26
33
|
.number()
|
|
@@ -41,7 +48,8 @@ const dragAndDropSchema = z.object({
|
|
|
41
48
|
targetElementUUID: elementUUIDScheme
|
|
42
49
|
.optional()
|
|
43
50
|
.describe(
|
|
44
|
-
|
|
51
|
+
AI_UUID_HINT +
|
|
52
|
+
`UUID of target element to drop on. Either targetElementUUID or targetX+targetY must be provided.`
|
|
45
53
|
),
|
|
46
54
|
targetX: z
|
|
47
55
|
.number()
|
|
@@ -106,28 +114,37 @@ export default function dragAndDrop(server: FastMCP): void {
|
|
|
106
114
|
}
|
|
107
115
|
const { driver } = resolved;
|
|
108
116
|
|
|
117
|
+
if (
|
|
118
|
+
(args.sourceElementUUID &&
|
|
119
|
+
isAiElementUUID(args.sourceElementUUID) &&
|
|
120
|
+
!isAIEnabled()) ||
|
|
121
|
+
(args.targetElementUUID &&
|
|
122
|
+
isAiElementUUID(args.targetElementUUID) &&
|
|
123
|
+
!isAIEnabled())
|
|
124
|
+
) {
|
|
125
|
+
return aiDisabledResult();
|
|
126
|
+
}
|
|
127
|
+
|
|
109
128
|
try {
|
|
110
129
|
const source = await resolvePoint(
|
|
111
130
|
driver,
|
|
112
131
|
args.sourceElementUUID,
|
|
113
132
|
args.sourceX,
|
|
114
|
-
args.sourceY
|
|
133
|
+
args.sourceY,
|
|
134
|
+
'source'
|
|
115
135
|
);
|
|
116
136
|
if ('error' in source) {
|
|
117
|
-
return errorResult(
|
|
118
|
-
'drag_and_drop requires either sourceElementUUID, or both sourceX and sourceY.'
|
|
119
|
-
);
|
|
137
|
+
return errorResult(source.error);
|
|
120
138
|
}
|
|
121
139
|
const target = await resolvePoint(
|
|
122
140
|
driver,
|
|
123
141
|
args.targetElementUUID,
|
|
124
142
|
args.targetX,
|
|
125
|
-
args.targetY
|
|
143
|
+
args.targetY,
|
|
144
|
+
'target'
|
|
126
145
|
);
|
|
127
146
|
if ('error' in target) {
|
|
128
|
-
return errorResult(
|
|
129
|
-
'drag_and_drop requires either targetElementUUID, or both targetX and targetY.'
|
|
130
|
-
);
|
|
147
|
+
return errorResult(target.error);
|
|
131
148
|
}
|
|
132
149
|
|
|
133
150
|
const { width, height } = await getWindowRect(driver);
|
|
@@ -193,17 +210,28 @@ async function resolvePoint(
|
|
|
193
210
|
driver: DriverInstance,
|
|
194
211
|
uuid: string | undefined,
|
|
195
212
|
x: number | undefined,
|
|
196
|
-
y: number | undefined
|
|
213
|
+
y: number | undefined,
|
|
214
|
+
role: 'source' | 'target'
|
|
197
215
|
): Promise<{ x: number; y: number } | { error: string }> {
|
|
198
216
|
if (uuid) {
|
|
199
|
-
|
|
217
|
+
// ai-element UUIDs are coordinates, not real element ids — resolve via
|
|
218
|
+
// the shared helper (bbox centre for AI, getElementRect for real elements).
|
|
219
|
+
const rect = await resolveTargetRect(driver, uuid);
|
|
220
|
+
if ('error' in rect) {
|
|
221
|
+
return rect;
|
|
222
|
+
}
|
|
200
223
|
return {
|
|
201
224
|
x: Math.floor(rect.x + rect.width / 2),
|
|
202
225
|
y: Math.floor(rect.y + rect.height / 2),
|
|
203
226
|
};
|
|
204
227
|
}
|
|
205
228
|
if (x === undefined || y === undefined) {
|
|
206
|
-
return {
|
|
229
|
+
return {
|
|
230
|
+
error:
|
|
231
|
+
role === 'source'
|
|
232
|
+
? 'drag_and_drop requires either sourceElementUUID, or both sourceX and sourceY.'
|
|
233
|
+
: 'drag_and_drop requires either targetElementUUID, or both targetX and targetY.',
|
|
234
|
+
};
|
|
207
235
|
}
|
|
208
236
|
return { x, y };
|
|
209
237
|
}
|