UNPKG

@mseep/hyperbrowser-mcp

Version:

Hyperbrowser Model Context Protocol Server

45 lines (44 loc) 1.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createProfileToolDescription = exports.createProfileToolName = exports.createProfileTool = void 0; const utils_js_1 = require("../utils.js"); // Import getClient const sdk_1 = require("@hyperbrowser/sdk"); // Import SDK error type // The handler function receives no specific parameters for create // but we define it to match the expected signature by the server setup async function createProfileTool(params // No parameters expected based on schema ) { try { const client = await (0, utils_js_1.getClient)(); // 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) { let errorMessage = 'An unknown error occurred while creating the profile.'; // Check if it's a specific Hyperbrowser SDK error if (error instanceof sdk_1.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, }; } } exports.createProfileTool = createProfileTool; // Export name and description separately for registration exports.createProfileToolName = 'create_profile'; exports.createProfileToolDescription = 'Creates a new persistent Hyperbrowser profile.';