list_profiles
Retrieve existing Hyperbrowser profiles with pagination options to manage browser automation sessions efficiently.
Instructions
Lists existing persistent Hyperbrowser profiles, with optional pagination.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Page number for pagination (optional) | |
| limit | No | Number of profiles per page (optional) |
Implementation Reference
- src/tools/list-profiles.ts:12-58 (handler)The handler function that executes the list_profiles tool logic, fetching profiles from Hyperbrowser API with pagination.
export async function listProfilesTool( params: listProfilesToolParamSchemaType, extra: RequestHandlerExtra<ServerRequest, ServerNotification> ): Promise<CallToolResult> { const { page, limit } = params; // Destructure validated optional params let apiKey: string | undefined = undefined; if (extra.authInfo && extra.authInfo.extra?.isSSE) { apiKey = extra.authInfo.token; } try { const client = await getClient({ hbApiKey: apiKey }); // Get client instance // Call the SDK list method with optional parameters const response = await client.profiles.list({ page, limit }); // Return the list of profiles and pagination info return { content: [ { type: "text", // response contains { profiles: ProfileResponse[], totalCount, page, perPage } text: JSON.stringify(response, null, 2), }, ], isError: false, }; } catch (error: any) { let errorMessage = "An unknown error occurred while listing profiles."; // Check if it's a specific Hyperbrowser SDK error if (error instanceof HyperbrowserError) { errorMessage = `Failed to list profiles: ${error.message} (Status: ${ error.statusCode || "N/A" })`; } else if (error instanceof Error) { errorMessage = `Failed to list profiles: ${error.message}`; } // Return error result return { content: [{ type: "text", text: errorMessage }], isError: true, }; } } - src/tools/tool-types.ts:280-291 (schema)Zod schema definition for list_profiles tool parameters (page and limit).
export const listProfilesToolParamSchemaRaw = { page: z.number().int().positive().optional().describe("Page number for pagination (optional)"), limit: z.number().int().positive().optional().describe("Number of profiles per page (optional)"), }; export const listProfilesToolParamSchema = z.object( listProfilesToolParamSchemaRaw ); export type listProfilesToolParamSchemaType = z.infer< typeof listProfilesToolParamSchema >; - src/transports/setup_server.ts:138-142 (registration)Registration of the list_profiles tool in the MCP server using server.tool() with name, description, schema, and handler.
listProfilesToolName, listProfilesToolDescription, listProfilesToolParamSchemaRaw, listProfilesTool ); - src/transports/setup_server.ts:66-69 (registration)Import of list_profiles tool components (handler, description, name) in setup_server.
listProfilesTool, listProfilesToolDescription, listProfilesToolName, } from "../tools/list-profiles"; - src/transports/setup_server.ts:72-74 (schema)Import of listProfilesToolParamSchemaRaw schema for registration.
deleteProfileToolParamSchemaRaw, listProfilesToolParamSchemaRaw, } from "../tools/tool-types";