内容
mcp-pulse
一个小巧、无依赖的 Node.js 命令行工具,用于监控一组 MCP(模型上下文协议)服务器,并报告健康状态、延迟和运行时间。零运行时依赖。适用于 Node 20+。
如果你运行了多个 MCP 服务器,你可能已经遇到了这个问题:其中一个服务器无声无息地超时,你的代理开始在缺少的工具周围出现幻觉,直到下游出现问题时才注意到。`mcp-pulse` 保留了每个服务器的一小段探测结果窗口,以便你可以一目了然地看到哪些服务器是健康的,哪些是慢的,哪些是宕机的。
## 安装
```bash
npm install -g @mukundakatta/mcp-pulse
```
安装后,您也可以将其作为 `mp` 调用。
## 快速入门
创建一个描述您的 MCP 服务器的 `fleet.json` 文件:
```json
{
"servers": [
{
"name": "fs-local",
"transport": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
},
{
"name": "search-remote",
"transport": "http",
"url": "http://localhost:9000/mcp",
"timeoutMs": 3000
}
]
}
```
运行一次:
```bash
mcp-pulse check fleet.json
```
在 10 秒循环中监视:
```bash
mcp-pulse watch fleet.json --interval=10
```
## 命令行参考
```
mcp-pulse watch <config.json> [--interval=<sec>] [--json]
mcp-pulse check <config.json> [--json]
mcp-pulse --help
mcp-pulse --version
```
选项:
| 标志 | 默认值 | 备注 |
|--------------------|---------|-------------------------------------------------------|
| `--interval=<sec>` | `10` | 在 `watch` 模式下,多久重新探测一次。 |
| `--json` | off | 输出 JSON 而不是 ANSI 表格。 |
退出代码:
- `check` 在最新探测中所有服务器都健康时退出 `0`,如果任何服务器宕机则退出 `1`。
- `watch` 运行直到您发送 `SIGINT`(Ctrl+C)。
## 状态表
```
名称 状态 运行时间% p50毫秒 p95毫秒 最后错误
------------- ------ ------- ----- ----- ----------
fs-local ● 100.0 12 14
search-remote 66.7 - - http 状态 502状态列显示 `●`的探测是健康的,`✗` 表示探测失败。运行50 和 p95 从滚动样本窗口(默认为 100)计算。
## 库使用
该软件包还导出了可编程使用的构建块:
```js
import { probeServer, RollingStore, loadConfig } from '@mukundakatta/mcp-pulse';
const config = await loadConfig('./fleet.json');
const store = new RollingStore({ 50 });
for ( of config.servers) const result = await probe);
store.record(server { ok: result.ok, latencyMs: result.latencyMs, error: result.error });
}
console.summaries());
```
Server(server, opts?)` ok, latencyMs, error?, }` 且永不抛出 配置模式
```ts
type Config = {
servers: | {
name: transport: 'stdio command: string;
args?: timeoutMs?: number 默认 5000
| {
name: string transport: 'http';
url: string;
timeoutMs;
}
>;
验证很严格;缺少字段一个清晰的错误,指向条目。
## 为什么是?
`mcp-pulse` 仅包含 Node 标准库安装快速、供应链小,并且地放入 CI 镜像 中。探测使用 `child` 进行 stdio 服务器,使用 `fetch`(带有Controller`)进行 HTTP 请求 许可证
MIT