delete_profile
Remove a specific Hyperbrowser profile by its ID to manage user data and optimize storage within the AI-driven browser automation platform.
Instructions
Deletes an existing persistent Hyperbrowser profile.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| profileId | Yes | ID of the profile to delete |
Implementation Reference
- src/tools/delete-profile.ts:12-64 (handler)The handler function that executes the delete_profile tool logic. It takes a profileId, gets a Hyperbrowser client, calls client.profiles.delete(profileId), and returns success or error content.export async function deleteProfileTool( params: deleteProfileToolParamSchemaType, extra: RequestHandlerExtra<ServerRequest, ServerNotification> ): Promise<CallToolResult> { const { profileId } = params; // Destructure validated profileId 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 delete method await client.profiles.delete(profileId); // Return success return { content: [ { type: "text", text: `Successfully deleted profile with ID: ${profileId}`, }, ], isError: false, }; } catch (error: any) { let errorMessage = `An unknown error occurred while deleting profile ${profileId}.`; let isError = true; // Check if it's a specific Hyperbrowser SDK error if (error instanceof HyperbrowserError) { if (error.statusCode === 404) { errorMessage = `Profile with ID ${profileId} not found.`; // Optionally, you might decide this isn't a true 'error' state for the tool // isError = false; // Depending on desired behavior } else { errorMessage = `Failed to delete profile ${profileId}: ${ error.message } (Status: ${error.statusCode || "N/A"})`; } } else if (error instanceof Error) { errorMessage = `Failed to delete profile ${profileId}: ${error.message}`; } // Return error result return { content: [{ type: "text", text: errorMessage }], isError: isError, }; } }
- src/tools/tool-types.ts:266-276 (schema)Zod schema definition for delete_profile tool parameters, including profileId as a required string.export const deleteProfileToolParamSchemaRaw = { profileId: z.string().describe("ID of the profile to delete"), }; export const deleteProfileToolParamSchema = z.object( deleteProfileToolParamSchemaRaw ); export type deleteProfileToolParamSchemaType = z.infer< typeof deleteProfileToolParamSchema >;
- src/transports/setup_server.ts:132-136 (registration)Registration of the delete_profile tool on the MCP server using server.tool() with name, description, param schema, and handler.deleteProfileToolName, deleteProfileToolDescription, deleteProfileToolParamSchemaRaw, deleteProfileTool );
- src/tools/delete-profile.ts:67-70 (registration)Exports the tool name and description used for registration.export const deleteProfileToolName = "delete_profile"; export const deleteProfileToolDescription = "Deletes an existing persistent Hyperbrowser profile.";