使用说明
项目简介
本 Twilio Messaging MCP Server 是一个实现了 Model Context Protocol (MCP) 的应用后端,专注于提供短信发送功能。它允许大型语言模型 (LLM) 客户端,如 Claude Desktop,通过标准化的 MCP 协议调用 Twilio API 发送短信。该服务器旨在为 LLM 应用提供安全、可扩展的短信发送能力。
主要功能点
- 短信发送工具: 提供 'send-sms' 工具,允许 LLM 通过 Twilio 发送短信到指定号码。
- MCP协议兼容: 遵循 MCP 协议标准,易于与任何支持 MCP 协议的客户端集成。
- 安全凭据处理: 通过命令行参数传递 Twilio API 密钥等敏感信息,避免硬编码或使用不安全的环境变量。
- 易于部署和使用: 可通过 'npx' 直接运行,或全局安装后使用命令行工具启动。
- Claude Desktop 集成: 提供详细的 Claude Desktop 客户端配置指南,方便用户快速集成使用。
安装步骤
您可以通过以下两种方式安装和运行 Twilio Messaging MCP Server:
方式一:使用 npx (无需全局安装)
这是最快速的运行方式,无需全局安装 'twilio-messaging-mcp-server' 包。
-
确保您已安装 Node.js 和 npm。
-
打开终端,直接运行以下命令,替换 '<accountSid>'、'<apiKey>'、'<apiSecret>' 和 '<number>' 为您的 Twilio 账户信息和 Twilio 电话号码:
npx twilio-messaging-mcp-server <accountSid> <apiKey> <apiSecret> <number>
方式二:全局安装 (推荐)
全局安装后,您可以更方便地从任何位置运行服务器。
-
确保您已安装 Node.js 和 npm。
-
打开终端,运行以下命令进行全局安装:
npm install -g twilio-messaging-mcp-server -
安装完成后,您可以直接使用 'twilio-messaging-mcp-server' 命令启动服务器,同样需要替换 '<accountSid>'、'<apiKey>'、'<apiSecret>' 和 '<number>' 为您的 Twilio 账户信息和 Twilio 电话号码:
twilio-messaging-mcp-server <accountSid> <apiKey> <apiSecret> <number>
服务器配置
为了让 MCP 客户端(例如 Claude Desktop)连接到 Twilio Messaging MCP Server,您需要在客户端的配置文件中添加服务器配置信息。以下是 Claude Desktop 的配置示例,请根据您的 MCP 客户端进行相应配置。
Claude Desktop 配置示例 (JSON 格式):
{ "mcpServers": { "twilio-messaging": { "command": "npx", // 启动服务器的命令,如果全局安装则为 "twilio-messaging-mcp-server" "args": [ "-y", "twilio-messaging-mcp-server", // 服务器启动脚本 "your_account_sid_here", // 您的 Twilio Account SID (以 "AC" 开头) "your_api_key_here", // 您的 Twilio API Key (以 "SK" 开头) "your_api_secret_here", // 您的 Twilio API Secret "+1234567890" // 您的 Twilio 电话号码,E.164 格式 (例如: +1234567890) ] } } }
配置参数说明:
- '"twilio-messaging"': 服务器名称,您可以自定义,用于在客户端中标识该服务器。
- '"command"': 启动服务器的命令。
- 如果您使用 'npx' 运行,则设置为 '"npx"'。
- 如果您全局安装了 'twilio-messaging-mcp-server',则可以尝试设置为 '"twilio-messaging-mcp-server"' 或 '"node"' 并指定脚本路径。
- '"args"': 传递给启动命令的参数数组。
- '"-y"': (可选) 'npx' 的参数,用于自动确认执行。
- '"twilio-messaging-mcp-server"': 服务器启动脚本名称 (在使用 'npx' 时)。
- '"your_account_sid_here"': 请替换为您的实际 Twilio Account SID。
- '"your_api_key_here"': 请替换为您的实际 Twilio API Key。
- '"your_api_secret_here"': 请替换为您的实际 Twilio API Secret。
- '"+1234567890"': 请替换为您的实际 Twilio 电话号码 (E.164 格式),用于发送短信。
重要提示:
- 请务必将 '"your_account_sid_here"'、'"your_api_key_here"'、'"your_api_secret_here"' 和 '"+1234567890"' 替换为您真实的 Twilio 账户信息和电话号码。
- Twilio Account SID 必须以 "AC" 开头。
- Twilio API Key 必须以 "SK" 开头。
- Twilio 电话号码必须使用 E.164 格式,例如 '+1234567890'。
基本使用方法
配置完成后,当您在 MCP 客户端(如 Claude Desktop)中使用 LLM 时,就可以调用 'send-sms' 工具发送短信了。
在 LLM 中使用 'send-sms' 工具的示例:
Can you send an SMS to +1234567890 saying "Hello from MCP!"
LLM 客户端会将上述指令转换为对 'send-sms' 工具的调用,并将电话号码 '+1234567890' 和消息内容 '"Hello from MCP!"' 作为参数传递给 Twilio Messaging MCP Server。服务器接收到请求后,会调用 Twilio API 发送短信,并将发送结果返回给 LLM 客户端。
工具参数:
- 'to': 目标电话号码,E.164 格式 (例如: +1234567890)。
- 'message': 短信内容。
信息
分类
通信与社交