gentyr 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/antipattern-hunter.md +176 -0
- package/.claude/agents/code-reviewer.md +205 -0
- package/.claude/agents/code-writer.md +154 -0
- package/.claude/agents/deputy-cto.md +309 -0
- package/.claude/agents/feedback-agent.md +101 -0
- package/.claude/agents/investigator.md +136 -0
- package/.claude/agents/product-manager.md +97 -0
- package/.claude/agents/project-manager.md +116 -0
- package/.claude/agents/repo-hygiene-expert.md +626 -0
- package/.claude/agents/secret-manager.md +324 -0
- package/.claude/agents/test-writer.md +354 -0
- package/.claude/commands/configure-personas.md +144 -0
- package/.claude/commands/cto-report.md +36 -0
- package/.claude/commands/demo.md +89 -0
- package/.claude/commands/deputy-cto.md +345 -0
- package/.claude/commands/hotfix.md +31 -0
- package/.claude/commands/overdrive-gentyr.md +167 -0
- package/.claude/commands/product-manager.md +32 -0
- package/.claude/commands/push-migrations.md +86 -0
- package/.claude/commands/push-secrets.md +97 -0
- package/.claude/commands/services.json.example +30 -0
- package/.claude/commands/setup-gentyr.md +396 -0
- package/.claude/commands/show.md +42 -0
- package/.claude/commands/spawn-tasks.md +79 -0
- package/.claude/commands/toggle-automation-gentyr.md +75 -0
- package/.claude/commands/toggle-product-manager.md +19 -0
- package/.claude/commands/triage.md +69 -0
- package/.claude/hooks/README.md +686 -0
- package/.claude/hooks/__tests__/README.md +129 -0
- package/.claude/hooks/agent-tracker.js +434 -0
- package/.claude/hooks/antipattern-hunter-hook.js +401 -0
- package/.claude/hooks/api-key-watcher.js +289 -0
- package/.claude/hooks/block-no-verify.js +301 -0
- package/.claude/hooks/bypass-approval-hook.js +313 -0
- package/.claude/hooks/compliance-checker.js +1309 -0
- package/.claude/hooks/config-reader.js +143 -0
- package/.claude/hooks/credential-file-guard.js +1139 -0
- package/.claude/hooks/credential-health-check.js +168 -0
- package/.claude/hooks/credential-sync-hook.js +79 -0
- package/.claude/hooks/cto-notification-hook.js +656 -0
- package/.claude/hooks/feedback-launcher.js +424 -0
- package/.claude/hooks/feedback-orchestrator.js +367 -0
- package/.claude/hooks/gentyr-splash.js +47 -0
- package/.claude/hooks/gentyr-sync.js +389 -0
- package/.claude/hooks/hourly-automation.js +3340 -0
- package/.claude/hooks/key-sync.js +899 -0
- package/.claude/hooks/lib/approval-utils.js +731 -0
- package/.claude/hooks/lib/feature-branch-helper.js +102 -0
- package/.claude/hooks/lib/worktree-manager.js +330 -0
- package/.claude/hooks/mapping-validator.js +285 -0
- package/.claude/hooks/plan-executor.js +398 -0
- package/.claude/hooks/playwright-cli-guard.js +104 -0
- package/.claude/hooks/playwright-health-check.js +71 -0
- package/.claude/hooks/pre-commit-review.js +725 -0
- package/.claude/hooks/prompts/local-spec-enforcement.md +310 -0
- package/.claude/hooks/prompts/mapping-fix.md +92 -0
- package/.claude/hooks/prompts/mapping-review.md +140 -0
- package/.claude/hooks/prompts/schema-mapper.md +185 -0
- package/.claude/hooks/prompts/spec-enforcement.md +233 -0
- package/.claude/hooks/protected-action-approval-hook.js +336 -0
- package/.claude/hooks/protected-action-gate.js +562 -0
- package/.claude/hooks/protected-actions.json +208 -0
- package/.claude/hooks/protected-actions.json.template +122 -0
- package/.claude/hooks/quota-monitor.js +490 -0
- package/.claude/hooks/reporters/jest-failure-reporter.js +401 -0
- package/.claude/hooks/reporters/playwright-failure-reporter.js +446 -0
- package/.claude/hooks/reporters/vitest-failure-reporter.js +443 -0
- package/.claude/hooks/schema-mapper-hook.js +544 -0
- package/.claude/hooks/secret-leak-detector.js +216 -0
- package/.claude/hooks/session-reviver.js +514 -0
- package/.claude/hooks/slash-command-prefetch.js +1145 -0
- package/.claude/hooks/stale-work-detector.js +205 -0
- package/.claude/hooks/stop-continue-hook.js +414 -0
- package/.claude/hooks/todo-maintenance.js +522 -0
- package/.claude/hooks/todo-processing-prompt.md +75 -0
- package/.claude/hooks/usage-optimizer.js +791 -0
- package/.claude/mcp/README.md +246 -0
- package/.claude/settings.json.template +168 -0
- package/.mcp.json.template +207 -0
- package/CLAUDE.md +340 -0
- package/CLAUDE.md.gentyr-section +89 -0
- package/LICENSE +21 -0
- package/README.md +297 -0
- package/cli/commands/init.js +471 -0
- package/cli/commands/migrate.js +132 -0
- package/cli/commands/protect.js +271 -0
- package/cli/commands/scaffold.js +48 -0
- package/cli/commands/status.js +133 -0
- package/cli/commands/sync.js +101 -0
- package/cli/commands/uninstall.js +207 -0
- package/cli/index.js +111 -0
- package/cli/lib/config-gen.js +214 -0
- package/cli/lib/resolve-framework.js +97 -0
- package/cli/lib/state.js +140 -0
- package/cli/lib/symlinks.js +260 -0
- package/docs/AUTOMATION-SYSTEMS.md +484 -0
- package/docs/BINARY-PATCHING.md +212 -0
- package/docs/CHANGELOG.md +2830 -0
- package/docs/CREDENTIAL-DETECTION.md +151 -0
- package/docs/CTO-DASHBOARD.md +476 -0
- package/docs/DEPLOYMENT-FLOW.md +477 -0
- package/docs/DEVELOPER.md +116 -0
- package/docs/Executive.md +372 -0
- package/docs/SECRET-PATHS.md +77 -0
- package/docs/SETUP-GUIDE.md +419 -0
- package/docs/STACK.md +109 -0
- package/docs/TESTING.md +440 -0
- package/docs/assets/claude-logo.svg +3 -0
- package/docs/sessions/2026-01-24-spec-suite-implementation.md +190 -0
- package/docs/sessions/2026-02-15-feedback-e2e-audit.md +484 -0
- package/docs/sessions/2026-02-20-credential-rotation-experiments.md +340 -0
- package/docs/sessions/TEST-COVERAGE-REPORT-2026-02-20.md +168 -0
- package/docs/shared/EPHEMERAL-STATE-FILES.md +115 -0
- package/docs/shared/PROTECTION-SYSTEM.md +341 -0
- package/husky/post-commit +10 -0
- package/husky/pre-commit +40 -0
- package/husky/pre-push +94 -0
- package/package.json +43 -0
- package/packages/cto-dashboard/package-lock.json +3510 -0
- package/packages/cto-dashboard/package.json +41 -0
- package/packages/cto-dashboard/pnpm-lock.yaml +2168 -0
- package/packages/mcp-servers/dist/__testUtils__/fixtures.d.ts +220 -0
- package/packages/mcp-servers/dist/__testUtils__/fixtures.d.ts.map +1 -0
- package/packages/mcp-servers/dist/__testUtils__/fixtures.js +376 -0
- package/packages/mcp-servers/dist/__testUtils__/fixtures.js.map +1 -0
- package/packages/mcp-servers/dist/__testUtils__/index.d.ts +121 -0
- package/packages/mcp-servers/dist/__testUtils__/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/__testUtils__/index.js +180 -0
- package/packages/mcp-servers/dist/__testUtils__/index.js.map +1 -0
- package/packages/mcp-servers/dist/__testUtils__/schemas.d.ts +84 -0
- package/packages/mcp-servers/dist/__testUtils__/schemas.d.ts.map +1 -0
- package/packages/mcp-servers/dist/__testUtils__/schemas.js +309 -0
- package/packages/mcp-servers/dist/__testUtils__/schemas.js.map +1 -0
- package/packages/mcp-servers/dist/agent-reports/index.d.ts +7 -0
- package/packages/mcp-servers/dist/agent-reports/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/agent-reports/index.js +8 -0
- package/packages/mcp-servers/dist/agent-reports/index.js.map +1 -0
- package/packages/mcp-servers/dist/agent-reports/server.d.ts +22 -0
- package/packages/mcp-servers/dist/agent-reports/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/agent-reports/server.js +535 -0
- package/packages/mcp-servers/dist/agent-reports/server.js.map +1 -0
- package/packages/mcp-servers/dist/agent-reports/types.d.ts +258 -0
- package/packages/mcp-servers/dist/agent-reports/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/agent-reports/types.js +81 -0
- package/packages/mcp-servers/dist/agent-reports/types.js.map +1 -0
- package/packages/mcp-servers/dist/agent-tracker/index.d.ts +5 -0
- package/packages/mcp-servers/dist/agent-tracker/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/agent-tracker/index.js +5 -0
- package/packages/mcp-servers/dist/agent-tracker/index.js.map +1 -0
- package/packages/mcp-servers/dist/agent-tracker/server.d.ts +12 -0
- package/packages/mcp-servers/dist/agent-tracker/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/agent-tracker/server.js +919 -0
- package/packages/mcp-servers/dist/agent-tracker/server.js.map +1 -0
- package/packages/mcp-servers/dist/agent-tracker/types.d.ts +328 -0
- package/packages/mcp-servers/dist/agent-tracker/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/agent-tracker/types.js +128 -0
- package/packages/mcp-servers/dist/agent-tracker/types.js.map +1 -0
- package/packages/mcp-servers/dist/chrome-bridge/browser-tips.d.ts +27 -0
- package/packages/mcp-servers/dist/chrome-bridge/browser-tips.d.ts.map +1 -0
- package/packages/mcp-servers/dist/chrome-bridge/browser-tips.js +167 -0
- package/packages/mcp-servers/dist/chrome-bridge/browser-tips.js.map +1 -0
- package/packages/mcp-servers/dist/chrome-bridge/index.d.ts +6 -0
- package/packages/mcp-servers/dist/chrome-bridge/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/chrome-bridge/index.js +6 -0
- package/packages/mcp-servers/dist/chrome-bridge/index.js.map +1 -0
- package/packages/mcp-servers/dist/chrome-bridge/server.d.ts +13 -0
- package/packages/mcp-servers/dist/chrome-bridge/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/chrome-bridge/server.js +959 -0
- package/packages/mcp-servers/dist/chrome-bridge/server.js.map +1 -0
- package/packages/mcp-servers/dist/chrome-bridge/types.d.ts +41 -0
- package/packages/mcp-servers/dist/chrome-bridge/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/chrome-bridge/types.js +8 -0
- package/packages/mcp-servers/dist/chrome-bridge/types.js.map +1 -0
- package/packages/mcp-servers/dist/cloudflare/index.d.ts +8 -0
- package/packages/mcp-servers/dist/cloudflare/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/cloudflare/index.js +8 -0
- package/packages/mcp-servers/dist/cloudflare/index.js.map +1 -0
- package/packages/mcp-servers/dist/cloudflare/server.d.ts +16 -0
- package/packages/mcp-servers/dist/cloudflare/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/cloudflare/server.js +253 -0
- package/packages/mcp-servers/dist/cloudflare/server.js.map +1 -0
- package/packages/mcp-servers/dist/cloudflare/types.d.ts +141 -0
- package/packages/mcp-servers/dist/cloudflare/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/cloudflare/types.js +53 -0
- package/packages/mcp-servers/dist/cloudflare/types.js.map +1 -0
- package/packages/mcp-servers/dist/codecov/index.d.ts +7 -0
- package/packages/mcp-servers/dist/codecov/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/codecov/index.js +7 -0
- package/packages/mcp-servers/dist/codecov/index.js.map +1 -0
- package/packages/mcp-servers/dist/codecov/server.d.ts +21 -0
- package/packages/mcp-servers/dist/codecov/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/codecov/server.js +376 -0
- package/packages/mcp-servers/dist/codecov/server.js.map +1 -0
- package/packages/mcp-servers/dist/codecov/types.d.ts +269 -0
- package/packages/mcp-servers/dist/codecov/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/codecov/types.js +128 -0
- package/packages/mcp-servers/dist/codecov/types.js.map +1 -0
- package/packages/mcp-servers/dist/cto-report/index.d.ts +9 -0
- package/packages/mcp-servers/dist/cto-report/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/cto-report/index.js +9 -0
- package/packages/mcp-servers/dist/cto-report/index.js.map +1 -0
- package/packages/mcp-servers/dist/cto-report/server.d.ts +14 -0
- package/packages/mcp-servers/dist/cto-report/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/cto-report/server.js +859 -0
- package/packages/mcp-servers/dist/cto-report/server.js.map +1 -0
- package/packages/mcp-servers/dist/cto-report/types.d.ts +213 -0
- package/packages/mcp-servers/dist/cto-report/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/cto-report/types.js +29 -0
- package/packages/mcp-servers/dist/cto-report/types.js.map +1 -0
- package/packages/mcp-servers/dist/cto-reports/index.d.ts +7 -0
- package/packages/mcp-servers/dist/cto-reports/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/cto-reports/index.js +8 -0
- package/packages/mcp-servers/dist/cto-reports/index.js.map +1 -0
- package/packages/mcp-servers/dist/cto-reports/server.d.ts +20 -0
- package/packages/mcp-servers/dist/cto-reports/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/cto-reports/server.js +538 -0
- package/packages/mcp-servers/dist/cto-reports/server.js.map +1 -0
- package/packages/mcp-servers/dist/cto-reports/types.d.ts +236 -0
- package/packages/mcp-servers/dist/cto-reports/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/cto-reports/types.js +77 -0
- package/packages/mcp-servers/dist/cto-reports/types.js.map +1 -0
- package/packages/mcp-servers/dist/deputy-cto/index.d.ts +7 -0
- package/packages/mcp-servers/dist/deputy-cto/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/deputy-cto/index.js +8 -0
- package/packages/mcp-servers/dist/deputy-cto/index.js.map +1 -0
- package/packages/mcp-servers/dist/deputy-cto/server.d.ts +23 -0
- package/packages/mcp-servers/dist/deputy-cto/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/deputy-cto/server.js +1700 -0
- package/packages/mcp-servers/dist/deputy-cto/server.js.map +1 -0
- package/packages/mcp-servers/dist/deputy-cto/types.d.ts +439 -0
- package/packages/mcp-servers/dist/deputy-cto/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/deputy-cto/types.js +102 -0
- package/packages/mcp-servers/dist/deputy-cto/types.js.map +1 -0
- package/packages/mcp-servers/dist/elastic-logs/index.d.ts +5 -0
- package/packages/mcp-servers/dist/elastic-logs/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/elastic-logs/index.js +5 -0
- package/packages/mcp-servers/dist/elastic-logs/index.js.map +1 -0
- package/packages/mcp-servers/dist/elastic-logs/server.d.ts +18 -0
- package/packages/mcp-servers/dist/elastic-logs/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/elastic-logs/server.js +259 -0
- package/packages/mcp-servers/dist/elastic-logs/server.js.map +1 -0
- package/packages/mcp-servers/dist/elastic-logs/types.d.ts +107 -0
- package/packages/mcp-servers/dist/elastic-logs/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/elastic-logs/types.js +31 -0
- package/packages/mcp-servers/dist/elastic-logs/types.js.map +1 -0
- package/packages/mcp-servers/dist/feedback-explorer/index.d.ts +2 -0
- package/packages/mcp-servers/dist/feedback-explorer/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/feedback-explorer/index.js +2 -0
- package/packages/mcp-servers/dist/feedback-explorer/index.js.map +1 -0
- package/packages/mcp-servers/dist/feedback-explorer/server.d.ts +21 -0
- package/packages/mcp-servers/dist/feedback-explorer/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/feedback-explorer/server.js +580 -0
- package/packages/mcp-servers/dist/feedback-explorer/server.js.map +1 -0
- package/packages/mcp-servers/dist/feedback-explorer/types.d.ts +331 -0
- package/packages/mcp-servers/dist/feedback-explorer/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/feedback-explorer/types.js +40 -0
- package/packages/mcp-servers/dist/feedback-explorer/types.js.map +1 -0
- package/packages/mcp-servers/dist/feedback-reporter/index.d.ts +9 -0
- package/packages/mcp-servers/dist/feedback-reporter/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/feedback-reporter/index.js +9 -0
- package/packages/mcp-servers/dist/feedback-reporter/index.js.map +1 -0
- package/packages/mcp-servers/dist/feedback-reporter/server.d.ts +36 -0
- package/packages/mcp-servers/dist/feedback-reporter/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/feedback-reporter/server.js +392 -0
- package/packages/mcp-servers/dist/feedback-reporter/server.js.map +1 -0
- package/packages/mcp-servers/dist/feedback-reporter/types.d.ts +152 -0
- package/packages/mcp-servers/dist/feedback-reporter/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/feedback-reporter/types.js +67 -0
- package/packages/mcp-servers/dist/feedback-reporter/types.js.map +1 -0
- package/packages/mcp-servers/dist/github/index.d.ts +7 -0
- package/packages/mcp-servers/dist/github/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/github/index.js +7 -0
- package/packages/mcp-servers/dist/github/index.js.map +1 -0
- package/packages/mcp-servers/dist/github/server.d.ts +15 -0
- package/packages/mcp-servers/dist/github/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/github/server.js +686 -0
- package/packages/mcp-servers/dist/github/server.js.map +1 -0
- package/packages/mcp-servers/dist/github/types.d.ts +660 -0
- package/packages/mcp-servers/dist/github/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/github/types.js +209 -0
- package/packages/mcp-servers/dist/github/types.js.map +1 -0
- package/packages/mcp-servers/dist/index.d.ts +30 -0
- package/packages/mcp-servers/dist/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/index.js +32 -0
- package/packages/mcp-servers/dist/index.js.map +1 -0
- package/packages/mcp-servers/dist/makerkit-docs/index.d.ts +5 -0
- package/packages/mcp-servers/dist/makerkit-docs/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/makerkit-docs/index.js +5 -0
- package/packages/mcp-servers/dist/makerkit-docs/index.js.map +1 -0
- package/packages/mcp-servers/dist/makerkit-docs/server.d.ts +15 -0
- package/packages/mcp-servers/dist/makerkit-docs/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/makerkit-docs/server.js +252 -0
- package/packages/mcp-servers/dist/makerkit-docs/server.js.map +1 -0
- package/packages/mcp-servers/dist/makerkit-docs/types.d.ts +74 -0
- package/packages/mcp-servers/dist/makerkit-docs/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/makerkit-docs/types.js +20 -0
- package/packages/mcp-servers/dist/makerkit-docs/types.js.map +1 -0
- package/packages/mcp-servers/dist/onepassword/index.d.ts +2 -0
- package/packages/mcp-servers/dist/onepassword/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/onepassword/index.js +2 -0
- package/packages/mcp-servers/dist/onepassword/index.js.map +1 -0
- package/packages/mcp-servers/dist/onepassword/server.d.ts +2 -0
- package/packages/mcp-servers/dist/onepassword/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/onepassword/server.js +159 -0
- package/packages/mcp-servers/dist/onepassword/server.js.map +1 -0
- package/packages/mcp-servers/dist/onepassword/types.d.ts +55 -0
- package/packages/mcp-servers/dist/onepassword/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/onepassword/types.js +22 -0
- package/packages/mcp-servers/dist/onepassword/types.js.map +1 -0
- package/packages/mcp-servers/dist/playwright/helpers.d.ts +20 -0
- package/packages/mcp-servers/dist/playwright/helpers.d.ts.map +1 -0
- package/packages/mcp-servers/dist/playwright/helpers.js +31 -0
- package/packages/mcp-servers/dist/playwright/helpers.js.map +1 -0
- package/packages/mcp-servers/dist/playwright/index.d.ts +5 -0
- package/packages/mcp-servers/dist/playwright/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/playwright/index.js +5 -0
- package/packages/mcp-servers/dist/playwright/index.js.map +1 -0
- package/packages/mcp-servers/dist/playwright/server.d.ts +13 -0
- package/packages/mcp-servers/dist/playwright/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/playwright/server.js +1201 -0
- package/packages/mcp-servers/dist/playwright/server.js.map +1 -0
- package/packages/mcp-servers/dist/playwright/types.d.ts +216 -0
- package/packages/mcp-servers/dist/playwright/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/playwright/types.js +172 -0
- package/packages/mcp-servers/dist/playwright/types.js.map +1 -0
- package/packages/mcp-servers/dist/playwright-feedback/browser-manager.d.ts +39 -0
- package/packages/mcp-servers/dist/playwright-feedback/browser-manager.d.ts.map +1 -0
- package/packages/mcp-servers/dist/playwright-feedback/browser-manager.js +71 -0
- package/packages/mcp-servers/dist/playwright-feedback/browser-manager.js.map +1 -0
- package/packages/mcp-servers/dist/playwright-feedback/index.d.ts +5 -0
- package/packages/mcp-servers/dist/playwright-feedback/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/playwright-feedback/index.js +5 -0
- package/packages/mcp-servers/dist/playwright-feedback/index.js.map +1 -0
- package/packages/mcp-servers/dist/playwright-feedback/server.d.ts +34 -0
- package/packages/mcp-servers/dist/playwright-feedback/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/playwright-feedback/server.js +538 -0
- package/packages/mcp-servers/dist/playwright-feedback/server.js.map +1 -0
- package/packages/mcp-servers/dist/playwright-feedback/types.d.ts +305 -0
- package/packages/mcp-servers/dist/playwright-feedback/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/playwright-feedback/types.js +123 -0
- package/packages/mcp-servers/dist/playwright-feedback/types.js.map +1 -0
- package/packages/mcp-servers/dist/product-manager/server.d.ts +17 -0
- package/packages/mcp-servers/dist/product-manager/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/product-manager/server.js +690 -0
- package/packages/mcp-servers/dist/product-manager/server.js.map +1 -0
- package/packages/mcp-servers/dist/product-manager/types.d.ts +286 -0
- package/packages/mcp-servers/dist/product-manager/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/product-manager/types.js +99 -0
- package/packages/mcp-servers/dist/product-manager/types.js.map +1 -0
- package/packages/mcp-servers/dist/programmatic-feedback/index.d.ts +7 -0
- package/packages/mcp-servers/dist/programmatic-feedback/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/programmatic-feedback/index.js +7 -0
- package/packages/mcp-servers/dist/programmatic-feedback/index.js.map +1 -0
- package/packages/mcp-servers/dist/programmatic-feedback/sandbox.d.ts +19 -0
- package/packages/mcp-servers/dist/programmatic-feedback/sandbox.d.ts.map +1 -0
- package/packages/mcp-servers/dist/programmatic-feedback/sandbox.js +174 -0
- package/packages/mcp-servers/dist/programmatic-feedback/sandbox.js.map +1 -0
- package/packages/mcp-servers/dist/programmatic-feedback/server.d.ts +35 -0
- package/packages/mcp-servers/dist/programmatic-feedback/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/programmatic-feedback/server.js +465 -0
- package/packages/mcp-servers/dist/programmatic-feedback/server.js.map +1 -0
- package/packages/mcp-servers/dist/programmatic-feedback/types.d.ts +127 -0
- package/packages/mcp-servers/dist/programmatic-feedback/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/programmatic-feedback/types.js +80 -0
- package/packages/mcp-servers/dist/programmatic-feedback/types.js.map +1 -0
- package/packages/mcp-servers/dist/render/index.d.ts +8 -0
- package/packages/mcp-servers/dist/render/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/render/index.js +8 -0
- package/packages/mcp-servers/dist/render/index.js.map +1 -0
- package/packages/mcp-servers/dist/render/server.d.ts +15 -0
- package/packages/mcp-servers/dist/render/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/render/server.js +428 -0
- package/packages/mcp-servers/dist/render/server.js.map +1 -0
- package/packages/mcp-servers/dist/render/types.d.ts +273 -0
- package/packages/mcp-servers/dist/render/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/render/types.js +102 -0
- package/packages/mcp-servers/dist/render/types.js.map +1 -0
- package/packages/mcp-servers/dist/resend/index.d.ts +7 -0
- package/packages/mcp-servers/dist/resend/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/resend/index.js +7 -0
- package/packages/mcp-servers/dist/resend/index.js.map +1 -0
- package/packages/mcp-servers/dist/resend/server.d.ts +15 -0
- package/packages/mcp-servers/dist/resend/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/resend/server.js +298 -0
- package/packages/mcp-servers/dist/resend/server.js.map +1 -0
- package/packages/mcp-servers/dist/resend/types.d.ts +222 -0
- package/packages/mcp-servers/dist/resend/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/resend/types.js +58 -0
- package/packages/mcp-servers/dist/resend/types.js.map +1 -0
- package/packages/mcp-servers/dist/review-queue/index.d.ts +6 -0
- package/packages/mcp-servers/dist/review-queue/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/review-queue/index.js +6 -0
- package/packages/mcp-servers/dist/review-queue/index.js.map +1 -0
- package/packages/mcp-servers/dist/review-queue/server.d.ts +17 -0
- package/packages/mcp-servers/dist/review-queue/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/review-queue/server.js +348 -0
- package/packages/mcp-servers/dist/review-queue/server.js.map +1 -0
- package/packages/mcp-servers/dist/review-queue/types.d.ts +162 -0
- package/packages/mcp-servers/dist/review-queue/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/review-queue/types.js +56 -0
- package/packages/mcp-servers/dist/review-queue/types.js.map +1 -0
- package/packages/mcp-servers/dist/secret-sync/server.d.ts +19 -0
- package/packages/mcp-servers/dist/secret-sync/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/secret-sync/server.js +1139 -0
- package/packages/mcp-servers/dist/secret-sync/server.js.map +1 -0
- package/packages/mcp-servers/dist/secret-sync/types.d.ts +442 -0
- package/packages/mcp-servers/dist/secret-sync/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/secret-sync/types.js +113 -0
- package/packages/mcp-servers/dist/secret-sync/types.js.map +1 -0
- package/packages/mcp-servers/dist/session-events/index.d.ts +5 -0
- package/packages/mcp-servers/dist/session-events/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/session-events/index.js +5 -0
- package/packages/mcp-servers/dist/session-events/index.js.map +1 -0
- package/packages/mcp-servers/dist/session-events/server.d.ts +11 -0
- package/packages/mcp-servers/dist/session-events/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/session-events/server.js +290 -0
- package/packages/mcp-servers/dist/session-events/server.js.map +1 -0
- package/packages/mcp-servers/dist/session-events/types.d.ts +213 -0
- package/packages/mcp-servers/dist/session-events/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/session-events/types.js +69 -0
- package/packages/mcp-servers/dist/session-events/types.js.map +1 -0
- package/packages/mcp-servers/dist/session-restart/index.d.ts +9 -0
- package/packages/mcp-servers/dist/session-restart/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/session-restart/index.js +9 -0
- package/packages/mcp-servers/dist/session-restart/index.js.map +1 -0
- package/packages/mcp-servers/dist/session-restart/server.d.ts +20 -0
- package/packages/mcp-servers/dist/session-restart/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/session-restart/server.js +411 -0
- package/packages/mcp-servers/dist/session-restart/server.js.map +1 -0
- package/packages/mcp-servers/dist/session-restart/types.d.ts +26 -0
- package/packages/mcp-servers/dist/session-restart/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/session-restart/types.js +16 -0
- package/packages/mcp-servers/dist/session-restart/types.js.map +1 -0
- package/packages/mcp-servers/dist/setup-helper/index.d.ts +5 -0
- package/packages/mcp-servers/dist/setup-helper/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/setup-helper/index.js +5 -0
- package/packages/mcp-servers/dist/setup-helper/index.js.map +1 -0
- package/packages/mcp-servers/dist/setup-helper/server.d.ts +14 -0
- package/packages/mcp-servers/dist/setup-helper/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/setup-helper/server.js +454 -0
- package/packages/mcp-servers/dist/setup-helper/server.js.map +1 -0
- package/packages/mcp-servers/dist/setup-helper/types.d.ts +81 -0
- package/packages/mcp-servers/dist/setup-helper/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/setup-helper/types.js +41 -0
- package/packages/mcp-servers/dist/setup-helper/types.js.map +1 -0
- package/packages/mcp-servers/dist/shared/audited-server.d.ts +31 -0
- package/packages/mcp-servers/dist/shared/audited-server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/shared/audited-server.js +126 -0
- package/packages/mcp-servers/dist/shared/audited-server.js.map +1 -0
- package/packages/mcp-servers/dist/shared/constants.d.ts +26 -0
- package/packages/mcp-servers/dist/shared/constants.d.ts.map +1 -0
- package/packages/mcp-servers/dist/shared/constants.js +41 -0
- package/packages/mcp-servers/dist/shared/constants.js.map +1 -0
- package/packages/mcp-servers/dist/shared/index.d.ts +6 -0
- package/packages/mcp-servers/dist/shared/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/shared/index.js +6 -0
- package/packages/mcp-servers/dist/shared/index.js.map +1 -0
- package/packages/mcp-servers/dist/shared/readonly-db.d.ts +11 -0
- package/packages/mcp-servers/dist/shared/readonly-db.d.ts.map +1 -0
- package/packages/mcp-servers/dist/shared/readonly-db.js +47 -0
- package/packages/mcp-servers/dist/shared/readonly-db.js.map +1 -0
- package/packages/mcp-servers/dist/shared/resolve-framework.d.ts +20 -0
- package/packages/mcp-servers/dist/shared/resolve-framework.d.ts.map +1 -0
- package/packages/mcp-servers/dist/shared/resolve-framework.js +65 -0
- package/packages/mcp-servers/dist/shared/resolve-framework.js.map +1 -0
- package/packages/mcp-servers/dist/shared/server.d.ts +86 -0
- package/packages/mcp-servers/dist/shared/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/shared/server.js +291 -0
- package/packages/mcp-servers/dist/shared/server.js.map +1 -0
- package/packages/mcp-servers/dist/shared/types.d.ts +113 -0
- package/packages/mcp-servers/dist/shared/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/shared/types.js +36 -0
- package/packages/mcp-servers/dist/shared/types.js.map +1 -0
- package/packages/mcp-servers/dist/show/server.d.ts +12 -0
- package/packages/mcp-servers/dist/show/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/show/server.js +97 -0
- package/packages/mcp-servers/dist/show/server.js.map +1 -0
- package/packages/mcp-servers/dist/show/types.d.ts +19 -0
- package/packages/mcp-servers/dist/show/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/show/types.js +32 -0
- package/packages/mcp-servers/dist/show/types.js.map +1 -0
- package/packages/mcp-servers/dist/specs-browser/index.d.ts +5 -0
- package/packages/mcp-servers/dist/specs-browser/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/specs-browser/index.js +5 -0
- package/packages/mcp-servers/dist/specs-browser/index.js.map +1 -0
- package/packages/mcp-servers/dist/specs-browser/server.d.ts +13 -0
- package/packages/mcp-servers/dist/specs-browser/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/specs-browser/server.js +692 -0
- package/packages/mcp-servers/dist/specs-browser/server.js.map +1 -0
- package/packages/mcp-servers/dist/specs-browser/types.d.ts +337 -0
- package/packages/mcp-servers/dist/specs-browser/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/specs-browser/types.js +134 -0
- package/packages/mcp-servers/dist/specs-browser/types.js.map +1 -0
- package/packages/mcp-servers/dist/supabase/index.d.ts +10 -0
- package/packages/mcp-servers/dist/supabase/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/supabase/index.js +10 -0
- package/packages/mcp-servers/dist/supabase/index.js.map +1 -0
- package/packages/mcp-servers/dist/supabase/server.d.ts +20 -0
- package/packages/mcp-servers/dist/supabase/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/supabase/server.js +451 -0
- package/packages/mcp-servers/dist/supabase/server.js.map +1 -0
- package/packages/mcp-servers/dist/supabase/types.d.ts +196 -0
- package/packages/mcp-servers/dist/supabase/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/supabase/types.js +76 -0
- package/packages/mcp-servers/dist/supabase/types.js.map +1 -0
- package/packages/mcp-servers/dist/todo-db/index.d.ts +5 -0
- package/packages/mcp-servers/dist/todo-db/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/todo-db/index.js +5 -0
- package/packages/mcp-servers/dist/todo-db/index.js.map +1 -0
- package/packages/mcp-servers/dist/todo-db/server.d.ts +13 -0
- package/packages/mcp-servers/dist/todo-db/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/todo-db/server.js +649 -0
- package/packages/mcp-servers/dist/todo-db/server.js.map +1 -0
- package/packages/mcp-servers/dist/todo-db/types.d.ts +225 -0
- package/packages/mcp-servers/dist/todo-db/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/todo-db/types.js +69 -0
- package/packages/mcp-servers/dist/todo-db/types.js.map +1 -0
- package/packages/mcp-servers/dist/user-feedback/index.d.ts +7 -0
- package/packages/mcp-servers/dist/user-feedback/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/user-feedback/index.js +8 -0
- package/packages/mcp-servers/dist/user-feedback/index.js.map +1 -0
- package/packages/mcp-servers/dist/user-feedback/server.d.ts +25 -0
- package/packages/mcp-servers/dist/user-feedback/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/user-feedback/server.js +914 -0
- package/packages/mcp-servers/dist/user-feedback/server.js.map +1 -0
- package/packages/mcp-servers/dist/user-feedback/types.d.ts +415 -0
- package/packages/mcp-servers/dist/user-feedback/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/user-feedback/types.js +132 -0
- package/packages/mcp-servers/dist/user-feedback/types.js.map +1 -0
- package/packages/mcp-servers/dist/vercel/index.d.ts +9 -0
- package/packages/mcp-servers/dist/vercel/index.d.ts.map +1 -0
- package/packages/mcp-servers/dist/vercel/index.js +9 -0
- package/packages/mcp-servers/dist/vercel/index.js.map +1 -0
- package/packages/mcp-servers/dist/vercel/server.d.ts +17 -0
- package/packages/mcp-servers/dist/vercel/server.d.ts.map +1 -0
- package/packages/mcp-servers/dist/vercel/server.js +265 -0
- package/packages/mcp-servers/dist/vercel/server.js.map +1 -0
- package/packages/mcp-servers/dist/vercel/types.d.ts +189 -0
- package/packages/mcp-servers/dist/vercel/types.d.ts.map +1 -0
- package/packages/mcp-servers/dist/vercel/types.js +65 -0
- package/packages/mcp-servers/dist/vercel/types.js.map +1 -0
- package/packages/mcp-servers/package-lock.json +3765 -0
- package/packages/mcp-servers/package.json +64 -0
- package/packages/mcp-servers/test/reporters/test-failure-reporter.ts +372 -0
- package/packages/mcp-servers/vitest.config.ts +27 -0
- package/scripts/__tests__/README.md +163 -0
- package/scripts/apply-credential-hardening.sh +271 -0
- package/scripts/credential-providers/manual.js +56 -0
- package/scripts/credential-providers/onepassword.js +85 -0
- package/scripts/credential-providers/provider-interface.js +104 -0
- package/scripts/encrypt-credential.js +337 -0
- package/scripts/feedback-launcher.js +338 -0
- package/scripts/feedback-orchestrator.js +373 -0
- package/scripts/fix-mcp-launcher-issues.sh +97 -0
- package/scripts/force-spawn-tasks.js +651 -0
- package/scripts/force-triage-reports.js +560 -0
- package/scripts/generate-protected-actions-spec.js +142 -0
- package/scripts/generate-proxy-certs.sh +158 -0
- package/scripts/grant-chrome-ext-permissions.sh +242 -0
- package/scripts/mcp-launcher.js +125 -0
- package/scripts/merge-settings.cjs +167 -0
- package/scripts/patch-clawd.py +844 -0
- package/scripts/patch-credential-cache.py +313 -0
- package/scripts/patches/credential-file-guard-patched.mjs +573 -0
- package/scripts/patches/credential-file-guard.js.patched +573 -0
- package/scripts/patches/verify-tokenizer.mjs +132 -0
- package/scripts/protect-framework.sh +478 -0
- package/scripts/readme-chrome.template +12 -0
- package/scripts/reap-completed-agents.js +439 -0
- package/scripts/reinstall.sh +86 -0
- package/scripts/resign-node.sh +185 -0
- package/scripts/rotation-proxy.js +656 -0
- package/scripts/rotation-stress-monitor.mjs +862 -0
- package/scripts/setup-automation-service.sh +648 -0
- package/scripts/setup-check.js +251 -0
- package/scripts/watch-claude-version.js +142 -0
- package/specs/framework/CORE-INVARIANTS.md +161 -0
- package/specs/patterns/AGENT-PATTERNS.md +223 -0
- package/specs/patterns/HOOK-PATTERNS.md +242 -0
- package/specs/patterns/MCP-SERVER-PATTERNS.md +144 -0
- package/templates/config/gitignore.template +14 -0
- package/templates/config/merge-chain-check.yml.template +51 -0
- package/templates/config/package.json.template +18 -0
- package/templates/config/pnpm-workspace.yaml +5 -0
- package/templates/config/services.json.template +18 -0
- package/templates/config/tsconfig.base.json +17 -0
- package/templates/scaffold/integrations/_template/.gitkeep +0 -0
- package/templates/scaffold/packages/logger/package.json +17 -0
- package/templates/scaffold/packages/logger/src/logger.ts +44 -0
- package/templates/scaffold/packages/shared/package.json +17 -0
- package/templates/scaffold/packages/shared/src/errors.ts +43 -0
- package/templates/scaffold/products/_product/apps/backend/package.json +21 -0
- package/templates/scaffold/products/_product/apps/backend/src/index.ts +17 -0
- package/templates/scaffold/products/_product/apps/extension/.gitkeep +0 -0
- package/templates/scaffold/products/_product/apps/web/.gitkeep +0 -0
- package/templates/scaffold/specs/global/.gitkeep +0 -0
- package/templates/scaffold/specs/local/.gitkeep +0 -0
- package/templates/scaffold/specs/reference/.gitkeep +0 -0
- package/version.json +15 -0
|
@@ -0,0 +1,959 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Chrome Bridge MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Proxies MCP tool calls to the Claude Chrome Extension via its Unix domain
|
|
6
|
+
* socket at /tmp/claude-mcp-browser-bridge-{username}/*.sock.
|
|
7
|
+
*
|
|
8
|
+
* Protocol: Length-prefixed JSON (4-byte LE uint32 length + UTF-8 JSON payload)
|
|
9
|
+
* over Unix domain socket. The Chrome extension handles all browser automation;
|
|
10
|
+
* this server is a pure proxy.
|
|
11
|
+
*/
|
|
12
|
+
import * as net from 'net';
|
|
13
|
+
import * as fs from 'fs';
|
|
14
|
+
import * as os from 'os';
|
|
15
|
+
import * as path from 'path';
|
|
16
|
+
import * as readline from 'readline';
|
|
17
|
+
import { JsonRpcRequestSchema, McpToolCallParamsSchema, JSON_RPC_ERRORS, } from '../shared/types.js';
|
|
18
|
+
import { BrowserTipTracker } from './browser-tips.js';
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// Chrome Bridge Socket Client
|
|
21
|
+
// ============================================================================
|
|
22
|
+
class ChromeBridgeClient {
|
|
23
|
+
connections = new Map();
|
|
24
|
+
reconnectAttempts = new Map();
|
|
25
|
+
requestQueues = new Map();
|
|
26
|
+
tabRoutes = new Map(); // tabId -> socketPath
|
|
27
|
+
tabUrls = new Map(); // tabId -> last known URL
|
|
28
|
+
tipTracker = new BrowserTipTracker();
|
|
29
|
+
socketDir;
|
|
30
|
+
static CLIENT_ID = 'gentyr';
|
|
31
|
+
static MAX_RECONNECT_ATTEMPTS = 100;
|
|
32
|
+
static BASE_RECONNECT_DELAY_MS = 100;
|
|
33
|
+
static MAX_RECONNECT_DELAY_MS = 30_000;
|
|
34
|
+
static TOOL_TIMEOUT_MS = 120_000;
|
|
35
|
+
static TABS_CONTEXT_TIMEOUT_MS = 2_000;
|
|
36
|
+
constructor() {
|
|
37
|
+
const username = os.userInfo().username || 'default';
|
|
38
|
+
this.socketDir = path.join('/tmp', `claude-mcp-browser-bridge-${username}`);
|
|
39
|
+
this.discoverAndConnect();
|
|
40
|
+
}
|
|
41
|
+
// --- Socket Discovery ---
|
|
42
|
+
discoverSockets() {
|
|
43
|
+
try {
|
|
44
|
+
if (!fs.existsSync(this.socketDir)) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
const entries = fs.readdirSync(this.socketDir);
|
|
48
|
+
const sockets = [];
|
|
49
|
+
for (const entry of entries) {
|
|
50
|
+
if (!entry.endsWith('.sock'))
|
|
51
|
+
continue;
|
|
52
|
+
const fullPath = path.join(this.socketDir, entry);
|
|
53
|
+
if (this.validateSocketOwnership(fullPath)) {
|
|
54
|
+
sockets.push(fullPath);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return sockets;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
validateSocketOwnership(socketPath) {
|
|
64
|
+
try {
|
|
65
|
+
const getuid = process.getuid;
|
|
66
|
+
if (!getuid)
|
|
67
|
+
return false; // Not available on Windows
|
|
68
|
+
const stats = fs.statSync(socketPath);
|
|
69
|
+
return stats.uid === getuid();
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// --- Connection Management ---
|
|
76
|
+
discoverAndConnect() {
|
|
77
|
+
const sockets = this.discoverSockets();
|
|
78
|
+
if (sockets.length === 0) {
|
|
79
|
+
log('No Chrome extension sockets found. Is Chrome running with the Claude extension?');
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
for (const socketPath of sockets) {
|
|
83
|
+
if (!this.connections.has(socketPath)) {
|
|
84
|
+
this.connect(socketPath);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
log(`Found ${sockets.length} socket(s) in ${this.socketDir}`);
|
|
88
|
+
}
|
|
89
|
+
connect(socketPath) {
|
|
90
|
+
const socket = net.createConnection(socketPath);
|
|
91
|
+
socket.on('connect', () => {
|
|
92
|
+
this.connections.set(socketPath, socket);
|
|
93
|
+
this.reconnectAttempts.set(socketPath, 0);
|
|
94
|
+
log(`Connected to ${path.basename(socketPath)}`);
|
|
95
|
+
});
|
|
96
|
+
socket.on('error', (err) => {
|
|
97
|
+
if (err.code && ['ECONNREFUSED', 'ECONNRESET', 'EPIPE', 'ENOENT'].includes(err.code)) {
|
|
98
|
+
// Expected errors when browser closes - handled by close event
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
log(`Socket error (${path.basename(socketPath)}): ${err.message}`);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
socket.on('close', () => {
|
|
105
|
+
this.connections.delete(socketPath);
|
|
106
|
+
this.scheduleReconnect(socketPath);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
scheduleReconnect(socketPath) {
|
|
110
|
+
const attempts = this.reconnectAttempts.get(socketPath) ?? 0;
|
|
111
|
+
if (attempts >= ChromeBridgeClient.MAX_RECONNECT_ATTEMPTS) {
|
|
112
|
+
this.reconnectAttempts.delete(socketPath);
|
|
113
|
+
// Remove stale tab routes and cached URLs
|
|
114
|
+
for (const [tabId, sp] of this.tabRoutes) {
|
|
115
|
+
if (sp === socketPath) {
|
|
116
|
+
this.tabRoutes.delete(tabId);
|
|
117
|
+
this.tabUrls.delete(tabId);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const delay = Math.min(ChromeBridgeClient.BASE_RECONNECT_DELAY_MS * Math.pow(1.5, attempts), ChromeBridgeClient.MAX_RECONNECT_DELAY_MS);
|
|
123
|
+
this.reconnectAttempts.set(socketPath, attempts + 1);
|
|
124
|
+
setTimeout(() => {
|
|
125
|
+
if (!fs.existsSync(socketPath)) {
|
|
126
|
+
this.reconnectAttempts.delete(socketPath);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
this.connect(socketPath);
|
|
130
|
+
}, delay);
|
|
131
|
+
}
|
|
132
|
+
// --- Binary Framing Protocol ---
|
|
133
|
+
encodeMessage(payload) {
|
|
134
|
+
const json = JSON.stringify(payload);
|
|
135
|
+
const data = Buffer.from(json, 'utf-8');
|
|
136
|
+
const header = Buffer.allocUnsafe(4);
|
|
137
|
+
header.writeUInt32LE(data.length, 0);
|
|
138
|
+
return Buffer.concat([header, data]);
|
|
139
|
+
}
|
|
140
|
+
readResponse(socket, timeoutMs) {
|
|
141
|
+
return new Promise((resolve, reject) => {
|
|
142
|
+
let buffer = Buffer.alloc(0);
|
|
143
|
+
let expectedLength = null;
|
|
144
|
+
const timeout = setTimeout(() => {
|
|
145
|
+
cleanup();
|
|
146
|
+
reject(new Error('Response timeout'));
|
|
147
|
+
}, timeoutMs);
|
|
148
|
+
const onData = (chunk) => {
|
|
149
|
+
buffer = Buffer.concat([buffer, chunk]);
|
|
150
|
+
processBuffer();
|
|
151
|
+
};
|
|
152
|
+
const processBuffer = () => {
|
|
153
|
+
while (buffer.length >= 4) {
|
|
154
|
+
if (expectedLength === null) {
|
|
155
|
+
expectedLength = buffer.readUInt32LE(0);
|
|
156
|
+
}
|
|
157
|
+
if (buffer.length < 4 + expectedLength)
|
|
158
|
+
break;
|
|
159
|
+
const jsonBuf = buffer.subarray(4, 4 + expectedLength);
|
|
160
|
+
buffer = buffer.subarray(4 + expectedLength);
|
|
161
|
+
expectedLength = null;
|
|
162
|
+
try {
|
|
163
|
+
const parsed = JSON.parse(jsonBuf.toString('utf-8'));
|
|
164
|
+
// Skip notifications (have method but no result/error)
|
|
165
|
+
if ('method' in parsed && !('result' in parsed) && !('error' in parsed)) {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
cleanup();
|
|
169
|
+
resolve(parsed);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
catch (err) {
|
|
173
|
+
cleanup();
|
|
174
|
+
reject(new Error(`Failed to parse response: ${err}`));
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
const onError = (err) => {
|
|
180
|
+
cleanup();
|
|
181
|
+
reject(err);
|
|
182
|
+
};
|
|
183
|
+
const onClose = () => {
|
|
184
|
+
cleanup();
|
|
185
|
+
reject(new Error('Socket closed before response'));
|
|
186
|
+
};
|
|
187
|
+
const cleanup = () => {
|
|
188
|
+
clearTimeout(timeout);
|
|
189
|
+
socket.removeListener('data', onData);
|
|
190
|
+
socket.removeListener('error', onError);
|
|
191
|
+
socket.removeListener('close', onClose);
|
|
192
|
+
};
|
|
193
|
+
socket.on('data', onData);
|
|
194
|
+
socket.on('error', onError);
|
|
195
|
+
socket.on('close', onClose);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
// --- Tool Execution ---
|
|
199
|
+
async executeOnSocket(socketPath, toolName, args) {
|
|
200
|
+
const socket = this.connections.get(socketPath);
|
|
201
|
+
if (!socket || socket.destroyed) {
|
|
202
|
+
throw new Error(`Socket not connected: ${path.basename(socketPath)}`);
|
|
203
|
+
}
|
|
204
|
+
const request = {
|
|
205
|
+
method: 'execute_tool',
|
|
206
|
+
params: {
|
|
207
|
+
client_id: ChromeBridgeClient.CLIENT_ID,
|
|
208
|
+
tool: toolName,
|
|
209
|
+
args,
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
const timeoutMs = toolName === 'tabs_context_mcp'
|
|
213
|
+
? ChromeBridgeClient.TABS_CONTEXT_TIMEOUT_MS
|
|
214
|
+
: ChromeBridgeClient.TOOL_TIMEOUT_MS;
|
|
215
|
+
socket.write(this.encodeMessage(request));
|
|
216
|
+
return this.readResponse(socket, timeoutMs);
|
|
217
|
+
}
|
|
218
|
+
/** Serialize requests per socket to prevent response interleaving */
|
|
219
|
+
async executeOnSocketSerialized(socketPath, toolName, args) {
|
|
220
|
+
const previous = this.requestQueues.get(socketPath) ?? Promise.resolve();
|
|
221
|
+
let resolveQueue;
|
|
222
|
+
const current = new Promise((r) => { resolveQueue = r; });
|
|
223
|
+
this.requestQueues.set(socketPath, current);
|
|
224
|
+
await previous;
|
|
225
|
+
try {
|
|
226
|
+
return await this.executeOnSocket(socketPath, toolName, args);
|
|
227
|
+
}
|
|
228
|
+
finally {
|
|
229
|
+
resolveQueue();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
isContentScriptError(result) {
|
|
233
|
+
return result.isError === true && result.content.some((c) => c.type === 'text' && ((c.text?.includes('Cannot access contents')) ||
|
|
234
|
+
(c.text?.includes('must request permission'))));
|
|
235
|
+
}
|
|
236
|
+
async executeTool(toolName, args) {
|
|
237
|
+
// Refresh connections if none available
|
|
238
|
+
if (this.connections.size === 0) {
|
|
239
|
+
this.discoverAndConnect();
|
|
240
|
+
// Brief wait for connection
|
|
241
|
+
if (this.connections.size === 0) {
|
|
242
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (this.connections.size === 0) {
|
|
246
|
+
return {
|
|
247
|
+
content: [{
|
|
248
|
+
type: 'text',
|
|
249
|
+
text: 'Chrome extension not connected. Make sure Chrome is running with the Claude extension installed.',
|
|
250
|
+
}],
|
|
251
|
+
isError: true,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
// tabs_context_mcp queries all sockets and merges
|
|
255
|
+
if (toolName === 'tabs_context_mcp') {
|
|
256
|
+
return this.executeTabsContext(args);
|
|
257
|
+
}
|
|
258
|
+
// Route by tabId if available
|
|
259
|
+
const tabId = typeof args.tabId === 'number' ? args.tabId : undefined;
|
|
260
|
+
// Cache URL on navigate for tip hostname matching
|
|
261
|
+
if (toolName === 'navigate' && tabId !== undefined && typeof args.url === 'string') {
|
|
262
|
+
const url = args.url;
|
|
263
|
+
if (url !== 'forward' && url !== 'back') {
|
|
264
|
+
this.tabUrls.set(tabId, url.match(/^https?:\/\//) ? url : `https://${url}`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
let targetSocket;
|
|
268
|
+
if (tabId !== undefined) {
|
|
269
|
+
targetSocket = this.tabRoutes.get(tabId);
|
|
270
|
+
if (targetSocket && !this.connections.has(targetSocket)) {
|
|
271
|
+
this.tabRoutes.delete(tabId);
|
|
272
|
+
targetSocket = undefined;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if (!targetSocket) {
|
|
276
|
+
targetSocket = this.connections.keys().next().value;
|
|
277
|
+
}
|
|
278
|
+
if (!targetSocket) {
|
|
279
|
+
return {
|
|
280
|
+
content: [{ type: 'text', text: 'No connected sockets available' }],
|
|
281
|
+
isError: true,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
// Inject a tabId for tools that don't require one but need tab context
|
|
285
|
+
// (e.g., update_plan, switch_browser). The extension needs a tab to anchor its UI.
|
|
286
|
+
if (tabId === undefined) {
|
|
287
|
+
for (const [knownTabId, socketPath] of this.tabRoutes) {
|
|
288
|
+
if (socketPath === targetSocket) {
|
|
289
|
+
args = { ...args, tabId: knownTabId };
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
try {
|
|
295
|
+
const response = await this.executeOnSocketSerialized(targetSocket, toolName, args);
|
|
296
|
+
const result = this.normalizeResponse(response);
|
|
297
|
+
// Content script injection retry: if the tab was loaded before the MCP
|
|
298
|
+
// tab group was created, the accessibility tree content script won't be
|
|
299
|
+
// injected yet. Reload the page to trigger injection, then retry once.
|
|
300
|
+
if (this.isContentScriptError(result) && tabId !== undefined) {
|
|
301
|
+
const cachedUrl = this.tabUrls.get(tabId);
|
|
302
|
+
if (cachedUrl) {
|
|
303
|
+
const urlHost = (() => { try {
|
|
304
|
+
return new URL(cachedUrl).hostname;
|
|
305
|
+
}
|
|
306
|
+
catch {
|
|
307
|
+
return '(unknown)';
|
|
308
|
+
} })();
|
|
309
|
+
log(`Content script missing on tab ${tabId}, reloading ${urlHost} and retrying...`);
|
|
310
|
+
try {
|
|
311
|
+
await this.executeOnSocketSerialized(targetSocket, 'navigate', { url: cachedUrl, tabId });
|
|
312
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
313
|
+
const retryResponse = await this.executeOnSocketSerialized(targetSocket, toolName, args);
|
|
314
|
+
const retryResult = this.normalizeResponse(retryResponse);
|
|
315
|
+
this.appendTips(retryResult, toolName, tabId);
|
|
316
|
+
return retryResult;
|
|
317
|
+
}
|
|
318
|
+
catch {
|
|
319
|
+
// Retry failed, fall through to return the original error
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
this.appendTips(result, toolName, tabId);
|
|
324
|
+
return result;
|
|
325
|
+
}
|
|
326
|
+
catch (err) {
|
|
327
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
328
|
+
return {
|
|
329
|
+
content: [{ type: 'text', text: `Chrome bridge error: ${message}` }],
|
|
330
|
+
isError: true,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
async executeTabsContext(args) {
|
|
335
|
+
const socketPaths = Array.from(this.connections.keys());
|
|
336
|
+
if (socketPaths.length === 1) {
|
|
337
|
+
try {
|
|
338
|
+
const response = await this.executeOnSocketSerialized(socketPaths[0], 'tabs_context_mcp', args);
|
|
339
|
+
const result = this.normalizeResponse(response);
|
|
340
|
+
this.updateTabRoutes(result.content, socketPaths[0]);
|
|
341
|
+
return result;
|
|
342
|
+
}
|
|
343
|
+
catch (err) {
|
|
344
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
345
|
+
return {
|
|
346
|
+
content: [{ type: 'text', text: `Chrome bridge error: ${message}` }],
|
|
347
|
+
isError: true,
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
// Multiple sockets: query all and merge
|
|
352
|
+
const results = await Promise.allSettled(socketPaths.map(async (sp) => {
|
|
353
|
+
const response = await this.executeOnSocketSerialized(sp, 'tabs_context_mcp', args);
|
|
354
|
+
return { response, socketPath: sp };
|
|
355
|
+
}));
|
|
356
|
+
const mergedContent = [];
|
|
357
|
+
this.tabRoutes.clear();
|
|
358
|
+
this.tabUrls.clear();
|
|
359
|
+
for (const result of results) {
|
|
360
|
+
if (result.status === 'fulfilled') {
|
|
361
|
+
const normalized = this.normalizeResponse(result.value.response);
|
|
362
|
+
this.updateTabRoutes(normalized.content, result.value.socketPath);
|
|
363
|
+
mergedContent.push(...normalized.content);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
if (mergedContent.length === 0) {
|
|
367
|
+
return {
|
|
368
|
+
content: [{ type: 'text', text: 'No tabs found across connected browsers' }],
|
|
369
|
+
isError: true,
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
return { content: mergedContent };
|
|
373
|
+
}
|
|
374
|
+
updateTabRoutes(content, socketPath) {
|
|
375
|
+
for (const item of content) {
|
|
376
|
+
if (item.type !== 'text' || !item.text)
|
|
377
|
+
continue;
|
|
378
|
+
try {
|
|
379
|
+
const parsed = JSON.parse(item.text);
|
|
380
|
+
const tabs = Array.isArray(parsed) ? parsed : parsed?.availableTabs;
|
|
381
|
+
if (Array.isArray(tabs)) {
|
|
382
|
+
for (const tab of tabs) {
|
|
383
|
+
if (typeof tab === 'object' && tab !== null && typeof tab.tabId === 'number') {
|
|
384
|
+
this.tabRoutes.set(tab.tabId, socketPath);
|
|
385
|
+
if (typeof tab.url === 'string' && tab.url) {
|
|
386
|
+
this.tabUrls.set(tab.tabId, tab.url);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
catch {
|
|
393
|
+
// Not JSON or no tab data - skip
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
normalizeResponse(response) {
|
|
398
|
+
if ('error' in response && response.error) {
|
|
399
|
+
const rawErrorContent = response.error.content;
|
|
400
|
+
const content = Array.isArray(rawErrorContent) ? rawErrorContent : rawErrorContent != null ? [rawErrorContent] : [];
|
|
401
|
+
return {
|
|
402
|
+
content: content.map((c) => typeof c === 'object' && c !== null && 'type' in c
|
|
403
|
+
? c
|
|
404
|
+
: { type: 'text', text: String(c) }),
|
|
405
|
+
isError: true,
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
if ('result' in response && response.result) {
|
|
409
|
+
const rawContent = response.result.content;
|
|
410
|
+
const content = Array.isArray(rawContent) ? rawContent : rawContent != null ? [rawContent] : [];
|
|
411
|
+
return {
|
|
412
|
+
content: content.map((c) => {
|
|
413
|
+
if (typeof c === 'object' && c !== null && 'type' in c) {
|
|
414
|
+
// Handle image content from screenshots
|
|
415
|
+
if (c.type === 'image' && typeof c.source === 'object' && c.source !== null && 'data' in c.source) {
|
|
416
|
+
return {
|
|
417
|
+
type: 'image',
|
|
418
|
+
data: c.source.data,
|
|
419
|
+
mimeType: c.source.media_type ?? 'image/png',
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
return c;
|
|
423
|
+
}
|
|
424
|
+
return { type: 'text', text: String(c) };
|
|
425
|
+
}),
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
return { content: [{ type: 'text', text: 'Empty response from Chrome extension' }] };
|
|
429
|
+
}
|
|
430
|
+
appendTips(result, toolName, tabId) {
|
|
431
|
+
if (result.isError)
|
|
432
|
+
return;
|
|
433
|
+
const tabUrl = tabId !== undefined ? this.tabUrls.get(tabId) : undefined;
|
|
434
|
+
const tipText = this.tipTracker.getRelevantTips(toolName, tabUrl);
|
|
435
|
+
if (tipText)
|
|
436
|
+
result.content.push({ type: 'text', text: tipText });
|
|
437
|
+
}
|
|
438
|
+
destroy() {
|
|
439
|
+
for (const socket of this.connections.values()) {
|
|
440
|
+
socket.removeAllListeners();
|
|
441
|
+
socket.end();
|
|
442
|
+
socket.destroy();
|
|
443
|
+
}
|
|
444
|
+
this.connections.clear();
|
|
445
|
+
this.tabRoutes.clear();
|
|
446
|
+
this.tabUrls.clear();
|
|
447
|
+
this.requestQueues.clear();
|
|
448
|
+
this.reconnectAttempts.clear();
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
// ============================================================================
|
|
452
|
+
// Tool Definitions (exact schemas from Chrome extension)
|
|
453
|
+
// ============================================================================
|
|
454
|
+
const CHROME_TOOLS = [
|
|
455
|
+
{
|
|
456
|
+
name: 'tabs_context_mcp',
|
|
457
|
+
title: 'Tabs Context',
|
|
458
|
+
description: 'Get context information about the current MCP tab group. Returns all tab IDs inside the group if it exists. CRITICAL: You must get the context at least once before using other browser automation tools so you know what tabs exist. Each new conversation should create its own new tab (using tabs_create_mcp) rather than reusing existing tabs, unless the user explicitly asks to use an existing tab.',
|
|
459
|
+
inputSchema: {
|
|
460
|
+
type: 'object',
|
|
461
|
+
properties: {
|
|
462
|
+
createIfEmpty: {
|
|
463
|
+
type: 'boolean',
|
|
464
|
+
description: 'Creates a new MCP tab group if none exists, creates a new Window with a new tab group containing an empty tab (which can be used for this conversation). If a MCP tab group already exists, this parameter has no effect.',
|
|
465
|
+
},
|
|
466
|
+
},
|
|
467
|
+
},
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
name: 'tabs_create_mcp',
|
|
471
|
+
title: 'Tabs Create',
|
|
472
|
+
description: 'Creates a new empty tab in the MCP tab group. CRITICAL: You must get the context using tabs_context_mcp at least once before using other browser automation tools so you know what tabs exist.',
|
|
473
|
+
inputSchema: {
|
|
474
|
+
type: 'object',
|
|
475
|
+
properties: {},
|
|
476
|
+
},
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
name: 'navigate',
|
|
480
|
+
description: 'Navigate to a URL, or go forward/back in browser history. If you don\'t have a valid tab ID, use tabs_context_mcp first to get available tabs.',
|
|
481
|
+
inputSchema: {
|
|
482
|
+
type: 'object',
|
|
483
|
+
properties: {
|
|
484
|
+
url: {
|
|
485
|
+
type: 'string',
|
|
486
|
+
description: 'The URL to navigate to. Can be provided with or without protocol (defaults to https://). Use "forward" to go forward in history or "back" to go back in history.',
|
|
487
|
+
},
|
|
488
|
+
tabId: {
|
|
489
|
+
type: 'number',
|
|
490
|
+
description: 'Tab ID to navigate. Must be a tab in the current group. Use tabs_context_mcp first if you don\'t have a valid tab ID.',
|
|
491
|
+
},
|
|
492
|
+
},
|
|
493
|
+
required: ['url', 'tabId'],
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
name: 'read_page',
|
|
498
|
+
description: 'Get an accessibility tree representation of elements on the page. By default returns all elements including non-visible ones. Output is limited to 50000 characters by default. If the output exceeds this limit, you will receive an error asking you to specify a smaller depth or focus on a specific element using ref_id. Optionally filter for only interactive elements. If you don\'t have a valid tab ID, use tabs_context_mcp first to get available tabs.',
|
|
499
|
+
inputSchema: {
|
|
500
|
+
type: 'object',
|
|
501
|
+
properties: {
|
|
502
|
+
filter: {
|
|
503
|
+
type: 'string',
|
|
504
|
+
enum: ['interactive', 'all'],
|
|
505
|
+
description: 'Filter elements: "interactive" for buttons/links/inputs only, "all" for all elements including non-visible ones (default: all elements)',
|
|
506
|
+
},
|
|
507
|
+
tabId: {
|
|
508
|
+
type: 'number',
|
|
509
|
+
description: 'Tab ID to read from. Must be a tab in the current group. Use tabs_context_mcp first if you don\'t have a valid tab ID.',
|
|
510
|
+
},
|
|
511
|
+
depth: {
|
|
512
|
+
type: 'number',
|
|
513
|
+
description: 'Maximum depth of the tree to traverse (default: 15). Use a smaller depth if output is too large.',
|
|
514
|
+
},
|
|
515
|
+
ref_id: {
|
|
516
|
+
type: 'string',
|
|
517
|
+
description: 'Reference ID of a parent element to read. Will return the specified element and all its children. Use this to focus on a specific part of the page when output is too large.',
|
|
518
|
+
},
|
|
519
|
+
max_chars: {
|
|
520
|
+
type: 'number',
|
|
521
|
+
description: 'Maximum characters for output (default: 50000). Set to a higher value if your client can handle large outputs.',
|
|
522
|
+
},
|
|
523
|
+
},
|
|
524
|
+
required: ['tabId'],
|
|
525
|
+
},
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
name: 'get_page_text',
|
|
529
|
+
description: 'Extract raw text content from the page, prioritizing article content. Ideal for reading articles, blog posts, or other text-heavy pages. Returns plain text without HTML formatting. If you don\'t have a valid tab ID, use tabs_context_mcp first to get available tabs.',
|
|
530
|
+
inputSchema: {
|
|
531
|
+
type: 'object',
|
|
532
|
+
properties: {
|
|
533
|
+
tabId: {
|
|
534
|
+
type: 'number',
|
|
535
|
+
description: 'Tab ID to extract text from. Must be a tab in the current group. Use tabs_context_mcp first if you don\'t have a valid tab ID.',
|
|
536
|
+
},
|
|
537
|
+
},
|
|
538
|
+
required: ['tabId'],
|
|
539
|
+
},
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
name: 'find',
|
|
543
|
+
description: 'Find elements on the page using natural language. Can search for elements by their purpose (e.g., "search bar", "login button") or by text content (e.g., "organic mango product"). Returns up to 20 matching elements with references that can be used with other tools. If more than 20 matches exist, you\'ll be notified to use a more specific query. If you don\'t have a valid tab ID, use tabs_context_mcp first to get available tabs.',
|
|
544
|
+
inputSchema: {
|
|
545
|
+
type: 'object',
|
|
546
|
+
properties: {
|
|
547
|
+
query: {
|
|
548
|
+
type: 'string',
|
|
549
|
+
description: 'Natural language description of what to find (e.g., "search bar", "add to cart button", "product title containing organic")',
|
|
550
|
+
},
|
|
551
|
+
tabId: {
|
|
552
|
+
type: 'number',
|
|
553
|
+
description: 'Tab ID to search in. Must be a tab in the current group. Use tabs_context_mcp first if you don\'t have a valid tab ID.',
|
|
554
|
+
},
|
|
555
|
+
},
|
|
556
|
+
required: ['query', 'tabId'],
|
|
557
|
+
},
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
name: 'form_input',
|
|
561
|
+
description: 'Set values in form elements using element reference ID from the read_page tool. If you don\'t have a valid tab ID, use tabs_context_mcp first to get available tabs.',
|
|
562
|
+
inputSchema: {
|
|
563
|
+
type: 'object',
|
|
564
|
+
properties: {
|
|
565
|
+
ref: {
|
|
566
|
+
type: 'string',
|
|
567
|
+
description: 'Element reference ID from the read_page tool (e.g., "ref_1", "ref_2")',
|
|
568
|
+
},
|
|
569
|
+
value: {
|
|
570
|
+
type: ['string', 'boolean', 'number'],
|
|
571
|
+
description: 'The value to set. For checkboxes use boolean, for selects use option value or text, for other inputs use appropriate string/number',
|
|
572
|
+
},
|
|
573
|
+
tabId: {
|
|
574
|
+
type: 'number',
|
|
575
|
+
description: 'Tab ID to set form value in. Must be a tab in the current group. Use tabs_context_mcp first if you don\'t have a valid tab ID.',
|
|
576
|
+
},
|
|
577
|
+
},
|
|
578
|
+
required: ['ref', 'value', 'tabId'],
|
|
579
|
+
},
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
name: 'computer',
|
|
583
|
+
description: 'Use a mouse and keyboard to interact with a web browser, and take screenshots. If you don\'t have a valid tab ID, use tabs_context_mcp first to get available tabs.\n* Whenever you intend to click on an element like an icon, you should consult a screenshot to determine the coordinates of the element before moving the cursor.\n* If you tried clicking on a program or link but it failed to load, even after waiting, try adjusting your click location so that the tip of the cursor visually falls on the element that you want to click.\n* Make sure to click any buttons, links, icons, etc with the cursor tip in the center of the element. Don\'t click boxes on their edges unless asked.',
|
|
584
|
+
inputSchema: {
|
|
585
|
+
type: 'object',
|
|
586
|
+
properties: {
|
|
587
|
+
action: {
|
|
588
|
+
type: 'string',
|
|
589
|
+
enum: [
|
|
590
|
+
'left_click', 'right_click', 'type', 'screenshot', 'wait',
|
|
591
|
+
'scroll', 'key', 'left_click_drag', 'double_click',
|
|
592
|
+
'triple_click', 'zoom', 'scroll_to', 'hover',
|
|
593
|
+
],
|
|
594
|
+
description: 'The action to perform:\n* `left_click`: Click the left mouse button at the specified coordinates.\n* `right_click`: Click the right mouse button at the specified coordinates to open context menus.\n* `double_click`: Double-click the left mouse button at the specified coordinates.\n* `triple_click`: Triple-click the left mouse button at the specified coordinates.\n* `type`: Type a string of text.\n* `screenshot`: Take a screenshot of the screen.\n* `wait`: Wait for a specified number of seconds.\n* `scroll`: Scroll up, down, left, or right at the specified coordinates.\n* `key`: Press a specific keyboard key.\n* `left_click_drag`: Drag from start_coordinate to coordinate.\n* `zoom`: Take a screenshot of a specific region for closer inspection.\n* `scroll_to`: Scroll an element into view using its element reference ID from read_page or find tools.\n* `hover`: Move the mouse cursor to the specified coordinates or element without clicking.',
|
|
595
|
+
},
|
|
596
|
+
coordinate: {
|
|
597
|
+
type: 'array',
|
|
598
|
+
items: { type: 'number' },
|
|
599
|
+
description: '(x, y): The x (pixels from the left edge) and y (pixels from the top edge) coordinates. Required for left_click, right_click, double_click, triple_click, and scroll. For left_click_drag, this is the end position.',
|
|
600
|
+
},
|
|
601
|
+
text: {
|
|
602
|
+
type: 'string',
|
|
603
|
+
description: 'The text to type (for type action) or the key(s) to press (for key action). For key action: Provide space-separated keys (e.g., "Backspace Backspace Delete"). Supports keyboard shortcuts using the platform\'s modifier key (use "cmd" on Mac, "ctrl" on Windows/Linux, e.g., "cmd+a" or "ctrl+a" for select all).',
|
|
604
|
+
},
|
|
605
|
+
duration: {
|
|
606
|
+
type: 'number',
|
|
607
|
+
description: 'The number of seconds to wait. Required for wait. Maximum 30 seconds.',
|
|
608
|
+
},
|
|
609
|
+
scroll_direction: {
|
|
610
|
+
type: 'string',
|
|
611
|
+
enum: ['up', 'down', 'left', 'right'],
|
|
612
|
+
description: 'The direction to scroll. Required for scroll.',
|
|
613
|
+
},
|
|
614
|
+
scroll_amount: {
|
|
615
|
+
type: 'number',
|
|
616
|
+
description: 'The number of scroll wheel ticks. Optional for scroll, defaults to 3.',
|
|
617
|
+
},
|
|
618
|
+
start_coordinate: {
|
|
619
|
+
type: 'array',
|
|
620
|
+
items: { type: 'number' },
|
|
621
|
+
description: '(x, y): The starting coordinates for left_click_drag.',
|
|
622
|
+
},
|
|
623
|
+
region: {
|
|
624
|
+
type: 'array',
|
|
625
|
+
items: { type: 'number' },
|
|
626
|
+
description: '(x0, y0, x1, y1): The rectangular region to capture for zoom. Coordinates define a rectangle from top-left (x0, y0) to bottom-right (x1, y1) in pixels from the viewport origin. Required for zoom action.',
|
|
627
|
+
},
|
|
628
|
+
repeat: {
|
|
629
|
+
type: 'number',
|
|
630
|
+
description: 'Number of times to repeat the key sequence. Only applicable for key action. Must be between 1 and 100. Default is 1.',
|
|
631
|
+
},
|
|
632
|
+
ref: {
|
|
633
|
+
type: 'string',
|
|
634
|
+
description: 'Element reference ID from read_page or find tools (e.g., "ref_1", "ref_2"). Required for scroll_to action. Can be used as alternative to coordinate for click actions.',
|
|
635
|
+
},
|
|
636
|
+
modifiers: {
|
|
637
|
+
type: 'string',
|
|
638
|
+
description: 'Modifier keys for click actions. Supports: "ctrl", "shift", "alt", "cmd" (or "meta"), "win" (or "windows"). Can be combined with "+" (e.g., "ctrl+shift", "cmd+alt"). Optional.',
|
|
639
|
+
},
|
|
640
|
+
tabId: {
|
|
641
|
+
type: 'number',
|
|
642
|
+
description: 'Tab ID to execute the action on. Must be a tab in the current group. Use tabs_context_mcp first if you don\'t have a valid tab ID.',
|
|
643
|
+
},
|
|
644
|
+
},
|
|
645
|
+
required: ['action', 'tabId'],
|
|
646
|
+
},
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
name: 'javascript_tool',
|
|
650
|
+
description: 'Execute JavaScript code in the context of the current page. The code runs in the page\'s context and can interact with the DOM, window object, and page variables. Returns the result of the last expression or any thrown errors. If you don\'t have a valid tab ID, use tabs_context_mcp first to get available tabs.',
|
|
651
|
+
inputSchema: {
|
|
652
|
+
type: 'object',
|
|
653
|
+
properties: {
|
|
654
|
+
action: {
|
|
655
|
+
type: 'string',
|
|
656
|
+
description: "Must be set to 'javascript_exec'",
|
|
657
|
+
},
|
|
658
|
+
text: {
|
|
659
|
+
type: 'string',
|
|
660
|
+
description: 'The JavaScript code to execute. The code will be evaluated in the page context. The result of the last expression will be returned automatically. Do NOT use \'return\' statements - just write the expression you want to evaluate (e.g., \'window.myData.value\' not \'return window.myData.value\'). You can access and modify the DOM, call page functions, and interact with page variables.',
|
|
661
|
+
},
|
|
662
|
+
tabId: {
|
|
663
|
+
type: 'number',
|
|
664
|
+
description: 'Tab ID to execute the code in. Must be a tab in the current group. Use tabs_context_mcp first if you don\'t have a valid tab ID.',
|
|
665
|
+
},
|
|
666
|
+
},
|
|
667
|
+
required: ['action', 'text', 'tabId'],
|
|
668
|
+
},
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
name: 'read_console_messages',
|
|
672
|
+
description: 'Read browser console messages (console.log, console.error, console.warn, etc.) from a specific tab. Useful for debugging JavaScript errors, viewing application logs, or understanding what\'s happening in the browser console. Returns console messages from the current domain only. If you don\'t have a valid tab ID, use tabs_context_mcp first to get available tabs. IMPORTANT: Always provide a pattern to filter messages - without a pattern, you may get too many irrelevant messages.',
|
|
673
|
+
inputSchema: {
|
|
674
|
+
type: 'object',
|
|
675
|
+
properties: {
|
|
676
|
+
tabId: {
|
|
677
|
+
type: 'number',
|
|
678
|
+
description: 'Tab ID to read console messages from. Must be a tab in the current group. Use tabs_context_mcp first if you don\'t have a valid tab ID.',
|
|
679
|
+
},
|
|
680
|
+
onlyErrors: {
|
|
681
|
+
type: 'boolean',
|
|
682
|
+
description: 'If true, only return error and exception messages. Default is false.',
|
|
683
|
+
},
|
|
684
|
+
clear: {
|
|
685
|
+
type: 'boolean',
|
|
686
|
+
description: 'If true, clear the console messages after reading to avoid duplicates on subsequent calls. Default is false.',
|
|
687
|
+
},
|
|
688
|
+
pattern: {
|
|
689
|
+
type: 'string',
|
|
690
|
+
description: 'Regex pattern to filter console messages. Only messages matching this pattern will be returned (e.g., \'error|warning\' to find errors and warnings, \'MyApp\' to filter app-specific logs). You should always provide a pattern to avoid getting too many irrelevant messages.',
|
|
691
|
+
},
|
|
692
|
+
limit: {
|
|
693
|
+
type: 'number',
|
|
694
|
+
description: 'Maximum number of messages to return. Defaults to 100. Increase only if you need more results.',
|
|
695
|
+
},
|
|
696
|
+
},
|
|
697
|
+
required: ['tabId'],
|
|
698
|
+
},
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
name: 'read_network_requests',
|
|
702
|
+
description: 'Read HTTP network requests (XHR, Fetch, documents, images, etc.) from a specific tab. Useful for debugging API calls, monitoring network activity, or understanding what requests a page is making. Returns all network requests made by the current page, including cross-origin requests. Requests are automatically cleared when the page navigates to a different domain. If you don\'t have a valid tab ID, use tabs_context_mcp first to get available tabs.',
|
|
703
|
+
inputSchema: {
|
|
704
|
+
type: 'object',
|
|
705
|
+
properties: {
|
|
706
|
+
tabId: {
|
|
707
|
+
type: 'number',
|
|
708
|
+
description: 'Tab ID to read network requests from. Must be a tab in the current group. Use tabs_context_mcp first if you don\'t have a valid tab ID.',
|
|
709
|
+
},
|
|
710
|
+
urlPattern: {
|
|
711
|
+
type: 'string',
|
|
712
|
+
description: 'Optional URL pattern to filter requests. Only requests whose URL contains this string will be returned (e.g., \'/api/\' to filter API calls, \'example.com\' to filter by domain).',
|
|
713
|
+
},
|
|
714
|
+
clear: {
|
|
715
|
+
type: 'boolean',
|
|
716
|
+
description: 'If true, clear the network requests after reading to avoid duplicates on subsequent calls. Default is false.',
|
|
717
|
+
},
|
|
718
|
+
limit: {
|
|
719
|
+
type: 'number',
|
|
720
|
+
description: 'Maximum number of requests to return. Defaults to 100. Increase only if you need more results.',
|
|
721
|
+
},
|
|
722
|
+
},
|
|
723
|
+
required: ['tabId'],
|
|
724
|
+
},
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
name: 'resize_window',
|
|
728
|
+
description: 'Resize the current browser window to specified dimensions. Useful for testing responsive designs or setting up specific screen sizes. If you don\'t have a valid tab ID, use tabs_context_mcp first to get available tabs.',
|
|
729
|
+
inputSchema: {
|
|
730
|
+
type: 'object',
|
|
731
|
+
properties: {
|
|
732
|
+
width: {
|
|
733
|
+
type: 'number',
|
|
734
|
+
description: 'Target window width in pixels',
|
|
735
|
+
},
|
|
736
|
+
height: {
|
|
737
|
+
type: 'number',
|
|
738
|
+
description: 'Target window height in pixels',
|
|
739
|
+
},
|
|
740
|
+
tabId: {
|
|
741
|
+
type: 'number',
|
|
742
|
+
description: 'Tab ID to get the window for. Must be a tab in the current group. Use tabs_context_mcp first if you don\'t have a valid tab ID.',
|
|
743
|
+
},
|
|
744
|
+
},
|
|
745
|
+
required: ['width', 'height', 'tabId'],
|
|
746
|
+
},
|
|
747
|
+
},
|
|
748
|
+
{
|
|
749
|
+
name: 'gif_creator',
|
|
750
|
+
description: 'Manage GIF recording and export for browser automation sessions. Control when to start/stop recording browser actions (clicks, scrolls, navigation), then export as an animated GIF with visual overlays (click indicators, action labels, progress bar, watermark). All operations are scoped to the tab\'s group. When starting recording, take a screenshot immediately after to capture the initial state as the first frame. When stopping recording, take a screenshot immediately before to capture the final state as the last frame. For export, set download to true to download the GIF.',
|
|
751
|
+
inputSchema: {
|
|
752
|
+
type: 'object',
|
|
753
|
+
properties: {
|
|
754
|
+
action: {
|
|
755
|
+
type: 'string',
|
|
756
|
+
enum: ['start_recording', 'stop_recording', 'export', 'clear'],
|
|
757
|
+
description: "Action to perform: 'start_recording' (begin capturing), 'stop_recording' (stop capturing but keep frames), 'export' (generate and export GIF), 'clear' (discard frames)",
|
|
758
|
+
},
|
|
759
|
+
tabId: {
|
|
760
|
+
type: 'number',
|
|
761
|
+
description: 'Tab ID to identify which tab group this operation applies to',
|
|
762
|
+
},
|
|
763
|
+
download: {
|
|
764
|
+
type: 'boolean',
|
|
765
|
+
description: "Always set this to true for the 'export' action only. This causes the gif to be downloaded in the browser.",
|
|
766
|
+
},
|
|
767
|
+
filename: {
|
|
768
|
+
type: 'string',
|
|
769
|
+
description: "Optional filename for exported GIF (default: 'recording-[timestamp].gif'). For 'export' action only.",
|
|
770
|
+
},
|
|
771
|
+
options: {
|
|
772
|
+
type: 'object',
|
|
773
|
+
description: "Optional GIF enhancement options for 'export' action.",
|
|
774
|
+
properties: {
|
|
775
|
+
showClickIndicators: { type: 'boolean', description: 'Show orange circles at click locations (default: true)' },
|
|
776
|
+
showDragPaths: { type: 'boolean', description: 'Show red arrows for drag actions (default: true)' },
|
|
777
|
+
showActionLabels: { type: 'boolean', description: 'Show black labels describing actions (default: true)' },
|
|
778
|
+
showProgressBar: { type: 'boolean', description: 'Show orange progress bar at bottom (default: true)' },
|
|
779
|
+
showWatermark: { type: 'boolean', description: 'Show Claude logo watermark (default: true)' },
|
|
780
|
+
quality: { type: 'number', description: 'GIF compression quality, 1-30 (lower = better quality, slower encoding). Default: 10' },
|
|
781
|
+
},
|
|
782
|
+
},
|
|
783
|
+
},
|
|
784
|
+
required: ['action', 'tabId'],
|
|
785
|
+
},
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
name: 'upload_image',
|
|
789
|
+
description: 'Upload a previously captured screenshot or user-uploaded image to a file input or drag & drop target. Supports two approaches: (1) ref - for targeting specific elements, especially hidden file inputs, (2) coordinate - for drag & drop to visible locations like Google Docs. Provide either ref or coordinate, not both.',
|
|
790
|
+
inputSchema: {
|
|
791
|
+
type: 'object',
|
|
792
|
+
properties: {
|
|
793
|
+
imageId: {
|
|
794
|
+
type: 'string',
|
|
795
|
+
description: "ID of a previously captured screenshot (from the computer tool's screenshot action) or a user-uploaded image",
|
|
796
|
+
},
|
|
797
|
+
ref: {
|
|
798
|
+
type: 'string',
|
|
799
|
+
description: 'Element reference ID from read_page or find tools (e.g., "ref_1", "ref_2"). Use this for file inputs (especially hidden ones) or specific elements. Provide either ref or coordinate, not both.',
|
|
800
|
+
},
|
|
801
|
+
coordinate: {
|
|
802
|
+
type: 'array',
|
|
803
|
+
items: { type: 'number' },
|
|
804
|
+
description: 'Viewport coordinates [x, y] for drag & drop to a visible location. Use this for drag & drop targets like Google Docs. Provide either ref or coordinate, not both.',
|
|
805
|
+
},
|
|
806
|
+
tabId: {
|
|
807
|
+
type: 'number',
|
|
808
|
+
description: 'Tab ID where the target element is located. This is where the image will be uploaded to.',
|
|
809
|
+
},
|
|
810
|
+
filename: {
|
|
811
|
+
type: 'string',
|
|
812
|
+
description: 'Optional filename for the uploaded file (default: "image.png")',
|
|
813
|
+
},
|
|
814
|
+
},
|
|
815
|
+
required: ['imageId', 'tabId'],
|
|
816
|
+
},
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
name: 'shortcuts_list',
|
|
820
|
+
description: 'List all available shortcuts and workflows (shortcuts and workflows are interchangeable). Returns shortcuts with their commands, descriptions, and whether they are workflows. Use shortcuts_execute to run a shortcut or workflow.',
|
|
821
|
+
inputSchema: {
|
|
822
|
+
type: 'object',
|
|
823
|
+
properties: {
|
|
824
|
+
tabId: {
|
|
825
|
+
type: 'number',
|
|
826
|
+
description: 'Tab ID to list shortcuts from. Must be a tab in the current group. Use tabs_context_mcp first if you don\'t have a valid tab ID.',
|
|
827
|
+
},
|
|
828
|
+
},
|
|
829
|
+
required: ['tabId'],
|
|
830
|
+
},
|
|
831
|
+
},
|
|
832
|
+
{
|
|
833
|
+
name: 'shortcuts_execute',
|
|
834
|
+
description: 'Execute a shortcut or workflow by running it in a new sidepanel window using the current tab (shortcuts and workflows are interchangeable). Use shortcuts_list first to see available shortcuts. This starts the execution and returns immediately - it does not wait for completion.',
|
|
835
|
+
inputSchema: {
|
|
836
|
+
type: 'object',
|
|
837
|
+
properties: {
|
|
838
|
+
tabId: {
|
|
839
|
+
type: 'number',
|
|
840
|
+
description: 'Tab ID to execute the shortcut on. Must be a tab in the current group. Use tabs_context_mcp first if you don\'t have a valid tab ID.',
|
|
841
|
+
},
|
|
842
|
+
shortcutId: {
|
|
843
|
+
type: 'string',
|
|
844
|
+
description: 'The ID of the shortcut to execute',
|
|
845
|
+
},
|
|
846
|
+
command: {
|
|
847
|
+
type: 'string',
|
|
848
|
+
description: "The command name of the shortcut to execute (e.g., 'debug', 'summarize'). Do not include the leading slash.",
|
|
849
|
+
},
|
|
850
|
+
},
|
|
851
|
+
required: ['tabId'],
|
|
852
|
+
},
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
name: 'update_plan',
|
|
856
|
+
description: 'Present a plan to the user for approval before taking actions. The user will see the domains you intend to visit and your approach. Once approved, you can proceed with actions on the approved domains without additional permission prompts.',
|
|
857
|
+
inputSchema: {
|
|
858
|
+
type: 'object',
|
|
859
|
+
properties: {
|
|
860
|
+
domains: {
|
|
861
|
+
type: 'array',
|
|
862
|
+
items: { type: 'string' },
|
|
863
|
+
description: "List of domains you will visit (e.g., ['github.com', 'stackoverflow.com']). These domains will be approved for the session when the user accepts the plan.",
|
|
864
|
+
},
|
|
865
|
+
approach: {
|
|
866
|
+
type: 'array',
|
|
867
|
+
items: { type: 'string' },
|
|
868
|
+
description: 'High-level description of what you will do. Focus on outcomes and key actions, not implementation details. Be concise - aim for 3-7 items.',
|
|
869
|
+
},
|
|
870
|
+
},
|
|
871
|
+
required: ['domains', 'approach'],
|
|
872
|
+
},
|
|
873
|
+
},
|
|
874
|
+
{
|
|
875
|
+
name: 'switch_browser',
|
|
876
|
+
description: "Switch which Chrome browser is used for browser automation. Call this when the user wants to connect to a different Chrome browser. Broadcasts a connection request to all Chrome browsers with the extension installed — the user clicks 'Connect' in the desired browser.",
|
|
877
|
+
inputSchema: {
|
|
878
|
+
type: 'object',
|
|
879
|
+
properties: {},
|
|
880
|
+
},
|
|
881
|
+
},
|
|
882
|
+
];
|
|
883
|
+
// ============================================================================
|
|
884
|
+
// JSON-RPC Server
|
|
885
|
+
// ============================================================================
|
|
886
|
+
function log(message) {
|
|
887
|
+
process.stderr.write(`[chrome-bridge] ${message}\n`);
|
|
888
|
+
}
|
|
889
|
+
const client = new ChromeBridgeClient();
|
|
890
|
+
function createResponse(id, result) {
|
|
891
|
+
return { jsonrpc: '2.0', id, result };
|
|
892
|
+
}
|
|
893
|
+
function createError(id, code, message) {
|
|
894
|
+
return { jsonrpc: '2.0', id, error: { code, message } };
|
|
895
|
+
}
|
|
896
|
+
async function handleRequest(request) {
|
|
897
|
+
const { id, method, params } = request;
|
|
898
|
+
switch (method) {
|
|
899
|
+
case 'initialize':
|
|
900
|
+
return createResponse(id, {
|
|
901
|
+
protocolVersion: '2024-11-05',
|
|
902
|
+
capabilities: { tools: {} },
|
|
903
|
+
serverInfo: { name: 'chrome-bridge', version: '1.0.0' },
|
|
904
|
+
});
|
|
905
|
+
case 'notifications/initialized':
|
|
906
|
+
return null;
|
|
907
|
+
case 'tools/list':
|
|
908
|
+
return createResponse(id, { tools: CHROME_TOOLS });
|
|
909
|
+
case 'tools/call': {
|
|
910
|
+
const parseResult = McpToolCallParamsSchema.safeParse(params);
|
|
911
|
+
if (!parseResult.success) {
|
|
912
|
+
return createError(id, JSON_RPC_ERRORS.INVALID_PARAMS, `Invalid params: ${parseResult.error.message}`);
|
|
913
|
+
}
|
|
914
|
+
const { name, arguments: args } = parseResult.data;
|
|
915
|
+
const toolDef = CHROME_TOOLS.find((t) => t.name === name);
|
|
916
|
+
if (!toolDef) {
|
|
917
|
+
return createError(id, JSON_RPC_ERRORS.METHOD_NOT_FOUND, `Unknown tool: ${name}`);
|
|
918
|
+
}
|
|
919
|
+
const result = await client.executeTool(name, args ?? {});
|
|
920
|
+
return createResponse(id, result);
|
|
921
|
+
}
|
|
922
|
+
default:
|
|
923
|
+
return createError(id, JSON_RPC_ERRORS.METHOD_NOT_FOUND, `Unknown method: ${method}`);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
// --- Startup ---
|
|
927
|
+
log('chrome-bridge MCP Server v1.0.0 running');
|
|
928
|
+
const rl = readline.createInterface({
|
|
929
|
+
input: process.stdin,
|
|
930
|
+
output: process.stdout,
|
|
931
|
+
terminal: false,
|
|
932
|
+
});
|
|
933
|
+
rl.on('line', async (line) => {
|
|
934
|
+
if (!line.trim())
|
|
935
|
+
return;
|
|
936
|
+
let parsed;
|
|
937
|
+
try {
|
|
938
|
+
parsed = JSON.parse(line);
|
|
939
|
+
}
|
|
940
|
+
catch {
|
|
941
|
+
process.stdout.write(JSON.stringify(createError(null, JSON_RPC_ERRORS.PARSE_ERROR, 'Parse error')) + '\n');
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
const validateResult = JsonRpcRequestSchema.safeParse(parsed);
|
|
945
|
+
if (!validateResult.success) {
|
|
946
|
+
const partial = parsed;
|
|
947
|
+
const id = partial?.id != null ? partial.id : null;
|
|
948
|
+
process.stdout.write(JSON.stringify(createError(id, JSON_RPC_ERRORS.PARSE_ERROR, `Invalid request: ${validateResult.error.message}`)) + '\n');
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
const response = await handleRequest(validateResult.data);
|
|
952
|
+
if (response) {
|
|
953
|
+
process.stdout.write(JSON.stringify(response) + '\n');
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
rl.on('close', () => process.exit(0));
|
|
957
|
+
process.on('SIGINT', () => { client.destroy(); process.exit(0); });
|
|
958
|
+
process.on('SIGTERM', () => { client.destroy(); process.exit(0); });
|
|
959
|
+
//# sourceMappingURL=server.js.map
|