CallCenter.js MCP + CLI 是一个 MCP 服务器、命令行工具和 API,借助 VoIP 技术代表你拨打电话。只需告知 Claude 你的需求,它就能自动拨打电话并处理对话。该工具本质上是一个 MCP 服务器,在 OpenAI 的实时语音 API 和你的 VoIP 连接之间架起桥梁,代表你拨打电话。
这是体验该工具的最快方式:
# 设置环境变量(或创建 .env 文件)
export SIP_USERNAME="your_extension"
export SIP_PASSWORD="your_password"
export SIP_SERVER_IP="192.168.1.1"
export OPENAI_API_KEY="sk-your-key-here"
# 直接从 GitHub 运行(无需安装!)
npx github:gerkensm/callcenter.js-mcp call "+1234567890" --brief "Call restaurant for reservation" --user-name "Your Name"
或者使用 .env 文件:
# 创建 .env 文件
cat > .env << EOF
SIP_USERNAME=your_extension
SIP_PASSWORD=your_password
SIP_SERVER_IP=192.168.1.1
OPENAI_API_KEY=sk-your-key-here
SIP_PROVIDER=fritz-box
OPENAI_VOICE=alloy
EOF
# 从 GitHub 运行(自动加载 .env 文件)
npx github:gerkensm/callcenter.js-mcp call "+1234567890" --brief "Call restaurant"
注意:首次运行时,若你未安装 C++ 构建工具,可能会显示构建警告,但使用 G.711 编解码器回退仍可正常工作(标准电话音质)。若想获得更好的音频质量,建议先安装构建工具以启用 G.722 宽带编解码器。
xcode-select --install)build-essential 包注意:若未安装构建工具,系统将自动回退到 G.711(标准电话音质)。G.722 编解码器的带宽是 G.711 的两倍,可实现更清晰、自然的对话。
# 克隆并安装
git clone https://github.com/gerkensm/callcenter.js-mcp
cd callcenter.js-mcp
npm install
# 复制示例配置文件
cp config.example.json config.json
编辑 config.json 文件,填入你的设置:
{
"sip": {
"username": "your_sip_username",
"password": "your_sip_password",
"serverIp": "192.168.1.1",
"serverPort": 5060,
"provider": "fritz-box"
},
"ai": {
"openaiApiKey": "sk-your-openai-api-key-here",
"voice": "alloy",
"instructions": "You are a helpful AI assistant making phone calls on behalf of users.",
"userName": "Your Name"
}
}
# 设置环境变量(或创建 .env 文件)
export SIP_USERNAME="your_extension"
export SIP_PASSWORD="your_password"
export SIP_SERVER_IP="192.168.1.1"
export OPENAI_API_KEY="sk-your-key-here"
# 直接从 GitHub 运行(无需安装!)
npx github:gerkensm/callcenter.js-mcp call "+1234567890" --brief "Call restaurant for reservation" --user-name "Your Name"
或者使用 .env 文件:
# 创建 .env 文件
cat > .env << EOF
SIP_USERNAME=your_extension
SIP_PASSWORD=your_password
SIP_SERVER_IP=192.168.1.1
OPENAI_API_KEY=sk-your-key-here
SIP_PROVIDER=fritz-box
OPENAI_VOICE=alloy
EOF
# 从 GitHub 运行(自动加载 .env 文件)
npx github:gerkensm/callcenter.js-mcp call "+1234567890" --brief "Call restaurant"
xcode-select --install)build-essential 包# 克隆并安装
git clone https://github.com/gerkensm/callcenter.js-mcp
cd callcenter.js-mcp
npm install
# 复制示例配置文件
cp config.example.json config.json
import { makeCall, createAgent } from 'callcenter.js';
// 简单通话示例
const result = await makeCall({
number: '+1234567890',
brief: 'Call Bocca di Bacco and book a table for 2 at 19:30 for Torben',
userName: 'Torben',
config: 'config.json'
});
console.log(`Call duration: ${result.duration}s`);
console.log(`Transcript: ${result.transcript}`);
// 高级用法:使用代理实例
const agent = await createAgent('config.json');
agent.on('callEnded', () => {
console.log('Call finished!');
});
await agent.makeCall({
targetNumber: '+1234567890',
duration: 300
});
这是最常用的用法,可与 Claude Code 无缝集成,实现 AI 驱动的通话。非常适合让你的编码代理联系库作者,反馈文档问题!😄
选项 1:使用 Claude Code CLI(最简单)
# 运行前请替换为你的实际凭证:
claude mcp add --env SIP_USERNAME=your_actual_extension \
--env SIP,PASSWORD="your_actual_password" \
--env SIP_SERVER_IP=192.168.1.1 \
--env OPENAI_API_KEY="sk-your_actual_openai_key" \
--env USER_NAME="Your Actual Name" \
-- callcenter.js npx -- github:gerkensm/callcenter.js-mcp --mcp
⚠️ 重要提示:请将占位符值替换为你的实际 SIP 凭证和 OpenAI API 密钥,否则服务器将无法连接。
选项 2:手动配置 在 Claude Code 的 MCP 设置中进行配置,自动从 GitHub 拉取:
{
"mcpServers": {
"callcenter.js": {
"command": "npx",
"args": ["github:gerkensm/callcenter.js-mcp", "--mcp"],
"env": {
"SIP_USERNAME": "your_extension",
"SIP_PASSWORD": "your_password",
"SIP_SERVER_IP": "192.168.1.1",
"OPENAI_API_KEY": "sk-your-key-here",
"USER_NAME": "Your Name"
}
}
}
}
若你需要进行本地开发或更喜欢本地安装方式:
npm start --mcp
或者使用本地安装进行配置:
{
"mcpServers": {
"callcenter.js": {
"command": "node",
"args": ["dist/cli.js", "--mcp"],
"cwd": "/path/to/voip-agent"
}
}
}
可用的 MCP 工具:
simple_call - 自动生成指令进行通话advanced_call - 可对参数进行精细控制的通话在 Claude Code 中的使用示例:
"Can you call Bocca di Bacco restaurant and book a table for 2 people tonight at 7:30pm? My name is John Doe." Claude 将自动使用 MCP 服务器为你拨打电话!
当你需要通过 curl -X POST 摆脱社交义务,或者实现 ai-human-sort 算法时,命令行界面是你的理想选择!😄
💡 建议使用 --brief 而非 --instructions 以获得更好的效果!
--brief 选项使用 OpenAI 的 o3-mini 模型,根据你的简单描述生成复杂的指令,而 --instructions 则直接将你的文本发送到实时语音 API。由于实时语音 API 更注重速度而非复杂性,因此 --brief 通常能产生更好的通话效果。
# ✅ 推荐:使用 brief 实现自然语言目标
npm start call "+1234567890" --brief "Call the restaurant and book a table for 2 at 7pm tonight" --user-name "John Doe"
# ✅ 推荐:brief 适用于任何类型的通话
npm start call "+1234567890" --brief "Call to check appointment availability for John Doe"
# ⚠️ 仅在需要特定自定义行为时使用 instructions
npm start call "+1234567890" --instructions "You must follow this exact script: Say hello, ask for manager, then hang up"
# 其他使用 brief 的示例
npm start call "+1234567890" --record "meeting.wav" --duration 300 --brief "Conference call to discuss project status"
npm start call "+1234567890" --log-level verbose --brief "Test call to verify connectivity"
npm start call [options]
Options:
-c, --config Configuration file path (default: config.json)
-d, --duration Maximum call duration in seconds (default: 600)
-v, --verbose Verbose mode - show all debug information
-q, --quiet Quiet mode - show only transcripts, errors, and warnings
--log-level Set log level (quiet|error|warn|info|debug|verbose) (default: info)
--no-colors Disable colored output
--no-timestamp Disable timestamps in logs
--record [filename] Enable stereo call recording (optional filename)
--brief Call brief to generate instructions from (RECOMMENDED)
--instructions Direct AI instructions (use only for specific custom behavior)
--user-name Your name for the AI to use when calling
--help Display help information
import { makeCall, createAgent } from 'callcenter.js';
// 简单通话示例
const result = await makeCall({
number: '+1234567890',
brief: 'Call Bocca di Bacco and book a table for 2 at 19:30 for Torben',
userName: 'Torben',
config: 'config.json'
});
console.log(`Call duration: ${result.duration}s`);
console.log(`Transcript: ${result.transcript}`);
// 高级用法:使用代理实例
const agent = await createAgent('config.json');
agent.on('callEnded', () => {
console.log('Call finished!');
});
await agent.makeCall({
targetNumber: '+1234567890',
duration: 300
});
# 测试编解码器可用性
npm run test:codecs
# 若需要,不使用 G.722 进行构建
npm run build:no-g722
OpenAI 的实时语音 API 优化了速度,但在处理复杂的目标导向任务时,若没有非常具体的指令,可能会遇到困难。以下是具体问题:
# 模糊的摘要 - 实时语音 API 会感到困惑且缺乏重点
npm start call "+1234567890" --brief "Call the restaurant and book a table"
# 每次手动编写详细指令
npm start call "+1234567890" --instructions "You are calling on behalf of John Doe to make a restaurant reservation for 2 people at Bocca di Bacco for tonight at 7pm. You should start by greeting them professionally, then clearly state your purpose. Ask about availability for 7pm, and if not available, ask for alternative times between 6-8pm. Confirm the booking details including date, time, party size, and get a confirmation number if possible. If you reach voicemail, leave a professional message with callback information..."
# 简单的摘要 - o3 模型生成复杂的指令
npm start call "+1234567890" --brief "Call Bocca di Bacco and book a table for 2 at 7pm tonight" --user-name "John Doe"
系统使用 OpenAI 的 o3-mini 推理模型(最新的小型推理模型,智能且快速),根据你的简单摘要自动生成详细、复杂的指令。o3-mini 模型的工作流程如下:
你的简单输入:
"Call Bocca di Bacco and book a table for 2 at 7pm tonight"
o3-mini 生成的内容(节选):
## 个性与语气
身份:我是代表 John Doe 进行餐厅预订的助理。
任务:我负责为今晚 7 点在 Bocca di Bacco 预订 2 人的餐桌。
语气:专业、热情且尊重。
## 指令
1. 立即开启对话:“您好,我是代表 John Doe 打电话的助理。”
2. 重复关键信息:确认时间和细节。
3. 处理异议:礼貌回应并提供 6 - 8 点之间的替代时间。
...
## 对话状态
[
{
"id": "1_greeting",
"description": "问候并介绍通话目的",
"instructions": ["自我介绍为助理", "立即提及预订请求"],
"examples": ["您好,我是代表 John Doe 打电话的助理。我想为今晚 7 点预订 2 人的餐桌。"]
}
]
o3-mini 摘要处理器会自动:
--brief:更便捷且效果更佳。--instructions。本项目采用 MIT 许可证,详情请参阅 LICENSE 文件。
在拨打电话之前,请验证你的配置:
# 基本验证
npm run validate config.json
# 详细验证,包含网络连接测试
npm run validate:detailed
# 获取针对问题的具体修复建议
npm run validate:fix
# 测试不同提供商的示例配置
npm run validate:fritz-box # AVM Fritz!Box
npm run validate:asterisk # Asterisk PBX
npm run validate:cisco # Cisco CUCM
npm run validate:3cx # 3CX Phone System
npm run validate:generic # 通用 SIP 提供商
验证器将检查以下内容:
提供商配置文件基于研究和文档,而非实际测试:
| 提供商 | 传输方式 | NAT 穿透 | 会话定时器 | PRACK | 保活机制 |
|---|---|---|---|---|---|
| Fritz Box | UDP | 无需 | 可选 | 禁用 | 重新注册 |
| Asterisk | UDP/TCP | STUN | 支持 | 可选 | OPTIONS ping |
| Cisco CUCM | 首选 TCP | 需要 STUN | 必需 | 必需 | OPTIONS ping |
| 3CX | TCP/UDP | STUN | 支持 | 可选 | 重新注册 |
项目包含所有主要提供商的即用型配置:
config.example.json - AVM Fritz!Box(家庭/中小企业默认配置)config.asterisk.example.json - Asterisk PBX 高级功能配置config.cisco.example.json - Cisco CUCM 企业级设置config.3cx.example.json - 3CX 电话系统 配置config.generic.example.json - 通用 SIP 提供商 模板# 完整构建(TypeScript + 原生插件)
npm run build
# 分别构建组件
npm run build:native # 仅构建原生 G.722 插件
npm run build:ts # 仅进行 TypeScript 编译
# 开发模式,支持热重载
npm run dev
# 清理所有构建产物
npm run clean
# 验证任何配置文件
npm run validate path/to/config.json
# 使用不同提供商进行测试
npm run validate -- --provider asterisk config.json
# 获取详细的网络诊断信息
npm run validate -- --detailed --network config.json
# 显示问题的修复建议
npm run validate -- --fix-suggestions config.json
src/
├── voice-agent.ts # 主协调模块,与连接管理器交互
├── connection-manager.ts # 智能连接处理和重连机制
├── sip-client.ts # 增强的 SIP 协议,支持不同提供商
├── audio-bridge.ts # RTP 流和编解码器管理
├── openai-client.ts # OpenAI 实时语音 API 集成
├── call-brief-processor.ts # o3-mini 模型通话摘要处理
├── mcp-server.ts # MCP(模型上下文协议)服务器
├── validation.ts # 配置验证引擎
├── config.ts # 增强的配置加载,支持提供商配置文件
├── logger.ts # 全面的日志记录,捕获通话记录
├── index.ts # 主编程 API 导出
├── providers/
│ └── profiles.ts # 特定提供商的配置数据库
├── testing/
│ └── network-tester.ts # 实际的网络连接测试
├── codecs/ # 编解码器抽象层
│ ├── g722.ts # G.722 宽带实现
│ └── g711.ts # G.711 回退编解码器
└── cli.ts # 命令行界面
scripts/
└── validate-config.js # 全面的验证 CLI 工具
config.*.example.json # 特定提供商的示例配置
内置的验证系统提供全面的分析:
🔍 CallCenter.js 配置验证器
📋 提供商: AVM Fritz!Box(自动检测)
🎯 提供商兼容性得分: 100%
✅ 配置有效,可立即使用!
🌐 网络连接:
✅ SIP 服务器: 可达(延迟 12ms)
✅ G.722 编解码器: 可用,可提供高质量音频
💡 优化建议:
💡 G.722 宽带编解码器可用(已启用)
💡 延迟极低 - 本地网络性能最优
🚀 下一步: npm start call ""
npm run validate:detailed
npm run validate -- --provider fritz-box config.json
npm run validate:fix
npm run test:codecs
✅ 所选编解码器: PT 9 (G722/8000)
# 先安装构建工具,然后:
npm run build:no-g722 # 仅回退到 G.711
# 检查端口冲突或配置问题
npm start --mcp
本项目是一个基于创意的项目!🚀 这意味着:
验证工具可能有助于调试问题,但实际能否拨打电话才是真正的测试。
npm run validate:detailed 进行测试。npm run validate:detailed 进行诊断。准备好开始了吗? 复制一个示例配置,运行 npm run validate:detailed,然后开始进行 AI 驱动的语音通话!🚀