Run JavaScript in Safari with AI on Mac
Let your AI assistant run JavaScript in the current Safari tab and read the result — locally on your Mac. No API keys, no cloud. Works with Claude, ChatGPT and more.
The safari_evaluate_js tool lets your AI assistant run arbitrary JavaScript in the page that is currently open in Safari and read back whatever that script returns. Instead of describing a page to the AI by hand, you just ask — and the assistant pulls the live value straight out of the DOM. Try a prompt like: "In my current Safari tab, run JavaScript that returns the page title and the count of all links, then summarize what this page is about." The AI writes the JavaScript, LMCP executes it in the active tab, and the result flows back into the conversation.
Because it runs real JavaScript, it can do far more than read text: extract structured data from tables, count elements that match a selector, read the value of a form field, scrape prices off a product page, or pull a hidden API token your page exposes on window. It returns the result of the expression — strings, numbers, JSON-serializable objects — so the AI can reason over actual page state, not a screenshot. One requirement: enable Develop → Allow JavaScript from Apple Events in Safari (the Develop menu lives under Safari Settings → Advanced).
LMCP is a free, native macOS MCP server that exposes 150+ tools across your real Mac apps. Download LMCP to get started in a couple of minutes.
Which AI agents work?
Desktop clients auto-configure over local stdio — nothing to wire up by hand:
- Claude Desktop
- Cursor
- VS Code (GitHub Copilot)
- Windsurf
- Zed
Web-based AIs connect through the LMCP Cloud Relay connector, so they can reach the very same tools running on your Mac:
- ChatGPT
- Claude.ai (web)
- Grok
- Perplexity
Automation
The power of safari_evaluate_js shows when it chains with other tools. The AI can open a URL with a Safari navigation tool, evaluate JavaScript to extract a list of items, then drop those into create_reminders, a Note, or an email draft — all in one prompt. Read a shipping status off a carrier page and the AI adds a calendar event for the delivery date. Pull a table of figures and have it write them into an Excel file. Each tool does one job; the AI composes them into a full workflow.
Context
This tool gives the AI grounding in your actual browsing session — the real page you are looking at, logged in, with live data. It is not guessing from a stale crawl or a cached copy. Whatever JavaScript reads from the current tab is the ground truth the assistant works from, which means its answers reflect exactly what is on your screen right now.
Productivity
Manually copying values out of a web app, reformatting them, and pasting them somewhere else is the kind of busywork that eats minutes many times a day. With safari_evaluate_js the AI extracts and transforms page data in a single sentence — "grab every order number and total from this page and make me a summary table." What used to be a tab-switching copy-paste chore becomes one prompt and a few seconds.
Privacy & GDPR
Everything happens locally on your Mac. The JavaScript runs in your Safari tab, the result returns straight to your AI client, and nothing is uploaded to or stored on an LMCP server. There are no API keys to hand over and no cloud copy of your data. This local-first design makes LMCP GDPR-compliant by architecture — your browsing data never leaves the machine it lives on.