UNPKG

@mseep/hyperbrowser-mcp

Version:

Hyperbrowser Model Context Protocol Server

47 lines (46 loc) 1.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.extractStructuredDataToolDescription = exports.extractStructuredDataToolName = exports.extractStructuredDataTool = void 0; const utils_1 = require("../utils"); async function extractStructuredDataTool({ urls, sessionOptions, prompt, schema, }) { try { const client = await (0, utils_1.getClient)(); const params = { urls, sessionOptions, prompt, schema, }; const result = await client.extract.startAndWait(params); if (result.error) { return { isError: true, content: [ { type: "text", text: result.error, }, ], }; } const response = { content: [ { type: "text", text: JSON.stringify(result.data, null, 2), }, ], isError: false, }; return response; } catch (error) { return { content: [{ type: "text", text: `${error}` }], isError: true, }; } } exports.extractStructuredDataTool = extractStructuredDataTool; exports.extractStructuredDataToolName = "extract_structured_data"; exports.extractStructuredDataToolDescription = "Extract structured data from a webpage. This tool allows you to extract structured data from a webpage using a schema.";