UNPKG

local-api-mcp-typescript

Version:

A Model Context Protocol server that AdsPower browser LocalAPI. This server enables LLMs to interact with start browser, create browser, update browser fingerprint config ...

188 lines (187 loc) 14.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.schemas = void 0; const zod_1 = require("zod"); // Proxy Config Schema const userProxyConfigSchema = zod_1.z.object({ proxy_soft: zod_1.z.enum([ 'brightdata', 'brightauto', 'oxylabsauto', '922S5auto', 'ipideeauto', 'ipfoxyauto', '922S5auth', 'kookauto', 'ssh', 'other', 'no_proxy' ]).describe('The proxy soft of the browser'), proxy_type: zod_1.z.enum(['http', 'https', 'socks5', 'no_proxy']).optional(), proxy_host: zod_1.z.string().optional().describe('The proxy host of the browser, eg: 127.0.0.1'), proxy_port: zod_1.z.string().optional().describe('The proxy port of the browser, eg: 8080'), proxy_user: zod_1.z.string().optional().describe('The proxy user of the browser, eg: user'), proxy_password: zod_1.z.string().optional().describe('The proxy password of the browser, eg: password'), proxy_url: zod_1.z.string().optional().describe('The proxy url of the browser, eg: http://127.0.0.1:8080'), global_config: zod_1.z.enum(['0', '1']).optional().describe('The global config of the browser, default is 0') }).describe('The user proxy config of the browser'); // Browser Kernel Config Schema const browserKernelConfigSchema = zod_1.z.object({ version: zod_1.z.union([ zod_1.z.literal("92"), zod_1.z.literal("99"), zod_1.z.literal("102"), zod_1.z.literal("105"), zod_1.z.literal("108"), zod_1.z.literal("111"), zod_1.z.literal("114"), zod_1.z.literal("115"), zod_1.z.literal("116"), zod_1.z.literal("117"), zod_1.z.literal("118"), zod_1.z.literal("119"), zod_1.z.literal("120"), zod_1.z.literal("121"), zod_1.z.literal("122"), zod_1.z.literal("123"), zod_1.z.literal("124"), zod_1.z.literal("125"), zod_1.z.literal("126"), zod_1.z.literal("127"), zod_1.z.literal("128"), zod_1.z.literal("129"), zod_1.z.literal("130"), zod_1.z.literal("131"), zod_1.z.literal("132"), zod_1.z.literal("133"), zod_1.z.literal("134"), zod_1.z.literal("ua_auto") ]).optional().describe('The version of the browser, default is ua_auto'), type: zod_1.z.enum(['chrome', 'firefox']).optional().describe('The type of the browser, default is chrome') }).optional().describe('The browser kernel config of the browser, default is version: ua_auto, type: chrome'); // Random UA Config Schema const randomUaConfigSchema = zod_1.z.object({ ua_version: zod_1.z.array(zod_1.z.string()).optional(), ua_system_version: zod_1.z.array(zod_1.z.enum([ 'Android 9', 'Android 10', 'Android 11', 'Android 12', 'Android 13', 'iOS 14', 'iOS 15', 'Windows 7', 'Windows 8', 'Windows 10', 'Windows 11', 'Mac OS X 10', 'Mac OS X 11', 'Mac OS X 12', 'Mac OS X 13', 'Linux' ])).optional().describe('The ua system version of the browser, eg: ["Android 9", "iOS 14"]') }).optional().describe('The random ua config of the browser, default is ua_version: [], ua_system_version: []'); // Fingerprint Config Schema const fingerprintConfigSchema = zod_1.z.object({ automatic_timezone: zod_1.z.enum(['0', '1']).optional().describe('The automatic timezone of the browser, default is 0'), timezone: zod_1.z.string().optional().describe('The timezone of the browser, eg: Asia/Shanghai'), language: zod_1.z.array(zod_1.z.string()).optional().describe('The language of the browser, eg: ["en-US", "zh-CN"]'), flash: zod_1.z.enum(['block', 'allow']).optional().describe('The flash of the browser, default is disabled'), fonts: zod_1.z.array(zod_1.z.string()).optional().describe('The fonts of the browser, eg: ["Arial", "Times New Roman"]'), webrtc: zod_1.z.enum(['disabled', 'forward', 'proxy', 'local']).optional().describe('The webrtc of the browser, default is disabled'), browser_kernel_config: browserKernelConfigSchema, random_ua: randomUaConfigSchema, tls_switch: zod_1.z.enum(['0', '1']).optional().describe('The tls switch of the browser, default is 0'), tls: zod_1.z.string().optional().describe('The tls of the browser, if tls_switch is 1, you can set the tls of the browser, eg: "0xC02C,0xC030"') }).optional().describe('The fingerprint config of the browser, default is automatic_timezone: 0, timezone: "", language: [], flash: "", fonts: [], webrtc: disabled, browser_kernel_config: ua_auto, random_ua: ua_version: [], ua_system_version: [], tls_switch: 0, tls: ""'); exports.schemas = { // Browser Related Schema createBrowserSchema: zod_1.z.object({ domainName: zod_1.z.string().optional().describe('The domain name of the browser, eg: facebook.com'), openUrls: zod_1.z.array(zod_1.z.string()).optional().describe('The open urls of the browser, eg: ["https://www.google.com"]'), cookie: zod_1.z.string().optional().describe('The cookie of the browser, eg: "[{\"domain\":\".baidu.com\",\"expirationDate\":\"\",\"name\":\"\",\"path\":\"/\",\"sameSite\":\"unspecified\",\"secure\":true,\"value\":\"\",\"id\":1}]"'), username: zod_1.z.string().optional().describe('The username of the browser, eg: "user"'), password: zod_1.z.string().optional().describe('The password of the browser, eg: "password"'), groupId: zod_1.z.string() .regex(/^\d+$/, "Group ID must be a numeric string") .describe('The group id of the browser, must be a numeric string (e.g., "123"). You can use the get-group-list tool to get the group list or create a new group, or default is 0'), name: zod_1.z.string().optional().describe('The name of the browser, eg: "My Browser"'), country: zod_1.z.string().optional().describe('The country of the browser, eg: "CN"'), sysAppCateId: zod_1.z.string().optional().describe('The sys app cate id of the browser, you can use the get-application-list tool to get the application list'), userProxyConfig: userProxyConfigSchema, fingerprintConfig: fingerprintConfigSchema, storageStrategy: zod_1.z.number().optional().describe('The storage strategy of the browser, default is 0') }), updateBrowserSchema: zod_1.z.object({ domainName: zod_1.z.string().optional().describe('The domain name of the browser, eg: facebook.com'), openUrls: zod_1.z.array(zod_1.z.string()).optional().describe('The open urls of the browser, eg: ["https://www.google.com"]'), cookie: zod_1.z.string().optional().describe('The cookie of the browser, eg: "[{\"domain\":\".baidu.com\",\"expirationDate\":\"\",\"name\":\"\",\"path\":\"/\",\"sameSite\":\"unspecified\",\"secure\":true,\"value\":\"\",\"id\":1}]"'), username: zod_1.z.string().optional().describe('The username of the browser, eg: "user"'), password: zod_1.z.string().optional().describe('The password of the browser, eg: "password"'), groupId: zod_1.z.string().optional().describe('The group id of the browser, must be a numeric string (e.g., "123"). You can use the get-group-list tool to get the group list or create a new group'), name: zod_1.z.string().optional().describe('The name of the browser, eg: "My Browser"'), country: zod_1.z.string().optional().describe('The country of the browser, eg: "CN"'), sysAppCateId: zod_1.z.string().optional().describe('The sys app cate id of the browser, you can use the get-application-list tool to get the application list'), userProxyConfig: userProxyConfigSchema.optional(), fingerprintConfig: fingerprintConfigSchema.optional(), storageStrategy: zod_1.z.number().optional().describe('The storage strategy of the browser, default is 0'), userId: zod_1.z.string().describe('The user id of the browser to update, it is required when you want to update the browser') }), openBrowserSchema: zod_1.z.object({ serialNumber: zod_1.z.string().optional().describe('The serial number of the browser to open'), userId: zod_1.z.string().optional().describe('The browser id of the browser to open'), ipTab: zod_1.z.enum(['0', '1']).optional().describe('The ip tab of the browser, 0 is not use ip tab, 1 is use ip tab, default is 0'), launchArgs: zod_1.z.string().optional().describe(`The launch args of the browser, use chrome launch args, eg: ${JSON.stringify(["--blink-settings=imagesEnabled=false", "--disable-notifications"])}, or vista url, eg: ${JSON.stringify(["https://www.adspower.net"])}`), clearCacheAfterClosing: zod_1.z.enum(['0', '1']).optional().describe('The clear cache after closing of the browser, 0 is not clear cache after closing, 1 is clear cache after closing, default is 0'), cdpMask: zod_1.z.enum(['0', '1']).optional().describe('The cdp mask of the browser, 0 is not use cdp mask, 1 is use cdp mask, default is 0'), }).strict(), closeBrowserSchema: zod_1.z.object({ userId: zod_1.z.string().describe('The browser id of the browser to stop, it is required when you want to stop the browser') }).strict(), deleteBrowserSchema: zod_1.z.object({ userIds: zod_1.z.array(zod_1.z.string()).describe('The user ids of the browsers to delete, it is required when you want to delete the browser') }).strict(), getBrowserListSchema: zod_1.z.object({ groupId: zod_1.z.string() .regex(/^\d+$/, "Group ID must be a numeric string") .optional() .describe('The group id of the browser, must be a numeric string (e.g., "123"). You can use the get-group-list tool to get the group list'), size: zod_1.z.number().optional().describe('The size of the page, max is 100, if get more than 100, you need to use the page to get the next page, default is 10'), page: zod_1.z.number().optional().describe('The page of the browser, default is 1'), id: zod_1.z.string().optional().describe('The id of the browser'), serialNumber: zod_1.z.string().optional().describe('The serial number of the browser'), sort: zod_1.z.enum(['serial_number', 'last_open_time', 'created_time']).optional() .describe('The sort of the browser'), order: zod_1.z.enum(['asc', 'desc']).optional() .describe('The order of the browser') }).strict(), moveBrowserSchema: zod_1.z.object({ groupId: zod_1.z.string() .regex(/^\d+$/, "Group ID must be a numeric string") .describe('The target group id, must be a numeric string (e.g., "123"). You can use the get-group-list tool to get the group list'), userIds: zod_1.z.array(zod_1.z.string()).describe('The browser ids to move') }).strict(), // Group Related Schema createGroupSchema: zod_1.z.object({ groupName: zod_1.z.string().describe('The name of the group to create'), remark: zod_1.z.string().optional().describe('The remark of the group') }).strict(), updateGroupSchema: zod_1.z.object({ groupId: zod_1.z.string() .regex(/^\d+$/, "Group ID must be a numeric string") .describe('The id of the group to update, must be a numeric string (e.g., "123"). You can use the get-group-list tool to get the group list'), groupName: zod_1.z.string().describe('The new name of the group'), remark: zod_1.z.string().nullable().optional().describe('The new remark of the group') }).strict(), getGroupListSchema: zod_1.z.object({ groupName: zod_1.z.string().optional().describe('The name of the group to search, use like to search, often used group name to find the group id, so eg: "test" will search "test" and "test1"'), size: zod_1.z.number().optional().describe('The size of the page, max is 100, if get more than 100, you need to use the page to get the next page, default is 10'), page: zod_1.z.number().optional().describe('The page of the group, default is 1') }).strict(), // Application Related Schema getApplicationListSchema: zod_1.z.object({ size: zod_1.z.number().optional().describe('The size of the page') }).strict(), // Empty Schema emptySchema: zod_1.z.object({}).strict(), // Automation Related Schema createAutomationSchema: zod_1.z.object({ userId: zod_1.z.string().optional().describe('The browser id of the browser to connect'), serialNumber: zod_1.z.string().optional().describe('The serial number of the browser to connect'), wsUrl: zod_1.z.string().describe('The ws url of the browser, get from the open-browser tool content `ws.puppeteer`') }).strict(), navigateSchema: zod_1.z.object({ url: zod_1.z.string().describe('The url to navigate to') }).strict(), screenshotSchema: zod_1.z.object({ savePath: zod_1.z.string().optional().describe('The path to save the screenshot'), isFullPage: zod_1.z.boolean().optional().describe('The is full page of the screenshot') }).strict(), clickElementSchema: zod_1.z.object({ selector: zod_1.z.string().describe('The selector of the element to click, find from the page source code') }).strict(), fillInputSchema: zod_1.z.object({ selector: zod_1.z.string().describe('The selector of the input to fill, find from the page source code'), text: zod_1.z.string().describe('The text to fill in the input') }).strict(), selectOptionSchema: zod_1.z.object({ selector: zod_1.z.string().describe('The selector of the option to select, find from the page source code'), value: zod_1.z.string().describe('The value of the option to select') }).strict(), hoverElementSchema: zod_1.z.object({ selector: zod_1.z.string().describe('The selector of the element to hover, find from the page source code') }).strict(), scrollElementSchema: zod_1.z.object({ selector: zod_1.z.string().describe('The selector of the element to scroll, find from the page source code') }).strict(), pressKeySchema: zod_1.z.object({ key: zod_1.z.string().describe('The key to press, eg: "Enter"'), selector: zod_1.z.string().optional().describe('The selector of the element to press the key, find from the page source code') }).strict(), evaluateScriptSchema: zod_1.z.object({ script: zod_1.z.string().describe('The script to evaluate, eg: "document.querySelector(\'#username\').value = \'test\'"') }).strict(), };