You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add element verification to open_application and navigate_browser
- Add verify_element_exists, verify_element_not_exists, verify_timeout_ms to OpenApplicationArgs
- Add verification fields to NavigateBrowserArgs
- Make verify_timeout_ms optional (Option<u64>) across all tools for backwards compatibility
- Add post-action verification logic to both open_application and navigate_browser implementations
- All verification timeouts default to 2000ms if not specified
All tools now have consistent optional verification fields with sensible defaults.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Copy file name to clipboardExpand all lines: crates/terminator-mcp-agent/src/server.rs
+126-4Lines changed: 126 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -2419,7 +2419,7 @@ Note: Curly brace format (e.g., '{Tab}') is more reliable than plain format (e.g
2419
2419
// POST-ACTION VERIFICATION
2420
2420
let verify_exists = args.verify_element_exists.clone();
2421
2421
let verify_not_exists = args.verify_element_not_exists.clone();
2422
-
let verify_timeout_ms = args.verify_timeout_ms;
2422
+
let verify_timeout_ms = args.verify_timeout_ms.unwrap_or(2000);
2423
2423
2424
2424
let skip_verification = verify_exists.is_empty() && verify_not_exists.is_empty();
2425
2425
@@ -4505,9 +4505,9 @@ Set include_logs: true to capture stdout/stderr output. Default is false for cle
4505
4505
}
4506
4506
4507
4507
#[tool(
4508
-
description = "Opens a URL in the specified browser (uses SDK's built-in browser automation). This is the RECOMMENDED method for browser navigation - more reliable than manually manipulating the address bar with keyboard/mouse actions. Handles page loading, waiting, and error recovery automatically."
4508
+
description = "Opens a URL in the specified browser (uses SDK's built-in browser automation). This is the RECOMMENDED method for browser navigation - more reliable than manually manipulating the address bar with keyboard/mouse actions. Handles page loading, waiting, and error recovery automatically. Requires verify_element_exists and verify_element_not_exists parameters (use empty string \"\" to skip verification)."
4509
4509
)]
4510
-
asyncfnnavigate_browser(
4510
+
pubasyncfnnavigate_browser(
4511
4511
&self,
4512
4512
Parameters(args):Parameters<NavigateBrowserArgs>,
4513
4513
) -> Result<CallToolResult,McpError>{
@@ -4567,6 +4567,67 @@ Set include_logs: true to capture stdout/stderr output. Default is false for cle
4567
4567
)
4568
4568
.await;
4569
4569
4570
+
// POST-ACTION VERIFICATION
4571
+
if !args.verify_element_exists.is_empty() || !args.verify_element_not_exists.is_empty(){
4572
+
let verify_exists_opt = if args.verify_element_exists.is_empty(){
4573
+
None
4574
+
}else{
4575
+
Some(args.verify_element_exists.as_str())
4576
+
};
4577
+
let verify_not_exists_opt = if args.verify_element_not_exists.is_empty(){
@@ -4582,7 +4643,7 @@ Set include_logs: true to capture stdout/stderr output. Default is false for cle
4582
4643
))
4583
4644
}
4584
4645
4585
-
#[tool(description = "Opens an application by name (uses SDK's built-in app launcher).")]
4646
+
#[tool(description = "Opens an application by name (uses SDK's built-in app launcher). Requires verify_element_exists and verify_element_not_exists parameters (use empty string \"\" to skip verification).")]
4586
4647
pubasyncfnopen_application(
4587
4648
&self,
4588
4649
Parameters(args):Parameters<OpenApplicationArgs>,
@@ -4660,6 +4721,67 @@ Set include_logs: true to capture stdout/stderr output. Default is false for cle
4660
4721
}
4661
4722
}
4662
4723
4724
+
// POST-ACTION VERIFICATION
4725
+
if !args.verify_element_exists.is_empty() || !args.verify_element_not_exists.is_empty(){
4726
+
let verify_exists_opt = if args.verify_element_exists.is_empty(){
4727
+
None
4728
+
}else{
4729
+
Some(args.verify_element_exists.as_str())
4730
+
};
4731
+
let verify_not_exists_opt = if args.verify_element_not_exists.is_empty(){
Copy file name to clipboardExpand all lines: crates/terminator-mcp-agent/src/utils.rs
+34-4Lines changed: 34 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -171,9 +171,8 @@ pub struct ActionOptions {
171
171
pubverify_element_not_exists:String,
172
172
173
173
#[schemars(
174
-
description = "Timeout in milliseconds for post-action verification. The system will poll until verification passes or timeout is reached. Defaults to 2000ms."
174
+
description = "Timeout in milliseconds for post-action verification. The system will poll until verification passes or timeout is reached. Defaults to 2000ms if not specified."
175
175
)]
176
-
#[serde(default)]
177
176
pubverify_timeout_ms:Option<u64>,
178
177
}
179
178
@@ -596,9 +595,9 @@ pub struct GlobalKeyArgs {
596
595
pubverify_element_not_exists:String,
597
596
598
597
#[schemars(
599
-
description = "REQUIRED: Timeout in milliseconds for post-action verification. The system will poll until verification passes or timeout is reached."
598
+
description = "Timeout in milliseconds for post-action verification. The system will poll until verification passes or timeout is reached. Defaults to 2000ms if not specified."
description = "Browser process name (e.g., 'chrome', 'msedge', 'firefox'). Will start the browser if not running."
782
781
)]
783
782
pubprocess:String,
783
+
784
+
#[schemars(
785
+
description = "REQUIRED: Selector that should exist after navigation completes. Used to verify the page loaded successfully. Use empty string \"\" to skip this check."
786
+
)]
787
+
pubverify_element_exists:String,
788
+
789
+
#[schemars(
790
+
description = "REQUIRED: Selector that should NOT exist after navigation completes. Use empty string \"\" to skip this check."
791
+
)]
792
+
pubverify_element_not_exists:String,
793
+
794
+
#[schemars(
795
+
description = "Timeout in milliseconds for post-action verification. The system will poll until verification passes or timeout is reached. Defaults to 2000ms if not specified."
#[schemars(description = "Name of the application to open")]
821
836
pubapp_name:String,
822
837
838
+
#[schemars(
839
+
description = "REQUIRED: Selector that should exist after the application opens. Used to verify the app loaded successfully (e.g., 'process:notepad|role:Document'). Use empty string \"\" to skip this check."
840
+
)]
841
+
pubverify_element_exists:String,
842
+
843
+
#[schemars(
844
+
description = "REQUIRED: Selector that should NOT exist after the application opens. Use empty string \"\" to skip this check."
845
+
)]
846
+
pubverify_element_not_exists:String,
847
+
848
+
#[schemars(
849
+
description = "Timeout in milliseconds for post-action verification. The system will poll until verification passes or timeout is reached. Defaults to 2000ms if not specified."
0 commit comments