-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: add --profile-directory option to specify Chrome profile #753
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
base: main
Are you sure you want to change the base?
feat: add --profile-directory option to specify Chrome profile #753
Conversation
Added a new CLI option to allow users to specify which Chrome profile to use when launching the browser. Changes: - Added --profile-directory CLI argument - Updated BrowserOptions interface - Connected CLI arg to Chrome launch flag - Added documentation in README.md
sebastianbenz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, one suggestion on the docs.
|
Did you test this with autoconnect? I just tested this by running Chrome in "Profile 1" and setting |
@sebastianbenz Yes, I tested this with autoconnect and saw the same behavior even when Chrome is running with “Profile 1”, the MCP server still connects successfully when --profile-directory=Profile 2 is specified. So, I add a validation step to detect a profile mismatch after connecting and fail fast instead of silently attaching to the wrong profile. The intention is to avoid surprising connections when a specific profile is explicitly requested. Let me know if you’d like me to add anything specific to the docs around the profile behavior. |
|
- Yasindu, Chrome profilini belirtmek için yeni --profile-directory
seçeneğini
ekleyen bir çekme isteği başlattı.
- Sebastian'ın otomatik bağlantı sırasındaki profil uyuşmazlığı
endişeleri üzerine, Yasindu bir doğrulama adımı ekledi.
13 Oca 2026 Sal 09:42 tarihinde Yasindu Dasanga De Mel <
***@***.***> şunu yazdı:
… *Yasindu20* left a comment (ChromeDevTools/chrome-devtools-mcp#753)
<#753 (comment)>
Did you test this with autoconnect? I just tested this by running Chrome
in "Profile 1" and setting "--profile-directory=Profile 2". In this case,
the MCP server still connected to Profile 1, but I would've expected the
connection to fail. Or is this the intended behavior?
@sebastianbenz <https://github.com/sebastianbenz> Yes, I tested this with
autoconnect and saw the same behavior even when Chrome is running with
“Profile 1”, the MCP server still connects successfully when
--profile-directory=Profile 2 is specified. So, I add a validation step to
detect a profile mismatch after connecting and fail fast instead of
silently attaching to the wrong profile. The intention is to avoid
surprising connections when a specific profile is explicitly requested. Let
me know if you’d like me to add anything specific to the docs around the
profile behavior.
—
Reply to this email directly, view it on GitHub
<#753 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BMNMCXR527L4IE7CKSWEF5D4GSHUHAVCNFSM6AAAAACRMMOQI2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTONBSGI3TAOBUHE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
src/browser.ts
Outdated
|
|
||
| if (options.profileDirectory && options.userDataDir) { | ||
| try { | ||
| const portPath = path.join(options.userDataDir, 'DevToolsActivatePort'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
such file does not exist, did you mean DevToolsPort. A single user data dir hosts multiple profiles so I am not sure if the check handles it correctly.
src/browser.ts
Outdated
| ); | ||
| } | ||
|
|
||
| if (options.profileDirectory && options.userDataDir) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think this check should be in the connection code branch.
| default: true, | ||
| describe: 'Set to false to exclude tools related to network.', | ||
| }, | ||
| profileDirectory: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably should be using https://pptr.dev/api/puppeteer.browser.browsercontexts to locate the browser context for the profile (currently the default browser context is used)
… the connection path, switched to referencing browser.browserContexts()
|
@OrKoN I fixed the DevToolsActivePort from DevToolsActivatePort. Removed the profile validation logic since a single userDataDir can contain multiple profiles, and that check isn’t reliable. Also removed the profile-related checks from the connection path, add it to the function launch(). For profile handling, I switched to referencing browser.browserContexts() and added clear logging that we currently fall back to the default context. Proper profile → context mapping can be improved once Puppeteer exposes a cleaner way to do this. |
| logger(`Found ${contexts.length} browser context(s)`); | ||
|
|
||
| logger( | ||
| `Profile directory "${profileDirectory}" specified. ` + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this PR does not add anything useful without the implementation for finding the browser context that matches the profileDirectory name. Passing --profile-directory to Chrome is already possible via the --chrome-arg param. Would you be up to figuring out how to find the correct browser context? it might right changes on the CDP and Puppeteer side.
|
@OrKoN Puppeteer or CDP don’t currently expose profile directory info for browser contexts. Now I tried to implement it to open a temporary page in each context, reads chrome://version to get the profile path, and matches it to the requested --profile-directory. If no match is found, it falls back to the default context. This works with existing APIs and can be updated later if CDP/Puppeteer expose profile metadata. If need any changes let me know |
Summary
Adds support for specifying which Chrome profile to use via a new
--profile-directoryCLI option.Motivation
Users often need to:
Currently, there's no way to specify which profile Chrome should use when launched by the MCP server.
Changes
--profile-directoryCLI option with kebab-case aliasBrowserOptionsinterface to includeprofileDirectoryproperty--profile-directorylaunch flagUsage Example
{ "mcpServers": { "chrome-devtools": { "command": "npx", "args": [ "chrome-devtools-mcp@latest", "--profile-directory=Profile 1" ] } } }Or via command line:
npx chrome-devtools-mcp --profile-directory="Profile 1"npm run docsnpm run formatRelated Issues
Fixes #694