Skip to main content
Glama

interceptor_chrome_cdp_info

Retrieve Chrome DevTools Protocol endpoints and tab targets for attaching Playwright or DevTools to a launched Chrome instance.

Instructions

Get CDP endpoints (HTTP + WebSocket) and tab targets for a Chrome instance launched by interceptor_chrome_launch. Useful for attaching Playwright/DevTools.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
target_idYesTarget ID from interceptor_chrome_launch
include_targetsNoInclude /json/list targets (default: true)
timeout_msNoTotal time to wait for CDP readiness (default: 3000ms)
retry_interval_msNoRetry interval while waiting for CDP (default: 200ms)

Implementation Reference

  • The handler implementation for the 'interceptor_chrome_cdp_info' tool, which fetches Chrome CDP endpoints, version information, and list of targets for a given Chrome target ID.
      "interceptor_chrome_cdp_info",
      "Get CDP endpoints (HTTP + WebSocket) and tab targets for a Chrome instance launched by interceptor_chrome_launch. Useful for attaching Playwright/DevTools.",
      {
        target_id: z.string().describe("Target ID from interceptor_chrome_launch"),
        include_targets: z.boolean().optional().default(true).describe("Include /json/list targets (default: true)"),
        timeout_ms: z.number().optional().default(3000).describe("Total time to wait for CDP readiness (default: 3000ms)"),
        retry_interval_ms: z.number().optional().default(200).describe("Retry interval while waiting for CDP (default: 200ms)"),
      },
      async ({ target_id, include_targets, timeout_ms, retry_interval_ms }) => {
        try {
          const chrome = interceptorManager.get("chrome");
          if (!chrome) {
            return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: "Chrome interceptor not registered." }) }] };
          }
    
          const meta = await chrome.getMetadata();
          const target = meta.activeTargets.find((t) => t.id === target_id);
          if (!target) {
            return {
              content: [{
                type: "text",
                text: JSON.stringify({ status: "error", error: `Chrome target '${target_id}' not found. Is it still running?` }),
              }],
            };
          }
    
          // Chrome interceptor stores CDP port in details.port
          // eslint-disable-next-line @typescript-eslint/no-explicit-any
          const details: any = target.details ?? {};
          const port = details.port;
          if (typeof port !== "number" || !Number.isFinite(port) || port <= 0) {
            return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: `Chrome target '${target_id}' has no valid CDP port.` }) }] };
          }
    
          const httpUrl = getCdpBaseUrl(port);
          const versionUrl = getCdpVersionUrl(port);
          const targetsUrl = getCdpTargetsUrl(port);
    
          const version = await waitForCdpVersion(port, {
            timeoutMs: timeout_ms,
            intervalMs: retry_interval_ms,
            requestTimeoutMs: Math.min(1000, Math.max(100, retry_interval_ms)),
          });
          const ws = version.webSocketDebuggerUrl;
    
          let targets: Array<Record<string, unknown>> | null = null;
          let targetsError: string | null = null;
          if (include_targets) {
            try {
              targets = await getCdpTargets(port, { timeoutMs: 1500 });
            } catch (e) {
              targetsError = errorToString(e);
            }
          }
    
          return {
            content: [{
              type: "text",
              text: truncateResult({
                status: "success",
                target_id,
                cdp: {
                  httpUrl,
                  versionUrl,
                  targetsUrl,
                  version,
                  browserWebSocketDebuggerUrl: typeof ws === "string" ? ws : null,
                },
                targets,
                ...(targetsError ? { targetsError } : {}),
              }),
            }],
          };
        } catch (e) {
          return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: errorToString(e) }) }] };
        }
      },
    );

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yfe404/proxy-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server