
Hammerspoon
io.github.mobabur94由 GitHub 账号 mobabur94 发布v0.1.0更新于 Oct 25, 2026
macOS automation via Hammerspoon — 75 tools for windows, Spaces, audio, Bluetooth, and more
概览
一个本地 MCP 服务器,通过 Hammerspoon 让 AI 助手以编程方式控制 macOS:窗口、空间、音频、蓝牙、专注模式和系统状态。
- 可以做什么
- 列出、聚焦、移动和调整窗口,应用或保存布局预设,并管理空间与虚拟桌面,包括 Mission Control 切换和跨空间移动窗口。启动、激活和退出应用,并模拟点击、输入文字和快捷键。截取屏幕、读取显示器和光标信息、调节亮度。列出并切换音频设备、音量和静音,控制蓝牙开关、配对与连接。读取和更改电池、Wi-Fi、音量、深色模式、剪贴板、通知、计时器和防休眠等系统状态。监听应用、Wi-Fi、USB、电池、屏幕、文件、睡眠、剪贴板和 URL 等实时系统事件,并可执行 shell 命令、打开 URL 或运行 Lua
- 适用场景
- 适合希望助手直接操作 Mac 而不是靠截图和点击的场景:排列窗口、切换音频或蓝牙设备、在空间之间移动应用、开启专注时段,或对系统事件作出反应。适合已在使用或愿意安装 Hammerspoon 的 macOS 用户。
- 运行要求
- macOS 13 或更高版本、Node.js(标注 22+,据称 20 也可运行),以及已安装 Hammerspoon 并在其 init.lua 中启用 hs.ipc 模块。蓝牙工具还需要 blueutil。窗口、输入和应用控制需要辅助功能权限;截图需要屏幕录制权限。无需 API 密钥或账户。
安装
在 SourceWeft 中
- 打开 控制台中的 Hammerspoon,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
hammerspoon-mcp
Give AI agents deep control over macOS — windows, audio, Bluetooth, Spaces, Focus mode, and 200+ OS APIs — through one MCP server.
[macOS 13+] [Node 22+] [MIT License] [TypeScript]
What is this?
An MCP server that bridges AI agents to Hammerspoon — the most powerful macOS automation tool available. Unlike screenshot-and-click tools, this gives agents programmatic OS-level access: manage windows by ID, switch audio devices by name, move apps between Spaces, toggle Focus mode, and subscribe to real-time OS events.
75 tools. 12 subscribable resources. Zero native dependencies.
Quick Start
Note: The server auto-discovers the
hsbinary — it checks~/.local/bin/hs,/usr/local/bin/hs,/opt/homebrew/bin/hs, and the app bundle path. You don't needhson your PATH if Hammerspoon is installed to/Applications.
Architecture
MCP Client Configuration
Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
Claude Code
Cursor / VS Code / Copilot
Add to .vscode/mcp.json:
Kiro
Add to ~/.aws/amazonq/mcp.json:
Tools
🪟 Window Management (7)
🖥️ Spaces / Virtual Desktops (9)
📱 Application Control (3)
⌨️ Input (3)
🖼️ Screen (3)
🔊 Audio Devices (6)
🔵 Bluetooth (5)
Requires blueutil:
brew install blueutil
🌙 Focus / Do Not Disturb (6)
🔋 System State (6)
🔆 Display (1)
⏱️ Timers (3)
📁 Finder / Files (4)
🛠️ Utilities (5)
👁️ Watchers — Live OS Event Streams (13)
🧪 Escape Hatch (1)
This gives access to all 200+ Hammerspoon modules not covered by dedicated tools — USB details, serial ports, network interfaces, Canvas drawing, menubar items, etc.
Resources (Subscriptions)
MCP clients can subscribe to resource URIs and receive push notifications when OS events fire:
How event streaming works
Examples
"Tile my editor and terminal side by side"
"Switch my audio to AirPods"
"Move Slack to Space 3"
"Start a 25-minute focus session"
"Notify me when I switch away from my IDE"
"Connect my headphones and set volume to 40%"
Compared to Alternatives
Prerequisites
The
hsCLI symlink (hs.ipc.cliInstall()) is optional — the server auto-discovers the binary inside the Hammerspoon app bundle.
Verify setup
If this works, npx hammerspoon-mcp will connect successfully.
Permissions
Project Structure
Development
How It Works
- Startup — the bridge auto-discovers the
hsbinary (checks~/.local/bin,/usr/local/bin,/opt/homebrew/bin, app bundle) and validates connectivity - Tools execute synchronously via
hs -c '<lua>'— typically 30–80ms per call. Stdout noise (-- Loading extension: ...) is stripped automatically - Watchers inject Lua code that writes JSON lines to a FIFO pipe; a Node reader process emits them as MCP resource updates
- Resources buffer the last 50 events per watcher; clients read on-demand after receiving update notifications
- Graceful shutdown stops all watchers and cleans up the pipe on SIGINT/SIGTERM
Known Limitations
- Node.js 22+ is specified in
enginesbut the server builds and runs fine on Node 20 (tested) hs_spaces_goto,addSpaceToScreen,removeSpacebriefly flash Mission Control (macOS limitation — enable "Reduce motion" to minimize)- Bluetooth tools require blueutil (
brew install blueutil) - Focus/DND reading uses heuristics (no public Apple API exists)
hs_screenshotreturns base64 — large for full-screen captures- Saved layouts persist only in Hammerspoon's runtime (lost on HS reload)
- Named pipe path is
/tmp/hs-mcp-events.pipe— only one server instance at a time
License
MIT © 2026 Mohammed Babur
来源:README.md,提交 388b47d
工具
0版本历史
1- v0.1.0最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分