Skip to content

Allow passing an existing BrowserContext instance to createServer for more flexibility #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
adcentury opened this issue Apr 20, 2025 · 5 comments

Comments

@adcentury
Copy link

Would it be possible to support passing in an existing BrowserContext?

Right now, createServer() handles the creation/connecting of the Playwright browser internally, which works fine for many cases. But in more advanced setups, you might already have a context.

For example:

  • A developer already has a fully configured launchPersistentContext(), like login state, extensions, or other settings
  • The context is being managed externally (e.g. injected via dependency)

I know remoteEndpoint is an option, but sometimes passing a context directly is just simpler for local use cases.

I can create a PR about this feature if needed.

@pavelfeldman
Copy link
Member

How are you planning to start the mcp server?

@adcentury
Copy link
Author

From the code, not cli.

@pavelfeldman
Copy link
Member

That's kind of obvious. So you have your own mcp server and you just want to reuse the code, right?

@adcentury
Copy link
Author

adcentury commented Apr 20, 2025

Yes, that's correct. The way I see it, this repo is not just about exposing some MCP endpoints. One of its core value is how it manages the browser/tabs and supports features like snapshot/vision interaction, am I right about this?

@pavelfeldman
Copy link
Member

This repo is an implementation of the basic Playwright MCP server. Sounds like you are working on some other server. I'm fine with accepting a PR that allows passing external context for you to use in your server, as long as the PR is high quality and does not do anything else!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants