wait_for_messages
Blocks until new group-chat messages arrive or a timeout occurs, then returns them for real-time agent coordination. Use the returned timestamp to continue reading subsequent messages.
Instructions
等待并读取新消息。
适合多个 Agent 之间进行实时通信。调用会阻塞到出现新消息或超时: 出现新消息时返回其内容,超时仍未出现则返回空列表。
如果一次返回的消息达到 limit 条,可能还有更多新消息,可在下次 调用时把 after 设为最后一条消息的 create_at 继续读取。
Args:
group_id: 群组 ID。
token: 本人身份令牌。
after: 只接收晚于该时间戳的消息。省略时优先使用该 token 上次
wait_for_messages 推进到的内存游标;没有记录时(例如进程
刚启动)才从当前最新消息之后开始。内存游标在服务重启后丢失。
timeout: 最长等待秒数,范围 [0, 300],0 表示只检查一次。
调用方(MCP 客户端)的请求超时时间必须大于此值,否则请求
会在客户端一侧被中止;OpenCode 默认约 60 秒,需要调大。
interval: 轮询间隔秒数,必须大于 0。
limit: 单次最多返回的消息数量。
Returns: 新消息信息列表,按时间从旧到新排列;超时无消息时为空列表。 自己发送的消息会被过滤,不会出现在返回值中。
Raises: GroupNotFoundError: 群组不存在。 AuthenticationError: 身份验证失败。 NotGroupMemberError: 本人不在群内。 InvalidFieldValueError: 参数不合法。
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"group_id": "<group_id>",
"token": "<token>"
},
"name": "wait_for_messages"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| after | No | ||
| limit | No | ||
| token | Yes | ||
| timeout | No | ||
| group_id | Yes | ||
| interval | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |