Skip to content

Commit 156bd23

Browse files
author
BeerThaish
committed
Main
1 parent 914ac68 commit 156bd23

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

.github/copilot-instructions.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Guidance for AI coding agents working on chrome-devtools-mcp
2+
3+
This file contains short, actionable guidance for an AI coding agent to be productive in this repository.
4+
5+
1. Purpose (big picture)
6+
- This repo implements an MCP server that exposes Chrome DevTools functionality to MCP clients.
7+
- High-level flow: MCP client -> `McpContext` -> tool dispatcher (`src/tools/*`) -> `DevToolsConnectionAdapter` / `PageCollector` -> Puppeteer + DevTools.
8+
9+
2. Key files & why they matter
10+
- `src/McpContext.ts` — request lifecycle, context and quota handling.
11+
- `src/DevToolsConnectionAdapter.ts` — adapter between MCP tools and DevTools/Puppeteer.
12+
- `src/tools/ToolDefinition.ts` and `src/tools/*.ts` — where each MCP tool is defined; modify here to add/update tools.
13+
- `src/PageCollector.ts` — collects and manages trace/pages when recording performance.
14+
- `src/formatters/*` — formatting functions for console, network and snapshot outputs.
15+
- `third_party/devtools.ts` — mappings and constants derived from DevTools frontend.
16+
- `server.json` — server metadata; `scripts/verify-server-json-version.ts` validates this.
17+
18+
3. Build / test / doc workflows (exact commands)
19+
- Node requirement: Node v20.19+ (see `package.json.engines`).
20+
- Build (compile + post-process): `npm run build` (runs `tsc` then `scripts/post-build.ts`).
21+
- Build+bundle (production): `npm run bundle` (also runs Rollup). After bundling, `build/src` is the runtime output.
22+
- Start server (dev): `npm run start` or `npm run start-debug` (sets `DEBUG=mcp:*`).
23+
- Tests: tests run against the transpiled build. Typical sequence: `npm run build && npm run test:no-build` or simply `npm run test`.
24+
- Generate docs / tool reference: `npm run docs` (calls `scripts/generate-docs.ts`). The README contains an auto-generated tools block; update docs after editing `src/tools/*`.
25+
26+
4. Project-specific conventions & gotchas
27+
- Tests run against `build/tests/*` and rely on `build/tests/setup.js` being imported. Always run `npm run build` first.
28+
- The build pipeline uses `node --experimental-strip-types` in post-build. Do not assume plain `tsc` output is fully runnable without `post-build` steps.
29+
- The `bin` entry points to `build/src/index.js`: changes to CLI entry must be reflected in the build output.
30+
- Tool definitions are canonical sources for the public MCP surface; changing `src/tools/*` often requires regenerating the docs (`npm run docs`).
31+
- Lint/format: `npm run format`; `eslint_rules/` contains custom rules used by CI.
32+
33+
5. Integration points & external deps
34+
- Puppeteer (`puppeteer`) is used to drive Chrome. `DevToolsConnectionAdapter` and `PageCollector` contain the Puppeteer interactions.
35+
- DevTools frontend assets: `chrome-devtools-frontend` is a dependency; `third_party/devtools.ts` references generated artifacts.
36+
- Many runtime behaviors are controlled by CLI flags (see README for `--browser-url`, `--ws-endpoint`, `--isolated`, etc.).
37+
38+
6. When editing code, practical examples
39+
- Adding a new tool: add `src/tools/mytool.ts`, update exports in `src/tools/tools.ts`, run `npm run build` and `npm run docs` to update the README tools list.
40+
- Fixing a formatter: update `src/formatters/*.ts` and run unit tests (`npm run build && npm run test:no-build`).
41+
- Debugging live behavior: use `npm run start-debug` and set `DEBUG=mcp:* DEBUG_COLORS=false` to reproduce logs similar to CI.
42+
43+
7. Useful places to check before changes
44+
- `README.md` — contains overall guidance and auto-generated tools block.
45+
- `docs/tool-reference.md` — canonical documentation of tools and their inputs/outputs.
46+
- `scripts/` — build/post-build/docs generation behaviors.
47+
- `tests/` — examples of how tools are used and what outputs/fixtures look like (snapshots live under `tests/*/*.snapshot`).
48+
49+
8. Safety & scope
50+
- This project exposes browser content via MCP — avoid adding code that leaks secrets into logs or public responses. Follow existing patterns for masking or avoiding sensitive content.
51+
52+
If any section is unclear or you want more examples (e.g., a walkthrough of adding a tool end-to-end), I can expand specific parts. Please tell me which area you'd like more detail on.

0 commit comments

Comments
 (0)