Skip to content

Stagehand initialization error: Cannot create proxy with a non-object as target or handler, and uninitialized page object #56

Open
@djb4ai

Description

@djb4ai

Issue Description

When attempting to use Stagehand MCP with a local Chrome instance (CDP on port 9222), I encountered the following errors:

  • Cannot create proxy with a non-object as target or handler.
    • You seem to be calling page on a page in an uninitialized Stagehand object. Ensure you are running await stagehand.init() on the Stagehand object before referencing the page object.

Steps to Reproduce

  1. Start Chrome with remote debugging enabled: --remote-debugging-port=9222
    1. Start the Stagehand MCP server with the correct LOCAL_CDP_URL.
    1. Attempt to use browser automation via MCP.

Solution

The issue was resolved by ensuring that await stagehand.init() is called before any reference to the page object. In my case, the initialization was either missing or not awaited properly, causing the errors above. After adding and properly awaiting stagehand.init(), the errors were resolved and browser automation worked as expected.

Suggestion

Consider adding clearer error messages or documentation to help users ensure proper initialization order, especially when using Stagehand in local mode.


Thank you for your work on this project!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions