A small macOS command-line utility that returns the titles and URLs of open Safari tabs as JSON. It uses AppleScript through a short Python wrapper and can also be called from local automation tools.
The tool targets a specific macOS workflow. Changes to Safari, macOS permissions, or assistant integrations may require updates.
- macOS with Safari
- Python 3.12 or newer
- uv
git clone https://github.com/GoWithitRoger/get-tabs-tool.git
cd get-tabs-tool
uv run get_tabs_tool.pyExample output:
[
{
"title": "Example",
"url": "https://example.com/"
}
]The first run may prompt your terminal application for permission to control Safari. If needed, review the setting under System Settings → Privacy & Security → Automation.
The repository includes discover_tools.sh and call_tool.sh for the older Gemini CLI local-tool
interface. Point Gemini's toolDiscoveryCommand and toolCallCommand settings at those files and
make them executable:
chmod +x discover_tools.sh call_tool.shThose scripts are a convenience and may change with Gemini CLI releases. The standalone Python command does not depend on Gemini.
The parser tests do not open Safari and can run on any platform:
python -m unittest discover -s testsMIT. See LICENSE.