跨平台系统通知服务

一个提供跨平台系统通知功能的MCP服务器,支持macOS、Windows和Linux,并包含完整的声音支持。

  • by YDFlame13
  • JavaScript
  • 本地部署
  • 更新于
在 GitHub 查看 YDFlame13/sys-notification-mcp

使用说明

MCP跨平台系统通知服务器

中文

厌倦了编码时错过重要通知?试试这个MCP+规则解决方案,永远不会错过任何一个节拍。

一种模型上下文协议(MCP)服务器,为AI助手提供跨平台系统通知功能,支持macOS、Windows和Linux,并提供完整的声音支持。

🎯 特性

跨平台通知支持

  • macOS:完全支持14种系统声音的本地系统通知
  • 视窗:吐司通知+系统声音播放
  • Linux:桌面通知+堪培拉gtk播放/壁纸系统声音

通知类型

  • 授权:需要用户授权时(例如,运行终端命令)
  • 完成:任务完成时(例如,代码生成完成)
  • 等待:等待用户响应时
  • 错误:发生错误时
  • 信息:一般信息通知

声音支持

所有平台都支持相同的14种声音,并具有自动跨平台映射功能:

声音 macOS Windows Linux
巴索 ✅ 本机 系统感叹号 对话框警告
打击 ✅ 本机 SystemHand 对话框错误
瓶子 ✅ 本地 系统星号 消息
青蛙 ✅ 本机 SystemQuestion 对话问题
搞笑 ✅ 本机 系统感叹号 对话框信息
玻璃 ✅ 本机 系统通知 完成
英雄 ✅ 本机 系统通知 完成
莫尔斯 ✅ 本机 系统感叹号 对话框警告
Ping ✅ 本机 系统通知 消息
流行音乐 ✅ 本机 系统默认 对话框信息
Purr ✅ 本机 系统默认 对话框信息
Sosumi ✅ 本机 SystemHand 对话框错误
潜艇 ✅ 本地 系统星号 消息
叮当声 ✅ 本机 系统默认 对话框信息

📋 用法

基本通知

{
  "serverName": "sys-notification-mcp",
  "toolName": "notify",
  "arguments": {
    "type": "completed",
    "message": "Code generation completed, please check the result"
  }
}

自定义通知

{
  "serverName": "sys-notification-mcp",
  "toolName": "notify",
  "arguments": {
    "type": "authorization",
    "message": "Your authorization is required to run terminal commands",
    "title": "🔐 Permission Request",
    "sound": "Glass"
  }
}

查询功能

// List all notification types
{
  "serverName": "sys-notification-mcp",
  "toolName": "list_notification_types"
}

// Get system information
{
  "serverName": "sys-notification-mcp",
  "toolName": "get_system_info"
}

🔧 安装和配置

需求

  • Node.js 18+
  • 平台特定通知支持:
    • macOS:无其他依赖项
    • Windows:PowerShell 5.0+
    • Linux:通知发送(通常与桌面环境一起安装)

方法1:全局npm安装(推荐)

# Install MCP server globally
npm install -g sys-notification-mcp

# Verify installation
sys-notification-mcp --help

方法2:本地源安装

# Clone the project
git clone <repository-url>
cd sys-notification-mcp

# Install dependencies
npm install

# Run local tests
node index.js

MCP客户端配置

全局安装(方法1)

添加到MCP客户端配置文件:

{
  "mcpServers": {
    "sys-notification-mcp": {
      "command": "sys-notification-mcp"
    }
  }
}

本地安装(方法2)

添加到MCP客户端配置文件(使用绝对路径):

{
  "mcpServers": {
    "sys-notification-mcp": {
      "command": "node",
      "args": ["/path/to/sys-notification-mcp/index.js"]
    }
  }
}

配置验证

配置后,重新启动MCP客户端。人工智能助手应该能够识别和使用通知功能。

📜 推荐:与规则文件一起使用

为什么使用规则文件?

该项目包括一个精心设计的规则文件 rule.txt 强烈建议所有AI助手确保:

  • 一致的用户体验:跨平台的统一通知行为
  • 及时的用户交互:在关键时刻通知用户
  • 错误处理:出现问题时立即通知
  • 性能优化:避免过多的通知影响用户体验

规则文件内容概述

规则文件定义了完整的通知行为规范:

  1. 强制性规则:回答问题后必须发送通知
  2. 通知类型定义:5种标准通知类型及其使用场景
  3. 调用时间规则:关于何时发送通知的详细指南
  4. 技术实施规范:MCP工具调用的标准格式
  5. 跨平台兼容性:macOS、Windows、Linux的优化说明

规则文件使用示例

// According to the rule file, AI assistants should send notifications after task completion
{
  "serverName": "sys-notification-mcp",
  "toolName": "notify",
  "arguments": {
    "type": "completed",
    "message": "Code refactoring completed, please check the result"
  }
}

获取规则文件

规则文件位于项目根目录中: rule.txt

人工智能助手应定期检查规则文件的更新,以确保使用最新的最佳实践。

🛠️ 开发指南

项目结构

sys-notification-mcp/
├── index.js          # Main server file
├── package.json      # Project configuration
├── README.md         # Documentation (English)
├── README_zh.md      # Chinese documentation
├── rule.txt          # AI behavior rules (recommended)
├── test-cross-platform.js # Functionality test script
└── IMPLEMENTATION.md # Technical implementation documentation

核心功能

  • sendNotification():主要通知发送功能
  • playSound():跨平台声音播放
  • getOS():操作系统检测
  • 平台特定的通知实施功能

扩展声音

要添加新声音,请将新映射添加到 SOUND_MAPPING 对象:

const SOUND_MAPPING = {
  "NewSound": { 
    macos: "NewSound", 
    windows: "SystemDefault", 
    linux: "dialog-information" 
  }
};

🌍 平台兼容性

macOS

  • ✅ 完全原生通知支持
  • ✅ 支持所有14种系统声音
  • ✅ 不需要额外的依赖关系

视窗

  • ✅ Toast通知支持
  • ✅ 通过PowerShell播放SystemSounds
  • ✅ 需要PowerShell 5.0+

Linux

  • ✅ 桌面通知支持(通知发送)
  • ✅ 通过canberra gtk play或paplay播放声音
  • ✅ 需要桌面环境支持

📝 使用场景

场景1:代码生成完成

{
  "type": "completed",
  "message": "React component generation completed with full TypeScript type definitions"
}

场景2:需要用户授权

{
  "type": "authorization",
  "message": "Your confirmation is required to install project dependencies",
  "sound": "Glass"
}

场景3:错误处理

{
  "type": "error",
  "message": "Compilation failed: Missing required dependencies",
  "sound": "Basso"
}

🔍 故障排除

常见问题

  1. Linux上没有声音

    • 安装canberra gtk play: sudo apt-get install libcanberra-gtk-module
    • 或者安装pulseaudio实用程序: sudo apt-get install pulseaudio-utils
  2. Windows通知未显示

    • 确保PowerShell执行策略允许脚本执行
    • 检查是否启用了系统通知设置
  3. macOS听起来不工作

    • 检查系统声音设置
    • 确认通知中心权限

调试信息

使用 get_system_info 获取当前系统支持信息的工具:

{
  "serverName": "sys-notification-mcp",
  "toolName": "get_system_info"
}

📄 许可证

MIT许可证

🤝 贡献

欢迎提交问题和拉取请求以改进此项目!


备注:此MCP服务器专为AI助手设计,可确保在需要交互时及时通知用户,增强AI助手的交互体验。强烈建议与 rule.txt 规则文件,以获得最佳用户体验。