@@ -12,7 +12,7 @@ import {defineTool} from '../ToolDefinition.js';
1212
1313export const screenshot = defineTool ( {
1414 name : 'screenshot' ,
15- description : `Take a screenshot of the active page. ` ,
15+ description : `Takes a screenshot` ,
1616 annotations : {
1717 category : ToolCategory . DEBUGGING ,
1818 // Not read-only due to filePath param.
@@ -32,13 +32,13 @@ export const screenshot = defineTool({
3232
3333export const navigate = defineTool ( {
3434 name : 'navigate' ,
35- description : `Load URL in the browser ` ,
35+ description : `Loads a URL ` ,
3636 annotations : {
3737 category : ToolCategory . NAVIGATION ,
3838 readOnlyHint : false ,
3939 } ,
4040 schema : {
41- url : zod . string ( ) . describe ( 'Page URL' ) ,
41+ url : zod . string ( ) . describe ( 'URL to navigate to ' ) ,
4242 } ,
4343 handler : async ( request , response , context ) => {
4444 const page = context . getSelectedPage ( ) ;
@@ -68,29 +68,21 @@ export const navigate = defineTool({
6868
6969export const evaluate = defineTool ( {
7070 name : 'evaluate' ,
71- description : `Evaluate a JavaScript function on the last loaded page ` ,
71+ description : `Evaluates a JavaScript script ` ,
7272 annotations : {
7373 category : ToolCategory . DEBUGGING ,
7474 readOnlyHint : false ,
7575 } ,
7676 schema : {
77- fn : zod
78- . string ( )
79- . describe ( `A JavaScript function to be executed on the active page` ) ,
77+ script : zod . string ( ) . describe ( `JS script to run on the page` ) ,
8078 } ,
8179 handler : async ( request , response , context ) => {
8280 const page = context . getSelectedPage ( ) ;
83- const fn = await page . evaluateHandle ( `(${ request . params . fn } )` ) ;
8481 try {
85- const result = await page . evaluate ( async fn => {
86- // @ts -expect-error no types.
87- return JSON . stringify ( await fn ( ) ) ;
88- } , fn ) ;
89- response . appendResponseLine ( result ) ;
82+ const result = await page . evaluate ( request . params . script ) ;
83+ response . appendResponseLine ( JSON . stringify ( result ) ) ;
9084 } catch ( err ) {
9185 response . appendResponseLine ( String ( err . message ) ) ;
92- } finally {
93- void fn . dispose ( ) ;
9486 }
9587 } ,
9688} ) ;
0 commit comments