execute_browserql
Execute GraphQL queries for browser automation tasks like web scraping, content extraction, and performance audits using Browserless.io.
Instructions
Execute BrowserQL GraphQL queries
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| variables | No |
Implementation Reference
- src/index.ts:490-509 (handler)MCP CallToolRequest handler for 'execute_browserql' that validates arguments, calls BrowserlessClient.executeBrowserQL, and formats the response as MCP content.
case 'execute_browserql': { if (!args) throw new Error('Arguments are required'); const result = await this.client!.executeBrowserQL(args as any); if (result.success && result.data) { return { content: [ { type: 'text', text: 'BrowserQL query executed successfully.', }, { type: 'text', text: JSON.stringify(result.data, null, 2), }, ], }; } else { throw new Error(result.error || 'Failed to execute BrowserQL query'); } } - src/client.ts:217-228 (helper)BrowserlessClient method implementing the core logic: sends POST request to Browserless /chromium/bql endpoint with the BrowserQL query and variables.
async executeBrowserQL(request: BrowserQLRequest): Promise<BrowserlessResponse<BrowserQLResponse>> { try { const response: AxiosResponse<BrowserQLResponse> = await this.httpClient.post('/chromium/bql', request); return { success: true, data: response.data, }; } catch (error) { return this.handleError(error); } } - src/index.ts:206-217 (registration)Tool registration in ListToolsRequestHandler, defining name, description, and input schema for execute_browserql.
{ name: 'execute_browserql', description: 'Execute BrowserQL GraphQL queries', inputSchema: { type: 'object', properties: { query: { type: 'string' }, variables: { type: 'object' }, }, required: ['query'], }, }, - src/types.ts:226-231 (schema)Zod schema and TypeScript type definition for BrowserQLRequest (input validation).
export const BrowserQLRequestSchema = z.object({ query: z.string(), variables: z.record(z.any()).optional(), }); export type BrowserQLRequest = z.infer<typeof BrowserQLRequestSchema>; - src/types.ts:305-308 (schema)TypeScript interface for BrowserQLResponse (output type).
export interface BrowserQLResponse { data: any; errors?: any[]; }