内容
# 代理 Ping 服务器
一个小型的 MCP 服务器,为代理提供 `ping` 工具,以便在工作完成后发送跨平台的桌面通知。
## 功能
- 暴露一个 MCP 工具: **`ping(message: str, title: str)`**
- 发送本地操作系统通知(Windows toast / macOS alert / Linux notify-send)
- 可选的 **移动推送通知**,通过 [Apprise](https://github.com/caronc/apprise) — 支持 80 多种服务(ntfy.sh、Pushover、Slack、Discord、Telegram、电子邮件、短信等)
- 包括一个技能,提醒代理在完成前调用 `ping`
## 安装
**适用于任何代理的单行命令:**
```bash
curl -fsSL https://raw.githubusercontent.com/gitbannedme/ping/main/install.sh | bash
```
或选择您的代理:
### Claude 代码
Claude 代码从 `~/.claude.json`(macOS/Linux)或 `%USERPROFILE%\.claude.json`(Windows)读取全局 MCP 服务器:
```json
{
"mcpServers": {
"agent-ping": {
"type": "stdio",
"command": "python3",
"args": ["/path/to/ping/server.py"]
}
}
}
```
### Cursor
添加到 `.cursor/mcp.json`:
```json
{
"mcpServers": {
"agent-ping": {
"command": "python3",
"args": ["/path/to/ping/server.py"]
}
}
}
```
### OpenAI Codex CLI
添加到 `.codex/config.json`:
```json
{
"mcpServers": {
"agent-ping": {
"command": "python3",
"args": ["/path/to/ping/server.py"]
}
}
}
```
### OpenCode
告诉 OpenCode:
```
从 https://raw.githubusercontent.com/gitbannedme/ping/main/.opencode/INSTALL.md 获取并遵循说明
```
### 手动安装
```bash
git clone https://github.com/gitbannedme/ping.git
cd ping
pip install -r requirements.txt
python server.py
```
## 移动通知(可选)
代理 ping 使用 [Apprise](https://github.com/caronc/apprise) 向几乎任何服务推送通知。选择您的后端,获取 URL,并在启动代理之前设置环境变量。
### 快速开始
```bash
# Bash / Zsh
export APPRISE_URLS="ntfys://my-secret-topic"
# Windows PowerShell
$env:APPRISE_URLS="ntfys://my-secret-topic"
```
### 流行的后端
| 服务 | 示例 URL | 备注 |
|---------|-------------|-------|
| [ntfy.sh](https://ntfy.sh) | `ntfys://your-topic` | 最简单 — 无需帐户 |
| [Pushover](https://pushover.net) | `pover://user@token` | 加密,私有 |
| Slack | `slack://TokenA/TokenB/TokenC/Channel` | 团队警报 |
| Discord | `discord://webhook_id/webhook_token` | 服务器警报 |
| Telegram | `tgram://bottoken/ChatID` | 直接消息 |
| 电子邮件 | `mailto://user:pass@gmail.com` | 任何 SMTP 服务器 |
| 短信 | `twilio://AccountSid:AuthToken@FromPhoneNo/ToPhoneNo` | 通过 Twilio |
您可以链接多个服务:
```bash
export APPRISE_URLS="ntfys://topic pover://user@token discord://id/token"
```
### 旧环境变量(仍然有效)
如果您已经设置了这些变量,它们会自动转换为 apprise URLs:
- `NTFY_TOPIC` → `ntfys://<topic>`
- `PUSHOVER_TOKEN` + `PUSHOVER_USER` → `pover://<user>@<token>`
## 用法
代理调用:
```json
{
"tool": "ping",
"arguments": {
"message": "重构完成 — 所有测试通过",
"title": "Kwillo 后端"
}
}
```
您将获得本地桌面通知以及您配置的任何移动/远程服务。