create_profile
Create a new persistent browser profile for AI agents to maintain session data and preferences across automation tasks.
Instructions
Creates a new persistent Hyperbrowser profile.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/create-profile.ts:12-56 (handler)The handler function that executes the create_profile tool. It retrieves an API key from auth info, gets a client instance, calls client.profiles.create() to create a new profile, and returns the profile ID or an error message.
export async function createProfileTool( params: {}, extra: RequestHandlerExtra<ServerRequest, ServerNotification> ): Promise<CallToolResult> { let apiKey: string | undefined = undefined; if (extra.authInfo && extra.authInfo.extra?.isSSE) { apiKey = extra.authInfo.token; // You can use extra.authInfo here } try { const client = await getClient({ hbApiKey: apiKey }); // Get client instance // Call the SDK create method const response = await client.profiles.create(); // response is { id: string } // Return success with the profile ID return { content: [ { type: "text", text: JSON.stringify(response, null, 2), }, ], isError: false, }; } catch (error: any) { let errorMessage = "An unknown error occurred while creating the profile."; // Check if it's a specific Hyperbrowser SDK error if (error instanceof HyperbrowserError) { errorMessage = `Failed to create profile: ${error.message} (Status: ${ error.statusCode || "N/A" })`; } else if (error instanceof Error) { errorMessage = `Failed to create profile: ${error.message}`; } // Return error result return { content: [{ type: "text", text: errorMessage }], isError: true, }; } } - src/transports/setup_server.ts:125-130 (registration)Registers the create_profile tool with the MCP server, using the exported name, description, an empty parameter schema object, and the handler function.
server.tool( createProfileToolName, createProfileToolDescription, {}, // createProfileToolParamSchemaRaw is just an empty object createProfileTool ); - src/tools/create-profile.ts:58-62 (helper)Exports the tool name 'create_profile' and its description for use in registration.
// Export name and description separately for registration export const createProfileToolName = "create_profile"; export const createProfileToolDescription = "Creates a new persistent Hyperbrowser profile.";