内容
# manychat-mcp
一款[模型上下文协议](https://modelcontextprotocol.io)服务器,封装了**ManyChat账户/页面API**,使Claude(或任何MCP客户端)能够管理订阅者、标签、自定义字段以及触发流程/发送内容。
18种工具,涵盖六大功能领域 — 页面、订阅者、标签、自定义字段、机器人字段和发送。
## 快速安装
```bash
pip install manychat-mcp
```
或使用`uv`:
```bash
uv tool install manychat-mcp
```
## 设置
### 1. 生成ManyChat API密钥
在ManyChat → **设置 → API → 生成您的API密钥**。该密钥限定在一个单独的页面/账户范围内。复制它。
参阅ManyChat指南:
https://help.manychat.com/hc/en-us/articles/14959510331420
### 2. 配置`.env`
```bash
MANYCHAT_API_KEY=您的页面API密钥
```
可选覆盖配置:
```bash
# 默认值:https://api.manychat.com
MANYCHAT_API_BASE=https://api.manychat.com
# 路径前缀;ManyChat使用/fb/作为统一账户API的前缀。只有当ManyChat更改此配置时才需要覆盖。
MANYCHAT_API_PREFIX=fb
```
## 连接到Claude Desktop
编辑`~/.config/Claude/claude_desktop_config.json`(Linux)/ `~/Library/Application Support/Claude/claude_desktop_config.json`(macOS):
```json
{
"mcpServers": {
"manychat": {
"command": "manychat-mcp",
"env": {
"MANYCHAT_API_KEY": "您的页面API密钥"
}
}
}
}
```
重启Claude Desktop。您应该会在`manychat`服务器下看到18种工具。
## 可用工具
### 页面
| 工具 | 功能描述 |
|---|---|
| `get_page_info` | 获取页面/账户信息。 |
| `list_tags` | 获取页面上的所有标签(ID + 名称)。 |
| `create_tag` | 创建一个新的标签。 |
| `list_custom_fields` | 获取订阅者级别的自定义字段。 |
| `list_bot_fields` | 获取页面级别(机器人)的字段。 |
| `list_flows` | 获取所有流程(自动化)及其`ns` ID。 |
### 订阅者
| 工具 | 功能描述 |
|---|---|
| `get_subscriber` | 通过`subscriber_id`查找订阅者。 |
| `get_subscriber_by_user_ref` | 通过`user_ref`查找订阅者。 |
| `find_subscriber_by_name` | 通过名称搜索订阅者。 |
| `find_subscriber_by_custom_field` | 通过自定义字段值搜索订阅者。 |
### 标签
| 工具 | 功能描述 |
|---|---|
| `add_tag` | 向订阅者添加标签(按名称)。 |
| `remove_tag` | 从订阅者中删除标签(按名称)。 |
### 自定义字段
| 工具 | 功能描述 |
|---|---|
| `set_custom_field` | 设置一个自定义字段(按名称)。 |
| `set_custom_fields` | 设置多个自定义字段(按ID)。 |
### 机器人(页面级别)字段
| 工具 | 功能描述 |
|---|---|
| `set_bot_field` | 设置一个页面级别的字段(按名称)。 |
### 发送
| 工具 | 功能描述 |
|---|---|
| `send_content` | 向订阅者发送内容块。可选`message_tag`用于24小时窗口外。 |
| `send_content_by_user_ref` | 通过`user_ref`发送内容。 |
| `send_flow` | 为订阅者触发流程(自动化)。 |
## 注意事项
- **API前缀为`/fb/`,即使是Instagram/WhatsApp页面。** ManyChat的账户API是统一的 — 通道由页面在ManyChat内部的配置决定,而不是由URL路径决定。
- **`send_content`在24小时外需要`message_tag`。** 与Meta的Messenger Platform规则相同 — 没有标签,您只能在24小时用户发起的窗口内给订阅者发送消息。标签需要Meta批准。
- **错误返回结构化字典,** 而不是异常。查找`error: true`,包含`status`、`message`和`details`。
- **`flow_ns`** 是流程命名空间(类似于`content_xxxxxxxx`);从`list_flows()`获取。
## 开发
```bash
git clone https://github.com/AleemHaider/manychat-mcp
cd manychat-mcp
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest
```
## 许可证
MIT — 请参阅[LICENSE](LICENSE)。