Skip to content

CDP / 확장 프로그램 이스케이프 해치

DevBridge의 25개 표준 도구로 커버되지 않는 경우, 6개의 이스케이프 해치 도구를 사용해 Chrome DevTools Protocol(CDP) 또는 chrome.* 확장 API에 직접 접근할 수 있습니다.

먼저 표준 도구를 사용하세요

이스케이프 해치 도구는 강력하지만 더 저수준입니다. screenshot, computer, read_console, read_network 등의 전용 도구를 우선 사용하세요——이들에는 오류 처리, 권한 검사, 재시도 로직이 내장되어 있습니다. 표준 도구로 정말 커버되지 않을 때만 이스케이프 해치를 사용하세요.

CDP 도구

cdp_command — 단일 CDP 명령 전송

Chrome DevTools Protocol 명령을 직접 전송하고 응답을 받습니다. 일회성 요청/응답 작업에 적합합니다.

_help 인트로스펙션: method: "_help"를 전달하면 사용 가능한 CDP 도메인 목록이 표시됩니다. method: "Network._help"를 전달하면 Network 도메인의 명령과 파라미터 설명이 표시됩니다.

json
// CDP 도메인 목록
{ "method": "_help" }

// Network 도메인 명령 확인
{ "method": "Network._help" }

// 디바이스 에뮬레이션 (iPhone 14)
{
  "method": "Emulation.setDeviceMetricsOverride",
  "params": { "width": 390, "height": 844, "deviceScaleFactor": 3, "mobile": true }
}

// 3G 네트워크 조건 에뮬레이션
{
  "method": "Network.emulateNetworkConditions",
  "params": { "offline": false, "downloadThroughput": 375000, "uploadThroughput": 125000, "latency": 100 }
}

cdp_subscribe — CDP 이벤트 구독

CDP 이벤트 스트림을 구독합니다. untilPredicate로 조건 충족 시 자동 중지할 수 있습니다.

json
{
  "tabId": 123,
  "eventName": "Network.responseReceived",
  "untilPredicate": "event.response.url.includes('/api/data')",
  "timeoutMs": 10000
}

cdp_events_read — 링 버퍼에서 CDP 이벤트 풀

사전 구독 없이 이미 캡처된 CDP 이벤트를 풀합니다. 사후 분석에 유용합니다.

json
{ "tabId": 123, "eventName": "Network.requestWillBeSent", "limit": 50 }

chrome.* 확장 도구

extension_call — chrome.* API 메서드 호출

화이트리스트의 chrome.* API 메서드를 호출합니다. void 메서드의 응답은 { success: true, void: true }입니다.

json
// 로컬 스토리지 읽기
{ "namespace": "storage.local", "method": "get", "args": [["myKey"]] }

// 도메인의 모든 쿠키 가져오기
{ "namespace": "cookies", "method": "getAll", "args": [{ "domain": "example.com" }] }

extension_subscribe — chrome.* 이벤트 구독

chrome.* 이벤트를 구독합니다 (cdp_subscribe와 유사한 사용법).

json
{
  "namespace": "tabs",
  "eventName": "onUpdated",
  "untilPredicate": "event.changeInfo.status === 'complete'",
  "timeoutMs": 15000
}

extension_events_read — 링 버퍼에서 chrome.* 이벤트 풀

이미 캡처된 chrome.* 이벤트를 풀합니다.

json
{ "namespace": "tabs", "eventName": "onUpdated", "limit": 20 }

구독 vs 풀 모드 비교

시나리오권장 도구
이벤트 발생을 기다린 후 계속 진행cdp_subscribe / extension_subscribe (untilPredicate 사용)
이미 발생한 이벤트 확인cdp_events_read / extension_events_read
명령 전송 후 결과 받기cdp_command / extension_call

주요 사용 사례

  • 모바일 디바이스 또는 네트워크 조건 에뮬레이션cdp_command + Emulation.* / Network.emulateNetworkConditions
  • 확장 프로그램 로컬 스토리지 읽기/쓰기extension_call + storage.local.get / set
  • SPA 내비게이션 완료 대기cdp_subscribe + Page.frameNavigated
  • 특정 요청의 전체 헤더 감사cdp_events_read + Network.requestWillBeSent
  • 쿠키 변경 모니터링extension_subscribe + cookies.onChanged

DevBridge — Browser Debugging & Automation via MCP