@@ -5,36 +5,86 @@ async function testBrowserMCPTools() {
5
5
console . log ( '============================' ) ;
6
6
await codebolt . waitForConnection ( ) ;
7
7
try {
8
- // 1. browser_navigate
9
- try {
10
- const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'browser_navigate' , { url : 'https://example.com' } ) ;
11
- console . log ( '✅ browser_navigate:' , result ?. success , 'URL:' , result ?. currentUrl ) ;
12
- } catch ( e ) { console . log ( '⚠️ browser_navigate failed:' , e . message ) ; }
13
- // 2. browser_click
14
- try {
15
- const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'browser_click' , { selector : 'body' } ) ;
16
- console . log ( '✅ browser_click:' , result ?. success ) ;
17
- } catch ( e ) { console . log ( '⚠️ browser_click failed:' , e . message ) ; }
18
- // 3. browser_type
19
- try {
20
- const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'browser_type' , { selector : 'input' , text : 'test' } ) ;
21
- console . log ( '✅ browser_type:' , result ?. success ) ;
22
- } catch ( e ) { console . log ( '⚠️ browser_type failed:' , e . message ) ; }
23
- // 4. browser_screenshot
24
- try {
25
- const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'browser_screenshot' , { fullPage : true } ) ;
26
- console . log ( '✅ browser_screenshot:' , result ?. success , 'Screenshot:' , ! ! result ?. screenshot ) ;
27
- } catch ( e ) { console . log ( '⚠️ browser_screenshot failed:' , e . message ) ; }
28
- // 5. browser_get_content
29
- try {
30
- const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'browser_get_content' , { } ) ;
31
- console . log ( '✅ browser_get_content:' , result ?. success , 'Content:' , ! ! result ?. content ) ;
32
- } catch ( e ) { console . log ( '⚠️ browser_get_content failed:' , e . message ) ; }
33
- // 6. browser_scroll
34
- try {
35
- const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'browser_scroll' , { direction : 'down' , amount : 100 } ) ;
36
- console . log ( '✅ browser_scroll:' , result ?. success ) ;
37
- } catch ( e ) { console . log ( '⚠️ browser_scroll failed:' , e . message ) ; }
8
+ // 1. navigate
9
+ try {
10
+ const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'navigate' , { url : 'https://example.com' } ) ;
11
+ console . log ( '✅ navigate:' , result ?. success , 'URL:' , result ?. currentUrl ) ;
12
+ } catch ( e ) { console . log ( '⚠️ navigate failed:' , e . message ) ; }
13
+ // 2. click
14
+ try {
15
+ const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'click' , { selector : 'body' } ) ;
16
+ console . log ( '✅ click:' , result ?. success ) ;
17
+ } catch ( e ) { console . log ( '⚠️ click failed:' , e . message ) ; }
18
+ // 3. type
19
+ try {
20
+ const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'type' , { selector : 'input' , text : 'test' } ) ;
21
+ console . log ( '✅ type:' , result ?. success ) ;
22
+ } catch ( e ) { console . log ( '⚠️ type failed:' , e . message ) ; }
23
+ // 4. screenshot
24
+ try {
25
+ const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'screenshot' , { fullPage : true } ) ;
26
+ console . log ( '✅ screenshot:' , result ?. success , 'Screenshot:' , ! ! result ?. screenshot ) ;
27
+ } catch ( e ) { console . log ( '⚠️ screenshot failed:' , e . message ) ; }
28
+ // 5. get_content
29
+ try {
30
+ const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'get_content' , { } ) ;
31
+ console . log ( '✅ get_content:' , result ?. success , 'Content:' , ! ! result ?. content ) ;
32
+ } catch ( e ) { console . log ( '⚠️ get_content failed:' , e . message ) ; }
33
+ // 6. scroll
34
+ try {
35
+ const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'scroll' , { direction : 'down' , amount : 100 } ) ;
36
+ console . log ( '✅ scroll:' , result ?. success ) ;
37
+ } catch ( e ) { console . log ( '⚠️ scroll failed:' , e . message ) ; }
38
+ // 7. new_page
39
+ try {
40
+ const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'new_page' , { } ) ;
41
+ console . log ( '✅ new_page:' , result ?. success ) ;
42
+ } catch ( e ) { console . log ( '⚠️ new_page failed:' , e . message ) ; }
43
+ // 8. get_url
44
+ try {
45
+ const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'get_url' , { } ) ;
46
+ console . log ( '✅ get_url:' , result ?. success , 'URL:' , result ?. url ) ;
47
+ } catch ( e ) { console . log ( '⚠️ get_url failed:' , e . message ) ; }
48
+ // 9. get_html
49
+ try {
50
+ const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'get_html' , { } ) ;
51
+ console . log ( '✅ get_html:' , result ?. success , 'HTML Length:' , result ?. html ?. length ) ;
52
+ } catch ( e ) { console . log ( '⚠️ get_html failed:' , e . message ) ; }
53
+ // 10. get_markdown
54
+ try {
55
+ const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'get_markdown' , { } ) ;
56
+ console . log ( '✅ get_markdown:' , result ?. success , 'Markdown Length:' , result ?. markdown ?. length ) ;
57
+ } catch ( e ) { console . log ( '⚠️ get_markdown failed:' , e . message ) ; }
58
+ // 11. extract_text
59
+ try {
60
+ const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'extract_text' , { } ) ;
61
+ console . log ( '✅ extract_text:' , result ?. success , 'Text Length:' , result ?. text ?. length ) ;
62
+ } catch ( e ) { console . log ( '⚠️ extract_text failed:' , e . message ) ; }
63
+ // 12. get_snapshot
64
+ try {
65
+ const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'get_snapshot' , { } ) ;
66
+ console . log ( '✅ get_snapshot:' , result ?. success ) ;
67
+ } catch ( e ) { console . log ( '⚠️ get_snapshot failed:' , e . message ) ; }
68
+ // 13. get_info
69
+ try {
70
+ const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'get_info' , { } ) ;
71
+ console . log ( '✅ get_info:' , result ?. success , 'Info:' , result ?. info ) ;
72
+ } catch ( e ) { console . log ( '⚠️ get_info failed:' , e . message ) ; }
73
+ // 14. search
74
+ try {
75
+ const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'search' , { selector : 'input' , query : 'test query' } ) ;
76
+ console . log ( '✅ search:' , result ?. success ) ;
77
+ } catch ( e ) { console . log ( '⚠️ search failed:' , e . message ) ; }
78
+ // 15. enter
79
+ try {
80
+ const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'enter' , { } ) ;
81
+ console . log ( '✅ enter:' , result ?. success ) ;
82
+ } catch ( e ) { console . log ( '⚠️ enter failed:' , e . message ) ; }
83
+ // 16. close
84
+ try {
85
+ const result = await codebolt . tools . executeTool ( 'codebolt.browser' , 'close' , { } ) ;
86
+ console . log ( '✅ close:' , result ?. success ) ;
87
+ } catch ( e ) { console . log ( '⚠️ close failed:' , e . message ) ; }
38
88
console . log ( '🎉 Browser MCP tools tests completed!' ) ;
39
89
} catch ( e ) {
40
90
console . error ( '❌ Browser MCP tools test error:' , e . message ) ;
0 commit comments