
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 分