Skip to main content
Glama
AdsPower

AdsPower LocalAPI MCP Server

Official

get-browser-list

Retrieve a list of browsers from AdsPower LocalAPI MCP Server by specifying group ID, page size, or sorting criteria to manage and organize browser profiles effectively.

Instructions

Get the list of browsers

Input Schema

NameRequiredDescriptionDefault
groupIdNoThe 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
idNoThe id of the browser
orderNoThe order of the browser
pageNoThe page of the browser, default is 1
serialNumberNoThe serial number of the browser
sizeNoThe 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
sortNoThe sort of the browser

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "groupId": { "description": "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", "pattern": "^\\d+$", "type": "string" }, "id": { "description": "The id of the browser", "type": "string" }, "order": { "description": "The order of the browser", "enum": [ "asc", "desc" ], "type": "string" }, "page": { "description": "The page of the browser, default is 1", "type": "number" }, "serialNumber": { "description": "The serial number of the browser", "type": "string" }, "size": { "description": "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", "type": "number" }, "sort": { "description": "The sort of the browser", "enum": [ "serial_number", "last_open_time", "created_time" ], "type": "string" } }, "type": "object" }

Implementation Reference

  • The core handler function for the 'get-browser-list' tool. It destructures input params, builds URL search parameters for filtering, pagination, and sorting, makes an axios GET request to the local API endpoint for browser list, and returns a formatted JSON string of the list.
    async getBrowserList(params: GetBrowserListParams) { const { groupId, size, id, serialNumber, sort, order, page } = params; const urlParams = new URLSearchParams(); if (size) { urlParams.set('page_size', size.toString()); } if (page) { urlParams.set('page', page.toString()); } if (id) { urlParams.set('user_id', id); } if (groupId) { urlParams.set('group_id', groupId); } if (serialNumber) { urlParams.set('serial_number', serialNumber); } if (sort) { urlParams.set('user_sort', JSON.stringify({ [sort]: order || 'asc', })); } const response = await axios.get(`${LOCAL_API_BASE}${API_ENDPOINTS.GET_BROWSER_LIST}`, { params: urlParams }); return `Browser list: ${JSON.stringify(response.data.data.list, null, 2)}`; },
  • Zod input schema for the 'get-browser-list' tool, validating optional parameters for group filtering, pagination (size, page), search by id/serialNumber, and sorting (sort, order).
    getBrowserListSchema: z.object({ groupId: 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: 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: z.number().optional().describe('The page of the browser, default is 1'), id: z.string().optional().describe('The id of the browser'), serialNumber: z.string().optional().describe('The serial number of the browser'), sort: z.enum(['serial_number', 'last_open_time', 'created_time']).optional() .describe('The sort of the browser'), order: z.enum(['asc', 'desc']).optional() .describe('The order of the browser') }).strict(),
  • Tool registration in the MCP server, associating the name 'get-browser-list', description, input schema shape, and the wrapped browserHandlers.getBrowserList function.
    server.tool('get-browser-list', 'Get the list of browsers', schemas.getBrowserListSchema.shape, wrapHandler(browserHandlers.getBrowserList));
  • Helper function that wraps all tool handlers, standardizing the response to MCP CallToolResult format (text content array), and handles specific browser-related errors by resetting the browser connection.
    export function wrapHandler(handler: Function) { return async (params: any): Promise<CallToolResult> => { try { const content = await handler(params); if (typeof content === 'string') { return { content: [{ type: 'text' as const, text: content }] }; } return { content }; } catch (error) { let errorMessage = error instanceof Error ? error.message : String(error); if ( errorMessage.includes("Target page, context or browser has been closed") || errorMessage.includes("Target closed") || errorMessage.includes("Browser has been disconnected") || errorMessage.includes("Protocol error") || errorMessage.includes("Connection closed") ) { await browser.resetBrowser(); errorMessage = `Browser connection error: ${errorMessage}. Connection has been reset - please retry the operation.`; } return { content: [{ type: 'text' as const, text: errorMessage }] }; } }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AdsPower/local-api-mcp-typescript'

If you have feedback or need assistance with the MCP directory API, please join our Discord server