chromedevtools--chrome-devtools-mcp
627ed68a28
DOM elements are non-serializable and therefore cannot be directly sent between the inspected page and the MCP server. JSONSchema also has no native type for DOM elements. If an in-page tool expects a DOM element as an input parameter, it should specify this in its input schema by adding `'x-mcp-type': 'HTMLElement'` to the object it expects to be a DOM element. The MCP server internally refers to DOM elements by a UID (UIDs are assigned when generating a page snapshot which is based on the page's accessibility tree). This change provides the mapping between DOM element and UID in both directions: 1) The tool's input schema is rewritten internally, adding a required UID attribute to objects with `'x-mcp-type': 'HTMLElement'`. This allows the MCP server to call the in-page tool with UIDs where the tool expects DOM elements. 2) In the page context, the UIDs are replaced with the corresponding DOM elements, before the actual in-page tool is called. This means that the in-page tool receives DOM elements as parameters where it expects them.