Skip to content

feat: add --watchConfig to apply config file changes without restarting - #2878

Closed
Lightning00Blade wants to merge 6 commits into
cd4a-config/4-apply-configfrom
cd4a-config/5-watch-config
Closed

Lightning00Blade wants to merge 6 commits into
cd4a-config/4-apply-configfrom
cd4a-config/5-watch-config

Conversation

@Lightning00Blade

Copy link
Copy Markdown
Collaborator

When --watchConfig is passed, the config file is watched and changes are
applied via applyConfig(). Watching is off by default.

  • The directory of the real file is watched, so symlinks and atomic saves
    are handled.
  • Changes are debounced with the DevTools debouncer.
  • An invalid config file is logged to stderr and the previous configuration
    is kept.
  • Changes to options that require a restart are logged to stderr.

Stack created with GitHub Stacks CLI • Give Feedback 💬

@Lightning00Blade
Lightning00Blade force-pushed the cd4a-config/4-apply-config branch from 221225b to 16470e0 Compare September 30, 2026 08:13
@Lightning00Blade
Lightning00Blade force-pushed the cd4a-config/5-watch-config branch from 832c986 to 14955c8 Compare September 30, 2026 08:13
@Lightning00Blade
Lightning00Blade force-pushed the cd4a-config/4-apply-config branch from 16470e0 to b86222b Compare September 30, 2026 08:23
@Lightning00Blade
Lightning00Blade force-pushed the cd4a-config/5-watch-config branch 2 times, most recently from 9401679 to eb63f21 Compare September 30, 2026 08:28
@Lightning00Blade
Lightning00Blade force-pushed the cd4a-config/4-apply-config branch from b86222b to 07e645f Compare September 30, 2026 08:28
@Lightning00Blade
Lightning00Blade removed this pull request from stack #2879 September 30, 2026 08:32
Prepares the server for applying configuration changes at runtime.

- createTools() always returns every tool. The DevTools comments tools are
  gated by their `devtoolsComments` condition like other tools, instead of
  not being created.
- Slim tools are marked with `slim: true`. Slim mode selects which set of
  tools is registered, so slim tools may reuse the names of regular tools
  and other tools do not need a "not slim" condition.
- McpServer keeps the registered tool handles so tools can be updated in
  place, and declares the `tools.listChanged` capability with debounced
  `notifications/tools/list_changed`.
- The docs, CLI and metrics scripts use the single tool list. The DevTools
  comments tools are now tracked in the tool call metrics.
Moves the options passed to Puppeteer (viewport, acceptInsecureCerts,
blockedUrlPattern, allowedUrlPattern) to `puppeteer-options.ts` and the
options that change the default behavior of tools (screenshot*) to
`tool-options.ts`. This makes it possible to tell which options require a
restart when they change.
The config file is searched for in the following locations, the first
existing file wins and files are not merged:

1. `--config`
2. `${CWD}/cd4a.config.json`
3. `${PLUGIN_DATA}/cd4a.config.json`
4. `$XDG_CONFIG_HOME/cd4a/config.json` on macOS and Linux,
   `%LOCALAPPDATA%/Google/cd4a/config.json` on Windows, with a fallback to
   `~/.config/cd4a/config.json`.

Discovery is only enabled when a ConfigLocator is passed to ConfigParser,
which the entry points do. Setting `CHROME_DEVTOOLS_MCP_NO_CONFIG_DISCOVERY`
turns it off, the test runner sets it so tests never pick up a developer's
config file.

fix
Adds McpServer.applyConfig(), which updates all registered tools in place
(resulting in a single `tools/list_changed` notification) and applies the
live options to the existing McpContext. Options that are only read on
startup, such as the browser and Puppeteer options, are listed in
RESTART_REQUIRED_OPTIONS. Slim mode is kept as started.
When `--watchConfig` is passed, the config file is watched and changes are
applied via applyConfig(). Watching is off by default.

- The directory of the real file is watched, so symlinks and atomic saves
  are handled.
- Changes are debounced with the DevTools debouncer.
- An invalid config file is logged to stderr and the previous configuration
  is kept.
- Changes to options that require a restart are logged to stderr.
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

Successfully merging this pull request may close these issues.

1 participant