Stagehand MCP local mode: "Cannot create proxy with a non-object as target" error
Using the Stagehand MCP server from browserbase/mcp-server-browserbase against a local Chrome instance started with
--remote-debugging-port=9222, browser automation fails withCannot create proxy with a non-object as target or handlerand a warning thatpageis referenced on an uninitialized Stagehand object. What causes this and how do I fix it? The issue is still open and also affects other local-mode users.Originally asked on GitHub: https://github.com/browserbase/mcp-server-browserbase/issues/56
3 answers
Status: open (as of May 2025). The reported fix is initialization order: the Stagehand
pageobject cannot be used beforeawait stagehand.init()has completed.What worked in the thread:
- Start Chrome with remote debugging:
--remote-debugging-port=9222. - Point the Stagehand MCP server at that instance via
LOCAL_CDP_URL. - Make sure your code calls
await stagehand.init()and actually awaits it before touchingstagehand.page. A missing or un-awaited init producesCannot create proxy with a non-object as target or handlerplus the "uninitialized Stagehand object" warning. After adding and awaiting init, the reporter's automation worked.
Additional context from the thread:
- A maintainer commented that a proposed PR removing the try/catch around session creation would defeat the session check, so keep that check intact.
- A later commenter hit the same error when running locally to capture traffic in Burp Suite and asked whether Firefox can be used with
LOCAL_CDP_URL; the thread does not answer that. - Another commenter pointed to a fix described in issue #44 (comment link only), but the details are not in this thread.
General advice: a Chrome instance started with
--remote-debugging-portcan be driven by any local process, so don't expose that port to other machines or untrusted networks.Did this work for you?- Start Chrome with remote debugging:
What a GitHub user tried on GitHub (Worked)
Reproduced with Chrome on
--remote-debugging-port=9222andLOCAL_CDP_URL, then fixed it by calling and awaitingstagehand.init()before referencing thepageobject.Source: https://github.com/browserbase/mcp-server-browserbase/issues/56 (opens external site)
Did this work for you?What @cotarelorodrigo tried on GitHub (Outcome unclear)
Commenter reported the same issue when running locally to capture traffic with Burp Suite and asked if Firefox is supported via
LOCAL_CDP_URL; no answer was given in the thread.Did this work for you?