这是一个适用于 macOS 通知的模型上下文协议(MCP)服务器,支持与 tmux 集成。该工具允许像 Claude 这样的 AI 助手发送原生 macOS 通知,点击通知时可以聚焦到特定的 tmux 会话。
npm install -g macos-notify-mcp
git clone https://github.com/yuki-yano/macos-notify-mcp.git
cd macos-notify-mcp
npm install
npm run build
npm run build-app # 构建 macOS 应用程序包(仅开发时需要)
首先,全局安装该包:
npm install -g macos-notify-mcp
使用 claude mcp add 命令:
claude mcp add macos-notify -s user -- macos-notify-mcp
然后重启 Claude Code。
编辑 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"macos-notify": {
"command": "macos-notify-mcp"
}
}
}
send_notification - 发送 macOS 通知
message(必需):通知消息title:通知标题(默认:"Claude Code")sound:通知声音(默认:"Glass")session:tmux 会话名称window:tmux 窗口编号pane:tmux 窗格编号useCurrent:使用当前 tmux 位置list_tmux_sessions - 列出可用的 tmux 会话
get_current_tmux_info - 获取当前 tmux 会话信息
# 基本通知
macos-notify-cli -m "Build completed"
# 带标题的通知
macos-notify-cli -t "Development" -m "Tests passed"
# 与 tmux 集成的通知
macos-notify-cli -m "Task finished" -s my-session -w 1 -p 0
# 使用当前 tmux 位置
macos-notify-cli -m "Check this pane" --current-tmux
# 检测当前终端模拟器
macos-notify-cli --detect-terminal
# 列出 tmux 会话
macos-notify-cli --list-sessions
该工具会自动检测你使用的终端模拟器,并在你点击通知时利用此信息聚焦到正确的应用程序。你可以使用以下命令测试终端检测:
# 测试终端检测
macos-notify-cli --detect-terminal
该工具使用多种方法检测终端:
CURSOR_TRACE_ID 环境变量VSCODE_IPC_HOOK_CLI 或 VSCODE_REMOTE 环境变量ALACRITTY_WINDOW_ID 或 ALACRITTY_SOCKET 环境变量TERM_PROGRAM=iTerm.appTERM_PROGRAM=Apple_Terminal当在 tmux 中运行时,该工具会尝试检测活动 tmux 客户端使用的终端模拟器:
有关高级 tmux 客户端跟踪的详细信息,请参阅 examples/tmux-client-tracking.sh。
该项目由两个主要组件组成:
MCP 服务器/CLI(TypeScript/Node.js)
MacOSNotifyMCP.app(Swift/macOS)
MacOSNotifyMCP.app 已包含在 npm 包中,安装后即可自动使用,无需额外设置。
macos-notify-mcp -m "test" 进行验证macos-notify-mcp --list-sessions 检查会话名称# 安装依赖
npm install
# 构建 TypeScript
npm run build
# 开发模式运行
npm run dev
# 代码检查和格式化
npm run lint
npm run format
# 构建 macOS 应用程序(仅在修改 Swift 代码时需要)
npm run build-app
MIT
Yuki Yano