Run querySelectorAll in Safari with AI on Mac
Let your AI assistant run document.querySelectorAll in the current Safari tab on your Mac and return a compact summary of every match. Local, private, no API keys.
The LMCP tool safari_query_selector_all runs document.querySelectorAll inside whatever page is open in your front Safari tab and hands your AI assistant a compact summary of each matching element — tag, text, key attributes and counts. Instead of you copying CSS selectors into the developer console, you just describe what you want in plain English and the AI does the DOM query for you.
A concrete example prompt you can type: “In my current Safari tab, find every <a> inside the article and list their link text and href.” The AI calls safari_query_selector_all with the selector article a and returns a clean list of matches you can read or act on. It is a read-only tool, so it inspects the page without changing anything.
Download LMCP to give your AI this capability. LMCP is a free, native macOS MCP server with 150+ tools that lets AI assistants use your real Mac apps locally.
Which AI agents work?
You can use safari_query_selector_all from a wide range of assistants:
- Claude Desktop — auto-configures via local stdio.
- Cursor — auto-configures via local stdio.
- VS Code (GitHub Copilot) — auto-configures via local stdio.
- Windsurf — auto-configures via local stdio.
- Zed — auto-configures via local stdio.
- ChatGPT — connects through the LMCP Cloud Relay connector.
- Claude.ai (web) — connects through the LMCP Cloud Relay connector.
- Grok — connects through the LMCP Cloud Relay connector.
- Perplexity — connects through the LMCP Cloud Relay connector.
Desktop clients talk to LMCP over local stdio and configure themselves automatically. Web AIs reach your Mac securely through the LMCP Cloud Relay connector.
Automation
The real power shows when you chain safari_query_selector_all with other LMCP tools. The AI can query the DOM to discover the elements on a page, then act on those results: pull prices into a Reminder, drop a list of links into a Note, paste extracted contact rows into Contacts, or summarize a table and email it. Because the query returns structured matches, the AI can loop over them and decide what to do next — for example, “find every product card, read the title and price, and add the cheapest three to a shopping reminder.”
Context
This tool reads the live page in your Safari, with your logged-in session, your cookies and your exact scroll state. The AI sees the real DOM you are looking at — not a generic fetch of the public URL. That means it works on pages behind a login, on dynamic single-page apps, and on content rendered by JavaScript that a plain HTTP request would never see.
Productivity
Scraping a page by hand — opening dev tools, writing a selector, copying results into a spreadsheet — takes several minutes and a steady hand. With safari_query_selector_all you ask once and get a clean summary in seconds. Pulling all headings from a long article, listing every download link, grabbing every row of a results table, or auditing which images lack alt text becomes a one-sentence request. Over a research-heavy day that is dozens of saved minutes and zero context switching out of your assistant.
Privacy & GDPR
Everything runs locally on your Mac. The DOM query executes in your own Safari, the summary returns straight to your AI client, and nothing is copied to an LMCP server or any third-party cloud. There are no API keys to manage and nothing is stored remotely. This is privacy by design — see GDPR-compliant by architecture for why a local-first MCP server keeps your browsing data yours.