Skip to main content
Glama
AdsPower

AdsPower LocalAPI MCP Server

Official

connect-browser-with-ws

Establish a WebSocket connection to an AdsPower browser instance using its WebSocket URL, enabling remote control and automation of browser profiles.

Instructions

Connect the browser with the ws url

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
userIdNoThe browser id of the browser to connect
serialNumberNoThe serial number of the browser to connect
wsUrlYesThe ws url of the browser, get from the open-browser tool content `ws.puppeteer`

Implementation Reference

  • The main handler function for the 'connect-browser-with-ws' tool. It receives the wsUrl parameter and delegates the connection to the browserBase instance, handling success/error responses.
    async connectBrowserWithWs({ wsUrl }: CreateAutomationParams) {
        try {
            await browser.connectBrowserWithWs(wsUrl);
            return `Browser connected successfully with: ${wsUrl}`;
        } catch (error) {
            return `Failed to connect browser with: ${error?.toString()}`;
        }
    },
  • Zod schema defining input parameters for the tool: optional userId/serialNumber and required wsUrl.
    createAutomationSchema: z.object({
        userId: z.string().optional().describe('The browser id of the browser to connect'),
        serialNumber: z.string().optional().describe('The serial number of the browser to connect'),
        wsUrl: z.string().describe('The ws url of the browser, get from the open-browser tool content `ws.puppeteer`')
    }).strict(),
  • Registers the tool with the MCP server, specifying name, description, input schema, and the wrapped handler function.
    server.tool('connect-browser-with-ws', 'Connect the browser with the ws url', schemas.createAutomationSchema.shape,
        wrapHandler(automationHandlers.connectBrowserWithWs));
  • Supporting method in BrowserBase class that performs the actual WebSocket connection to an existing browser using Playwright's connectOverCDP.
    async connectBrowserWithWs(wsUrl: string) {
        this.browser = await chromium.connectOverCDP(wsUrl);
        const defaultContext = this.browser.contexts()[0];
        this.page = defaultContext.pages()[0];
        await this.page.bringToFront().catch((error) => {
            console.error('Failed to bring page to front', error);
        });
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action but doesn't explain what 'connect' means—whether it establishes a new session, reconnects an existing one, requires authentication, has side effects, or what happens on failure. This leaves critical operational traits undefined for the agent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function. It's front-loaded with the core action and includes a helpful note about parameter sourcing, though it could be slightly more informative without sacrificing brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a browser connection tool with no annotations and no output schema, the description is insufficient. It doesn't cover what the tool returns, error conditions, or how it integrates with sibling tools, leaving the agent with incomplete context for reliable invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents the three parameters. The description adds minimal value by referencing the wsUrl source from 'open-browser', which provides some context but doesn't elaborate on parameter interactions or usage beyond what's in the schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool's purpose as connecting a browser with a WebSocket URL, which is a clear action but lacks specificity about what 'connect' entails operationally. It doesn't distinguish itself from sibling tools like 'open-browser' or 'get-opened-browser', leaving ambiguity about its unique role in the browser management workflow.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It mentions getting the wsUrl from 'open-browser', implying a sequence, but doesn't clarify if this is a prerequisite or alternative to other tools like 'create-browser' or 'update-browser', leaving the agent to infer usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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