Skip to main content
Glama

interceptor_chrome_devtools_get_storage_value

Retrieve specific localStorage or sessionStorage values from Chrome DevTools sessions to inspect web application data during network traffic analysis.

Instructions

Get one localStorage/sessionStorage value by item_id.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
devtools_session_idYesSession ID from interceptor_chrome_devtools_attach
storage_typeYesStorage type
item_idYesitem_id from interceptor_chrome_devtools_list_storage_keys
originNoOptional origin override (must match current page origin)
value_max_charsNoMax characters for returned value (default: 20000)

Implementation Reference

  • The handler function for 'interceptor_chrome_devtools_get_storage_value' which retrieves a localStorage/sessionStorage value by item_id using Chrome DevTools Protocol.
        "interceptor_chrome_devtools_get_storage_value",
        "Get one localStorage/sessionStorage value by item_id.",
        {
          devtools_session_id: z.string().describe("Session ID from interceptor_chrome_devtools_attach"),
          storage_type: z.enum(["local", "session"]).describe("Storage type"),
          item_id: z.string().describe("item_id from interceptor_chrome_devtools_list_storage_keys"),
          origin: z.string().optional().describe("Optional origin override (must match current page origin)"),
          value_max_chars: z.number().optional().default(HARD_VALUE_CAP_CHARS)
            .describe(`Max characters for returned value (default: ${HARD_VALUE_CAP_CHARS})`),
        },
        async ({ devtools_session_id, storage_type, item_id, origin, value_max_chars }) => {
          try {
            const session = devToolsBridge.getSession(devtools_session_id);
            if (!session) {
              return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: `DevTools session '${devtools_session_id}' not found.` }) }] };
            }
    
            const parts = item_id.split(".");
            if (parts.length !== 4 || parts[0] !== "st") {
              return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: `Invalid item_id '${item_id}'` }) }] };
            }
            const itemType = parts[1];
            const itemOrigin = fromBase64UrlUtf8(parts[2]);
            const itemKey = fromBase64UrlUtf8(parts[3]);
            if (itemType !== storage_type) {
              return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: `item_id storage_type '${itemType}' does not match requested '${storage_type}'` }) }] };
            }
    
            const { targetId } = await ensureSessionTargetIsAlive(devtools_session_id);
            const { pageUrl, wsUrl } = await getCdpPageEndpoint(targetId);
    
            const currentOrigin = getOriginFromUrl(pageUrl);
            if (!currentOrigin) {
              return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: `No http(s) origin available for current page URL: '${pageUrl}'` }) }] };
            }
            if (origin && origin !== currentOrigin) {
              return {
                content: [{
                  type: "text",
                  text: JSON.stringify({ status: "error", error: `origin '${origin}' does not match current origin '${currentOrigin}'. Navigate first.` }),
                }],
              };
            }
            if (itemOrigin !== currentOrigin) {
              return {
                content: [{
                  type: "text",
                  text: JSON.stringify({ status: "error", error: `item_id origin '${itemOrigin}' does not match current origin '${currentOrigin}'. Navigate first.` }),
                }],
              };
            }
    
            const maxChars = Math.max(0, Math.min(HARD_VALUE_CAP_CHARS, Math.trunc(value_max_chars ?? HARD_VALUE_CAP_CHARS)));
            const stType = storage_type;
    
            const expr = `(() => {
      try {
        const storageType = ${JSON.stringify(stType)};
        const key = ${JSON.stringify(itemKey)};
        const maxChars = ${maxChars};
        const storage = storageType === "local" ? localStorage : sessionStorage;
        const raw = storage.getItem(key);
        const v = typeof raw === "string" ? raw : "";
        const valueLength = v.length;
        const truncated = maxChars > 0 && valueLength > maxChars;
        const value = maxChars > 0 ? (truncated ? v.slice(0, maxChars) : v) : v;
        return { key, value, valueLength, truncated };
      } catch (e) {
        return { error: String(e && e.message ? e.message : e) };
      }
    })()`;
    
            const result = await cdpEvaluateValue(wsUrl, expr) as unknown;
            if (!result || typeof result !== "object") {
              throw new Error("Unexpected storage evaluation result.");
            }
            const obj = result as Record<string, unknown>;
            if (obj.error) {
              throw new Error(`Storage evaluation error: ${typeof obj.error === "string" ? obj.error : JSON.stringify(obj.error)}`);
            }
    
            return {
              content: [{
                type: "text",
                text: truncateResult({
                  status: "success",
                  devtools_session_id,
                  target_id: targetId,
                  origin: currentOrigin,
                  storage_type: stType,
                  item_id,
                  key: obj.key ?? itemKey,
                  value: typeof obj.value === "string" ? obj.value : "",
                  value_length: typeof obj.valueLength === "number" ? obj.valueLength : null,
                  value_truncated: typeof obj.truncated === "boolean" ? obj.truncated : null,
                  value_max_chars: maxChars,
                }),
              }],
            };
          } catch (e) {
            return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: errorToString(e) }) }] };
          }
        },
      );
  • Registration of the 'interceptor_chrome_devtools_get_storage_value' tool within the registerDevToolsTools function.
        "interceptor_chrome_devtools_get_storage_value",
        "Get one localStorage/sessionStorage value by item_id.",
        {
          devtools_session_id: z.string().describe("Session ID from interceptor_chrome_devtools_attach"),
          storage_type: z.enum(["local", "session"]).describe("Storage type"),
          item_id: z.string().describe("item_id from interceptor_chrome_devtools_list_storage_keys"),
          origin: z.string().optional().describe("Optional origin override (must match current page origin)"),
          value_max_chars: z.number().optional().default(HARD_VALUE_CAP_CHARS)
            .describe(`Max characters for returned value (default: ${HARD_VALUE_CAP_CHARS})`),
        },
        async ({ devtools_session_id, storage_type, item_id, origin, value_max_chars }) => {
          try {
            const session = devToolsBridge.getSession(devtools_session_id);
            if (!session) {
              return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: `DevTools session '${devtools_session_id}' not found.` }) }] };
            }
    
            const parts = item_id.split(".");
            if (parts.length !== 4 || parts[0] !== "st") {
              return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: `Invalid item_id '${item_id}'` }) }] };
            }
            const itemType = parts[1];
            const itemOrigin = fromBase64UrlUtf8(parts[2]);
            const itemKey = fromBase64UrlUtf8(parts[3]);
            if (itemType !== storage_type) {
              return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: `item_id storage_type '${itemType}' does not match requested '${storage_type}'` }) }] };
            }
    
            const { targetId } = await ensureSessionTargetIsAlive(devtools_session_id);
            const { pageUrl, wsUrl } = await getCdpPageEndpoint(targetId);
    
            const currentOrigin = getOriginFromUrl(pageUrl);
            if (!currentOrigin) {
              return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: `No http(s) origin available for current page URL: '${pageUrl}'` }) }] };
            }
            if (origin && origin !== currentOrigin) {
              return {
                content: [{
                  type: "text",
                  text: JSON.stringify({ status: "error", error: `origin '${origin}' does not match current origin '${currentOrigin}'. Navigate first.` }),
                }],
              };
            }
            if (itemOrigin !== currentOrigin) {
              return {
                content: [{
                  type: "text",
                  text: JSON.stringify({ status: "error", error: `item_id origin '${itemOrigin}' does not match current origin '${currentOrigin}'. Navigate first.` }),
                }],
              };
            }
    
            const maxChars = Math.max(0, Math.min(HARD_VALUE_CAP_CHARS, Math.trunc(value_max_chars ?? HARD_VALUE_CAP_CHARS)));
            const stType = storage_type;
    
            const expr = `(() => {
      try {
        const storageType = ${JSON.stringify(stType)};
        const key = ${JSON.stringify(itemKey)};
        const maxChars = ${maxChars};
        const storage = storageType === "local" ? localStorage : sessionStorage;
        const raw = storage.getItem(key);
        const v = typeof raw === "string" ? raw : "";
        const valueLength = v.length;
        const truncated = maxChars > 0 && valueLength > maxChars;
        const value = maxChars > 0 ? (truncated ? v.slice(0, maxChars) : v) : v;
        return { key, value, valueLength, truncated };
      } catch (e) {
        return { error: String(e && e.message ? e.message : e) };
      }
    })()`;
    
            const result = await cdpEvaluateValue(wsUrl, expr) as unknown;
            if (!result || typeof result !== "object") {
              throw new Error("Unexpected storage evaluation result.");
            }
            const obj = result as Record<string, unknown>;
            if (obj.error) {
              throw new Error(`Storage evaluation error: ${typeof obj.error === "string" ? obj.error : JSON.stringify(obj.error)}`);
            }
    
            return {
              content: [{
                type: "text",
                text: truncateResult({
                  status: "success",
                  devtools_session_id,
                  target_id: targetId,
                  origin: currentOrigin,
                  storage_type: stType,
                  item_id,
                  key: obj.key ?? itemKey,
                  value: typeof obj.value === "string" ? obj.value : "",
                  value_length: typeof obj.valueLength === "number" ? obj.valueLength : null,
                  value_truncated: typeof obj.truncated === "boolean" ? obj.truncated : null,
                  value_max_chars: maxChars,
                }),
              }],
            };
          } 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