|
| 1 | +# Dead Code Analysis Report |
| 2 | + |
| 3 | +**Project:** chrome-devtools-mcp |
| 4 | +**Date:** 2026-02-06 |
| 5 | +**Analysis Tools:** knip, depcheck, ts-prune |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Executive Summary |
| 10 | + |
| 11 | +This report identifies unused code, dependencies, and exports in the chrome-devtools-mcp project. The analysis found several categories of items that can be potentially removed. |
| 12 | + |
| 13 | +### Key Findings |
| 14 | +- **3 Unused Files** |
| 15 | +- **5 Unused devDependencies** |
| 16 | +- **7 Unlisted Dependencies** (dependencies used but not in package.json) |
| 17 | +- **5 Unused Exports** |
| 18 | +- **2 Unused Exported Types** |
| 19 | +- **2 Unresolved Imports** |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## SAFE Category - Can be Removed |
| 24 | + |
| 25 | +These items are safe to remove with minimal risk. |
| 26 | + |
| 27 | +### 1. Unused devDependencies |
| 28 | + |
| 29 | +| Package | Location | Reason | Risk Level | |
| 30 | +|---------|----------|--------|------------| |
| 31 | +| `@types/filesystem` | package.json:51:6 | Not imported anywhere | LOW | |
| 32 | +| `@typescript-eslint/eslint-plugin` | package.json:55:6 | Replaced by typescript-eslint | LOW | |
| 33 | +| `@typescript-eslint/parser` | (from depcheck) | Not used directly | LOW | |
| 34 | +| `chrome-devtools-frontend` | (from depcheck) | Possibly unused devDependency | MEDIUM | |
| 35 | +| `eslint-import-resolver-typescript` | (from depcheck) | Possibly unused | LOW | |
| 36 | + |
| 37 | +**Estimated Size Savings:** ~200 MB (primarily from chrome-devtools-frontend) |
| 38 | + |
| 39 | +### 2. Unused Files |
| 40 | + |
| 41 | +| File | Size | Reason | Risk Level | |
| 42 | +|------|------|--------|------------| |
| 43 | +| `puppeteer.config.cjs` | Small | Puppeteer config not used in build | LOW | |
| 44 | +| `tests/setup.ts` | Small | Test setup file not imported | MEDIUM | |
| 45 | +| `src/third_party/devtools-formatter-worker.ts` | Small | Third-party worker file | MEDIUM | |
| 46 | + |
| 47 | +**Action Required:** Verify tests still pass before removing `tests/setup.ts`. |
| 48 | + |
| 49 | +### 3. Unused Exports (from src/ only) |
| 50 | + |
| 51 | +| Export | Type | Location | Reason | |
| 52 | +|--------|------|----------|--------| |
| 53 | +| `getIssueDescription` | function | src/issue-descriptions.ts:47:17 | Not imported in project | |
| 54 | + |
| 55 | +### 4. Unused Exported Types |
| 56 | + |
| 57 | +| Type | Location | Reason | |
| 58 | +|------|----------|--------| |
| 59 | +| `ChromeChannel` | enum | src/telemetry/types.ts:66:13 | Not used in project | |
| 60 | + |
| 61 | +--- |
| 62 | + |
| 63 | +## CAUTION Category - Review Before Removal |
| 64 | + |
| 65 | +These items require manual verification before removal. |
| 66 | + |
| 67 | +### 1. Unlisted Dependencies |
| 68 | + |
| 69 | +These packages are used in the code but not listed in package.json. They should be **added**, not removed. |
| 70 | + |
| 71 | +| Package | Usage Location | Action Required | |
| 72 | +|---------|----------------|-----------------| |
| 73 | +| `zod` | src/third_party/index.ts:24:25 | ADD to dependencies | |
| 74 | +| `puppeteer-core` | Multiple locations in src/ and tests/ | ADD to dependencies | |
| 75 | +| `@puppeteer/browsers` | src/third_party/index.ts:39:9 | ADD to dependencies | |
| 76 | + |
| 77 | +**Note:** These are runtime dependencies that must be added to package.json for the bundled package to work correctly. |
| 78 | + |
| 79 | +### 2. Unused Exports from Third Party |
| 80 | + |
| 81 | +| Export | Type | Location | Note | |
| 82 | +|--------|------|----------|------| |
| 83 | +| `KnownDevices` | puppeteer | src/third_party/index.ts:28:3 | Re-exported from puppeteer | |
| 84 | +| `resolveDefaultUserDataDir` | puppeteer | src/third_party/index.ts:35:3 | Re-exported from puppeteer | |
| 85 | +| `detectBrowserPlatform` | puppeteer | src/third_party/index.ts:36:3 | Re-exported from puppeteer | |
| 86 | +| `BrowserEnum` | puppeteer | src/third_party/index.ts:37:14 | Type from puppeteer | |
| 87 | +| `BrowsersChromeReleaseChannel` | type | src/third_party/index.ts:38:32 | Type from puppeteer | |
| 88 | + |
| 89 | +**Note:** These are re-exports from puppeteer. While not directly used in this project, they may be part of the public API. Remove only if sure they're not consumed externally. |
| 90 | + |
| 91 | +### 3. Unresolved Imports |
| 92 | + |
| 93 | +| Import | Location | Issue | |
| 94 | +|--------|----------|-------| |
| 95 | +| `/bundled/ui/legacy/legacy.js` | src/McpContext.ts:571:28 | Bundled file path | |
| 96 | +| `/bundled/core/sdk/sdk.js` | src/McpContext.ts:573:29 | Bundled file path | |
| 97 | + |
| 98 | +**Note:** These are bundled files that exist after the build process. This is expected behavior and not an issue. |
| 99 | + |
| 100 | +--- |
| 101 | + |
| 102 | +## DANGER Category - Do NOT Remove |
| 103 | + |
| 104 | +These items should be kept as-is. |
| 105 | + |
| 106 | +### 1. Core Dependencies |
| 107 | +- All dependencies used in src/ directory |
| 108 | +- @modelcontextprotocol/sdk (critical MCP functionality) |
| 109 | +- puppeteer (core browser automation) |
| 110 | +- debug (logging) |
| 111 | +- All @types packages for TypeScript support |
| 112 | + |
| 113 | +### 2. Configuration Files |
| 114 | +- `tsconfig.json` - TypeScript configuration |
| 115 | +- `rollup.config.mjs` - Bundling configuration |
| 116 | +- `eslint.config.mjs` - Linting configuration |
| 117 | +- `.prettierrc.cjs` - Formatting configuration |
| 118 | + |
| 119 | +--- |
| 120 | + |
| 121 | +## Recommendations |
| 122 | + |
| 123 | +### Immediate Actions (SAFE) |
| 124 | + |
| 125 | +1. **Remove unused devDependencies:** |
| 126 | + ```bash |
| 127 | + npm uninstall @types/filesystem @typescript-eslint/eslint-plugin |
| 128 | + ``` |
| 129 | + |
| 130 | +2. **Remove unused files:** |
| 131 | + ```bash |
| 132 | + rm puppeteer.config.cjs |
| 133 | + # Verify tests pass before removing tests/setup.ts |
| 134 | + ``` |
| 135 | + |
| 136 | +3. **Remove unused exports:** |
| 137 | + - Remove `getIssueDescription` from `src/issue-descriptions.ts` |
| 138 | + - Remove `ChromeChannel` enum from `src/telemetry/types.ts` |
| 139 | + |
| 140 | +### Follow-up Actions (CAUTION) |
| 141 | + |
| 142 | +1. **Add missing dependencies:** |
| 143 | + ```bash |
| 144 | + npm install --save zod puppeteer-core @puppeteer/browsers |
| 145 | + ``` |
| 146 | + |
| 147 | +2. **Review puppeteer re-exports:** |
| 148 | + - Determine if `KnownDevices`, `resolveDefaultUserDataDir`, `detectBrowserPlatform`, `BrowserEnum`, `BrowsersChromeReleaseChannel` are part of public API |
| 149 | + - Remove if not used externally |
| 150 | + |
| 151 | +### Testing Checklist |
| 152 | + |
| 153 | +Before applying any changes: |
| 154 | +- [ ] Run full test suite: `npm test` |
| 155 | +- [ ] Run type checking: `npm run typecheck` |
| 156 | +- [ ] Run build: `npm run build` |
| 157 | +- [ ] Run bundle: `npm run bundle` |
| 158 | +- [ ] Verify MCP server starts correctly |
| 159 | +- [ ] Test all MCP tools functionality |
| 160 | + |
| 161 | +--- |
| 162 | + |
| 163 | +## Configuration Hints |
| 164 | + |
| 165 | +The knip tool reported: |
| 166 | +- `index.js` - Package entry file not found |
| 167 | + |
| 168 | +**Resolution:** The package.json specifies `"main": "index.js"` but this file doesn't exist in the repository. Consider: |
| 169 | +1. Creating the file, OR |
| 170 | +2. Updating package.json to point to the correct entry point (`build/src/index.js`) |
| 171 | + |
| 172 | +--- |
| 173 | + |
| 174 | +## Summary Statistics |
| 175 | + |
| 176 | +| Category | Count | |
| 177 | +|----------|-------| |
| 178 | +| Unused Files | 3 | |
| 179 | +| Unused devDependencies | 5 | |
| 180 | +| Unlisted Dependencies (to add) | 3 | |
| 181 | +| Unused Exports | 5 | |
| 182 | +| Unused Types | 2 | |
| 183 | +| Unresolved Imports | 2 | |
| 184 | + |
| 185 | +**Potential Package Size Reduction:** ~200 MB (mainly from chrome-devtools-frontend if unused) |
| 186 | + |
| 187 | +--- |
| 188 | + |
| 189 | +## Next Steps |
| 190 | + |
| 191 | +1. Review this report with the team |
| 192 | +2. Create a feature branch for cleanup |
| 193 | +3. Run tests to establish baseline |
| 194 | +4. Apply SAFE category changes |
| 195 | +5. Run tests again |
| 196 | +6. Review CAUTION category items |
| 197 | +7. Apply changes incrementally with testing |
| 198 | + |
| 199 | +--- |
| 200 | + |
| 201 | +*Report generated by Refactor & Dead Code Cleaner agent* |
0 commit comments