文件历史

提交图

14 次代码提交

作者 SHA1 备注 提交日期
Wolfgang Beyer 57f32b0cd4 fix: Fix throttling info in performance trace output (#2096)
This addresses #1955.

Throttling information needs to be passed to the parser for the output
to be correct.
2026-05-22 08:08:56 +00:00
Nicholas Roscino b2b3e99d67 feat(cli): generate commands for conditional tools (#1962)
This PR adds all tools in the CLI interface. When a tool is not enabled
the server responds with an error guiding the user on how to enable the
category or the experiment.

Closes:
https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/1933
2026-04-30 07:59:08 +00:00
Alex Rudenko 82b67b07d3 refactor: add support for CLI sessionIds in tests (#1919)
Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/1119
2026-04-22 08:15:36 +00:00
Alex Rudenko 47a50ca84c chore: split cli tests (#1779)
splits cli test that might reach the test file timeout more often.
2026-04-01 07:38:43 +00:00
pidofme 73e1e24b26 fix(cli): avoid defaulting to isolated when userDataDir is provided (#1258)
## Summary

Fix `chrome-devtools start` so it no longer implicitly enables
`isolated` when `--userDataDir` is provided.

Previously, the CLI wrapper always defaulted `isolated` to `true` for
`start`, which caused `userDataDir` and `isolated` to conflict even when
the user only specified `--userDataDir`. This made it impossible to
start the CLI daemon against a persistent browser profile.

   ## Changes

- Update `chrome-devtools start` default handling in
`src/bin/chrome-devtools.ts`
     - only default `isolated=true` when `userDataDir` is not set
- Clarify the `isolated` CLI description to document the conditional
default
   - Update `docs/cli.md` to reflect that:
     - `headless` is enabled by default
- `isolated` is enabled by default unless `--userDataDir` is provided
   - Fix a small error message typo

   ## Why

   This matches the intended semantics of the flags:

   - `--isolated` means use a temporary user data dir
   - `--userDataDir` means use a persistent, explicit user data dir

If the user passes `--userDataDir`, the CLI should not also implicitly
enable `isolated`.

   ## Testing

   - Ran:
     - `npm test -- tests/cli.test.ts`
     - `npm test -- tests/e2e/chrome-devtools.test.ts`

Added an e2e regression test in `tests/e2e/chrome-devtools.test.ts` to
verify that:

   - `chrome-devtools start --userDataDir <temp dir>` succeeds
- the CLI no longer fails with `Arguments userDataDir and isolated are
mutually exclusive`
   - the daemon starts successfully when `userDataDir` is provided
2026-04-01 05:51:40 +00:00
Alex Rudenko c2d8009ff7 refactor: move main files (#1120)
- `chrome-devtools-mcp.js` is the `npx chrome-devtools-mcp`
- `chrome-devtools.js` is the new CLI
- `-cli-options.js` is the corresponding options
- all these files are in the bin folder to indicate they are executable
2026-03-05 21:51:37 +00:00
Alex Rudenko 8a3a1b7c19 test: improve cli test (#1121)
Use async spawn, and make the logs visible in CI.
2026-03-05 17:08:23 +00:00
Alex Rudenko 4e4038beff chore: configure cli args (#1115)
This PR configures CLI args for the start command. It removes arguments
that do not make sense.
2026-03-05 12:48:42 +00:00
Alex Rudenko d95e9ba89d chore: add detailed daemon status (#1110)
adds additional details about running daemon.
2026-03-05 08:41:10 +00:00
Alex Rudenko bad5a16f95 chore: handle images in the CLI (#1107)
- save base64 data as an image to a tmp file.
- change `--format` to `--output-format` to avoid conflicts.
2026-03-05 07:49:13 +00:00
Alex Rudenko 109bf43e4c chore: fix arg forwarding in CLI (#1084)
Drive-by: e2e tests for major scenarios.
Drive-by: make stopDaemon more robust.
2026-03-03 17:47:01 +00:00
Alex Rudenko c0435a2d53 fix: disable usage statistics when CI or CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS env is set (#862)
When CI or CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS env variables are
set, we override the set cli args and disable the usage statistics.
2026-01-30 07:58:45 +00:00
Ergün Erdoğmuş 210bacdb04 chore: Implement ClearcutSender HTTP transport for telemetry disabled by default (#805)
This PR completes the telemetry system by implementing the transport
layer for `ClearcutSender`. It enables actual HTTP communication with
the Clearcut backend, handling event batching, rate limiting, and
reliable delivery, including robust shutdown handling.

**Key Changes:**
* **HTTP Transport**: Implemented `fetch`-based transport sending `POST`
requests to the Clearcut HTTP server.
* **Event Batching**: Events are now buffered and flushed periodically
(default: 15 minutes) or on shutdown.
*   **Reliability & Rate Limiting**:
* **Server-Side Backoff**: Respects `next_request_wait_millis` from
server responses to handle rate limiting dynamically.
* **Transient Error Retries**: Failed requests (5xx, 429) result in
events being requeued for the next flush.
* **Request Timeouts**: Enforced 30s timeout on requests to prevent
hanging processes.
* **Session Rotation**: Automatically rotates session IDs every 24
hours.
*   **Safety & Stability**:
* **Buffer Overflow Protection**: Caps the buffer at 1000 events to
prevent memory leaks, dropping oldest events if necessary.
* **Optimistic Removal**: Prevents race conditions and duplicate events
during shutdown by optimistically removing events from the buffer before
sending.
*   **Testing Improvements**:
* **E2E Robustness**: Updated E2E tests to use a mock web server instead
of relying on the logger to log specific lines.

**Implementation Roadmap:**
These changes finalize the planned telemetry architecture:
1. **CLI & Opt-out Mechanism
([Merged](https://github.com/ChromeDevTools/chrome-devtools-mcp/pull/757))**
2. **Logger Scaffolding & Integration
([Merged](https://github.com/ChromeDevTools/chrome-devtools-mcp/pull/758))**
3. **Persistence Layer
([Merged](https://github.com/ChromeDevTools/chrome-devtools-mcp/pull/766))**
4. **Watchdog Process Architecture
([Merged](https://github.com/ChromeDevTools/chrome-devtools-mcp/pull/769))**
5.  **Transport, Batching & Retries (This PR):**
* Finalized `ClearcutSender` with HTTP transport, batching, and
server-directed backoff strategies.

---------

Co-authored-by: Alex Rudenko <alexrudenko@chromium.org>
2026-01-27 14:18:33 +00:00
Ergün Erdoğmuş ee35f207eb chore: Implement Watchdog process for reliable telemetry (#777)
This PR implements the watchdog process architecture for the telemetry
system. It moves the `ClearcutSender` execution to a dedicated child
process, ensuring that events—especially shutdown events—are reliably
transmitted even if the main server process terminates abruptly.

Added an e2e test that runs the server, checks the log file and confirms
the telemetry logs exist and that the watchdog process is correctly
killed after sending the shutdown event once the main process is killed.

**Implementation Roadmap:**
This is the fourth in a series of PRs designed to implement the
telemetry system:
1. **CLI & Opt-out Mechanism
([Merged](https://github.com/ChromeDevTools/chrome-devtools-mcp/pull/757)):**
    *   Added `--usage-statistics` flag and transparency logging.
2. **Logger Scaffolding & Integration
([Merged](https://github.com/ChromeDevTools/chrome-devtools-mcp/pull/758)):**
    *   **`ClearcutLogger`**: Implemented the main logging entry point.
* **One-way Data Flow**: Integrated `logToolInvocation` and
`logServerStart` hooks into `main.ts` to capture events.
    *   **`ClearcutSender`**: Introduced a transport abstraction.
* **Type Definitions**: Added TypeScript definitions for the telemetry
Protocol Buffer messages.
3. **Persistence Layer
([Merged](https://github.com/ChromeDevTools/chrome-devtools-mcp/pull/766)):**
* **`FilePersistence`**: Implemented a local file-based state manager to
persist the `lastActive` timestamp.
* **Daily Active Logic**: Integrated persistence into `ClearcutLogger`
to automatically detect and log `daily_active` events (with
`days_since_last_active` calculation) via `logDailyActiveIfNeeded`.
4.  **Watchdog Process Architecture (This PR):**
* **`WatchdogClient`**: Added a client-side wrapper to spawn and
communicate with the watchdog process via `stdin`.
* **`watchdog/main.ts`**: Created the entry point for the watchdog
process. It listens for IPC messages and uses `ClearcutSender` to
transmit events.
* **Reliable Shutdown**: The watchdog monitors the parent process and
guarantees a `shutdown` event is sent when the parent exits or crashes
(detecting `stdin` closure).
* **Refactoring**: Moved `ClearcutSender` to the `watchdog` directory
and updated `ClearcutLogger` to delegate event sending to the
`WatchdogClient`.
5.  **Transport, Batching & Retries (Next):**
* Finalize `ClearcutSender` with actual HTTP transport logic, including
event batching and exponential backoff retries.
2026-01-19 13:38:58 +00:00