Skip to content

Commit 92e0dc3

Browse files
committed
Fix text ui automation tool
1 parent 9a330d9 commit 92e0dc3

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

example_projects/iOS/MCPTest/ContentView.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ import SwiftUI
99
import OSLog
1010

1111
struct ContentView: View {
12-
@State private var text = "Hello, world!"
12+
@State private var text = ""
1313

1414
var body: some View {
1515
VStack {
1616
Image(systemName: "globe")
1717
.imageScale(.large)
1818
.foregroundStyle(.tint)
19+
TextField("Enter text", text: $text)
20+
.textFieldStyle(RoundedBorderTextFieldStyle())
21+
.padding(.horizontal)
1922
Text(text)
2023

2124
Button("Log something") {

src/tools/idb.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async function executeIdbCommand(
2929
): Promise<string> {
3030
let fullArgs: string[] = [];
3131

32-
const uiCommands = ['describe-all', 'describe-point', 'tap', 'swipe', 'key', 'press'];
32+
const uiCommands = ['describe-all', 'describe-point', 'tap', 'swipe', 'key', 'press', 'text'];
3333

3434
if (uiCommands.includes(commandName)) {
3535
fullArgs = ['ui', commandName, '--udid', simulatorUuid];
@@ -267,7 +267,7 @@ export function registerIdbTools(server: McpServer): void {
267267
// 3. tap
268268
server.tool(
269269
'tap',
270-
'Simulates a tap event at the specified (x, y) coordinates in the simulator.',
270+
'Simulates a tap event at the specified (x, y) coordinates in the simulator. Make sure to tap the center of the element you want to tap.',
271271
{
272272
simulatorUuid: z.string().uuid('Invalid Simulator UUID format'),
273273
x: z.number().int('X coordinate must be an integer'),
@@ -453,7 +453,7 @@ export function registerIdbTools(server: McpServer): void {
453453
// 6. type_text
454454
server.tool(
455455
'type_text',
456-
'Simulates typing the specified text into the simulator.',
456+
'Simulates typing the specified text into the simulator. Make sure to tap the center of the text field first to focus it.',
457457
{
458458
simulatorUuid: z.string().uuid('Invalid Simulator UUID format'),
459459
text: z.string().min(1, 'Text cannot be empty'),

0 commit comments

Comments
 (0)