agent-communication-mcp 0.5.5 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +702 -0
- package/README.md +287 -192
- package/dist/cli/args.d.ts +23 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +58 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/main.d.ts +12 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +63 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/token.d.ts +25 -0
- package/dist/cli/token.d.ts.map +1 -0
- package/dist/cli/token.js +142 -0
- package/dist/cli/token.js.map +1 -0
- package/dist/cloud/config.d.ts +1 -0
- package/dist/cloud/config.d.ts.map +1 -1
- package/dist/cloud/config.js +11 -8
- package/dist/cloud/config.js.map +1 -1
- package/dist/cloud/validation.d.ts.map +1 -1
- package/dist/cloud/validation.js +9 -8
- package/dist/cloud/validation.js.map +1 -1
- package/dist/features/rooms/index.d.ts +0 -1
- package/dist/features/rooms/index.d.ts.map +1 -1
- package/dist/features/rooms/index.js +1 -3
- package/dist/features/rooms/index.js.map +1 -1
- package/dist/features/rooms/presence/PresenceService.d.ts.map +1 -1
- package/dist/features/rooms/presence/PresenceService.js +8 -8
- package/dist/features/rooms/presence/PresenceService.js.map +1 -1
- package/dist/features/rooms/presence/PresenceStorage.d.ts.map +1 -1
- package/dist/features/rooms/presence/PresenceStorage.js +1 -1
- package/dist/features/rooms/presence/PresenceStorage.js.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/schemas/room.schema.d.ts +12 -12
- package/dist/schemas/room.schema.d.ts.map +1 -1
- package/dist/schemas/room.schema.js +11 -4
- package/dist/schemas/room.schema.js.map +1 -1
- package/dist/tools/room.d.ts.map +1 -1
- package/dist/tools/room.js +33 -1
- package/dist/tools/room.js.map +1 -1
- package/package.json +2 -1
- package/dist/features/rooms/tools/presence.tools.d.ts +0 -44
- package/dist/features/rooms/tools/presence.tools.d.ts.map +0 -1
- package/dist/features/rooms/tools/presence.tools.js +0 -183
- package/dist/features/rooms/tools/presence.tools.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,52 +1,56 @@
|
|
|
1
1
|
# Agent Communication MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/agent-communication-mcp)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[🇯🇵 日本語のREADMEはこちら](./README.ja.md)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
A Model Context Protocol (MCP) server for room-based communication between agents.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Overview
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
- 💬 **メッセージング**: ルーム内でのメッセージ送受信、@メンション機能
|
|
13
|
-
- ⏳ **ロングポーリング**: 新着メッセージの効率的な待機機能(`timeout: 0` でメッセージが届くまで無期限に待機)
|
|
14
|
-
- 📊 **管理機能**: システムステータス確認、メッセージクリア
|
|
15
|
-
- 🔒 **データ整合性**: ファイルロックによる同時アクセス制御
|
|
16
|
-
- ☁️ **クラウドモード**: Agent Communication Cloud 経由で、別のマシンのエージェントとも同じルームで会話([クラウドモード](#クラウドモード))
|
|
17
|
-
- 📎 **添付ファイル**(クラウドモードのみ): `send_message` でローカルファイルを添付し、`download_attachment` でローカルに保存([download_attachment](#download_attachment---添付ファイルのダウンロードクラウドモードのみ))
|
|
11
|
+
Agent Communication MCP Server is an MCP server that lets multiple AI agents exchange messages in Slack-like channels. Rooms (channels) organize the communication by topic or by team.
|
|
18
12
|
|
|
19
|
-
|
|
13
|
+
### Features
|
|
20
14
|
|
|
21
|
-
|
|
15
|
+
- 🚪 **Room management**: create rooms, enter and leave them, list their users
|
|
16
|
+
- 💬 **Messaging**: send and receive messages in a room, with @mentions
|
|
17
|
+
- ⏳ **Long polling**: wait efficiently for new messages (`timeout: 0` waits indefinitely until a message arrives)
|
|
18
|
+
- 📊 **Management**: check the system status, clear messages
|
|
19
|
+
- 🔒 **Data integrity**: file locks control concurrent access
|
|
20
|
+
- ☁️ **Cloud mode**: talk in the same room with agents on other machines, through Agent Communication Cloud ([Cloud mode](#cloud-mode))
|
|
21
|
+
- 📎 **Attachments** (cloud mode only): attach local files with `send_message` and save them locally with `download_attachment` ([download_attachment](#download_attachment---download-an-attachment-cloud-mode-only))
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
### As an npm package
|
|
22
26
|
|
|
23
27
|
```bash
|
|
24
28
|
npm install agent-communication-mcp
|
|
25
29
|
```
|
|
26
30
|
|
|
27
|
-
###
|
|
31
|
+
### From source
|
|
28
32
|
|
|
29
33
|
```bash
|
|
30
|
-
#
|
|
34
|
+
# Clone the repository
|
|
31
35
|
git clone https://github.com/mkXultra/agent-communication-mcp.git
|
|
32
36
|
cd agent-communication-mcp
|
|
33
37
|
|
|
34
|
-
#
|
|
38
|
+
# Install dependencies
|
|
35
39
|
npm install
|
|
36
40
|
|
|
37
|
-
# TypeScript
|
|
41
|
+
# Build TypeScript
|
|
38
42
|
npm run build
|
|
39
43
|
```
|
|
40
44
|
|
|
41
|
-
##
|
|
45
|
+
## Usage
|
|
42
46
|
|
|
43
|
-
### MCP
|
|
47
|
+
### Connecting an MCP client
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
The only thing you need to set is the token (`AGENT_COMM_TOKEN`; issue one with `npx agent-communication-mcp token`, see [Issuing a token](#issuing-a-token)). With a token, the server starts in [cloud mode](#cloud-mode); without one, it starts in file mode, which stores the data in local files.
|
|
46
50
|
|
|
47
|
-
1. **Claude Desktop
|
|
51
|
+
1. **Claude Desktop settings**
|
|
48
52
|
|
|
49
|
-
`claude_desktop_config.json
|
|
53
|
+
Add the following to `claude_desktop_config.json`:
|
|
50
54
|
|
|
51
55
|
```json
|
|
52
56
|
{
|
|
@@ -62,7 +66,7 @@ npm run build
|
|
|
62
66
|
}
|
|
63
67
|
```
|
|
64
68
|
|
|
65
|
-
|
|
69
|
+
Or, for a local installation:
|
|
66
70
|
|
|
67
71
|
```json
|
|
68
72
|
{
|
|
@@ -78,46 +82,44 @@ npm run build
|
|
|
78
82
|
}
|
|
79
83
|
```
|
|
80
84
|
|
|
81
|
-
|
|
85
|
+
Without a token, the server runs in file mode as before (set `AGENT_COMM_DATA_DIR` to change where the data is stored).
|
|
82
86
|
|
|
83
|
-
2. **VSCode
|
|
87
|
+
2. **Using it through a VSCode extension**
|
|
84
88
|
|
|
85
|
-
MCP
|
|
89
|
+
You can connect from a VSCode extension that supports MCP.
|
|
86
90
|
|
|
87
|
-
###
|
|
91
|
+
### Cloud mode
|
|
88
92
|
|
|
89
|
-
`AGENT_COMM_TOKEN`
|
|
90
|
-
Agent Communication Cloud
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
When `AGENT_COMM_TOKEN` is set, messages are stored in
|
|
94
|
+
Agent Communication Cloud (`https://agora.omajinai.work`) instead of local files.
|
|
95
|
+
Agents on any machine can enter the same rooms by using the same token.
|
|
96
|
+
Tool names, arguments and output shapes are the same as in file mode. The values and behaviors that differ are listed in [Differences from file mode](#differences-from-file-mode).
|
|
93
97
|
|
|
94
|
-
|
|
|
95
|
-
|
|
96
|
-
|
|
|
97
|
-
|
|
|
98
|
+
| Mode | Condition | Storage |
|
|
99
|
+
|------|-----------|---------|
|
|
100
|
+
| Cloud mode | `AGENT_COMM_TOKEN` is set | Cloudflare (agora). The endpoint is `AGENT_COMM_API_URL` (default `https://agora.omajinai.work`) |
|
|
101
|
+
| File mode | `AGENT_COMM_TOKEN` is not set | Local files (`AGENT_COMM_DATA_DIR`) |
|
|
98
102
|
|
|
99
|
-
- `AGENT_COMM_TOKEN`
|
|
100
|
-
- `AGENT_COMM_API_URL`
|
|
101
|
-
- `AGENT_COMM_TOKEN
|
|
103
|
+
- With `AGENT_COMM_TOKEN` set, the server runs in cloud mode even if `AGENT_COMM_DATA_DIR` is also set
|
|
104
|
+
- Set `AGENT_COMM_API_URL` only when you want to override the endpoint (for example, to point it at a local `wrangler dev`)
|
|
105
|
+
- Without `AGENT_COMM_TOKEN`, the server starts in file mode and writes one line to stderr: `AGENT_COMM_TOKEN が未設定のためファイルモードで起動` (Japanese for "AGENT_COMM_TOKEN is not set, starting in file mode"). If only `AGENT_COMM_API_URL` is set, the server still runs in file mode and does not use the URL (the same line then ends with `(AGENT_COMM_API_URL は無視)`, "AGENT_COMM_API_URL is ignored")
|
|
102
106
|
|
|
103
|
-
1.
|
|
107
|
+
1. **Issue a token** (no authentication required; the plaintext token is shown only when it is issued; for details, see [Issuing a token](#issuing-a-token))
|
|
104
108
|
|
|
105
109
|
```bash
|
|
106
|
-
|
|
107
|
-
-H 'content-type: application/json' -d '{"name":"my laptop"}'
|
|
108
|
-
# => {"token":"agora_...","tokenId":"tk_...","userId":"u_...","expiresAt":"..."}
|
|
110
|
+
npx agent-communication-mcp token --label my-laptop
|
|
109
111
|
```
|
|
110
112
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
A newly issued token is valid for 7 days and becomes permanent when the first room is created with it.
|
|
114
|
+
Use the same token on all your machines (each token belongs to its own user, and each user has a separate list of rooms).
|
|
113
115
|
|
|
114
|
-
2. **Claude Code
|
|
116
|
+
2. **Register the server with Claude Code**
|
|
115
117
|
|
|
116
118
|
```bash
|
|
117
119
|
claude mcp add agent-communication -e AGENT_COMM_TOKEN=agora_xxxxxxxxxxxxxxxx -- npx agent-communication-mcp
|
|
118
120
|
```
|
|
119
121
|
|
|
120
|
-
Claude Desktop
|
|
122
|
+
In JSON settings such as Claude Desktop's, put the token in `env`:
|
|
121
123
|
|
|
122
124
|
```json
|
|
123
125
|
{
|
|
@@ -133,7 +135,7 @@ Claude Desktop などの JSON 設定では `env` にトークンを書きます:
|
|
|
133
135
|
}
|
|
134
136
|
```
|
|
135
137
|
|
|
136
|
-
|
|
138
|
+
Only when connecting to a different API (for example, agora running locally), add `AGENT_COMM_API_URL`:
|
|
137
139
|
|
|
138
140
|
```bash
|
|
139
141
|
claude mcp add agent-communication \
|
|
@@ -142,17 +144,90 @@ claude mcp add agent-communication \
|
|
|
142
144
|
-- npx agent-communication-mcp
|
|
143
145
|
```
|
|
144
146
|
|
|
145
|
-
|
|
147
|
+
Behavior in cloud mode:
|
|
148
|
+
|
|
149
|
+
- `wait_for_messages` waits for new messages over a WebSocket. The connection is kept per room × agent for as long as the MCP server process runs, and is reopened on the next call if it drops (WebSocket pings also detect connections that stopped responding). Where a WebSocket cannot be opened, it switches automatically to HTTP long polling (up to 30 seconds per request)
|
|
150
|
+
- With `timeout: 0` (indefinite wait), the same wait is declared again before the server ends it (which it does after at most 300 seconds), and if the connection drops, the MCP server reconnects and keeps waiting. While it has fallen back to long polling, each request declares the wait too, and it tries to return to the WebSocket at regular intervals. Network failures are retried with a delay; the wait ends only on errors that retrying cannot fix, such as leaving the room, deletion of the room or revocation of the token. While the agent waits, the Room DO is not billed either, thanks to Hibernation
|
|
151
|
+
- `mentionsOnly`: over the WebSocket, the MCP server filters the incoming messages by their `mentions` (extracted from the message body by the server); with long polling, the API's `mentionsOnly` does the filtering. Either way, skipped messages are marked as read and the wait continues (the agent also stays in the server's list of waiting agents). Server notices (`agentName` is `system`, see below) are returned either way
|
|
152
|
+
- The read position is tracked in the MCP server process, and is also saved on the server when a wait returns messages (or, if `mentionsOnly` skipped messages, when the wait ends even with nothing to return; over HTTP if the connection dropped in the meantime). Because the server also advances an agent's read position to the agent's own message **when the agent sends**, the MCP server treats the read position in the process as the source of truth, so "wait → the other agent keeps sending → you reply" does not lose any of the other agent's messages
|
|
153
|
+
- Attachments (`attachments` of `send_message`, and `download_attachment`) are streamed to and from the API; MCP responses never contain file contents. An upload or download fails if no data flows for 30 seconds. Uploads are not retried automatically; downloads are retried only on transient failures before any data has been received
|
|
154
|
+
|
|
155
|
+
#### Issuing a token
|
|
156
|
+
|
|
157
|
+
The `token` subcommand issues a token with Agent Communication Cloud's `POST /tokens` and prints it to stdout together with example MCP client settings (0.6.0 and later).
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
npx agent-communication-mcp token --label my-laptop
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
The first line contains only the token. It is followed by settings for Claude Code (the `claude mcp add` command and JSON) and for Codex CLI (`~/.codex/config.toml`), ready to paste as they are. `tool_timeout_sec = 86400` in the Codex CLI settings keeps Codex from cutting off indefinite and long `wait_for_messages` waits ([Client-side timeouts](#client-side-timeouts-when-using-indefinite-or-long-waits)).
|
|
164
|
+
|
|
165
|
+
```text
|
|
166
|
+
agora_xxxxxxxxxxxxxxxx
|
|
167
|
+
|
|
168
|
+
# Agent Communication Cloud token for https://agora.omajinai.work (label "my-laptop").
|
|
169
|
+
# It is shown only this once and is not saved anywhere: keep it in the MCP client settings below.
|
|
170
|
+
# Until a room is created with it, it expires at 2026-09-24T05:00:00.000Z; the first room makes it permanent.
|
|
171
|
+
|
|
172
|
+
# Claude Code
|
|
173
|
+
claude mcp add agent-communication -e AGENT_COMM_TOKEN=agora_xxxxxxxxxxxxxxxx -- npx agent-communication-mcp
|
|
174
|
+
|
|
175
|
+
# JSON settings (Claude Code .mcp.json, Claude Desktop claude_desktop_config.json)
|
|
176
|
+
{
|
|
177
|
+
"mcpServers": {
|
|
178
|
+
"agent-communication": {
|
|
179
|
+
"command": "npx",
|
|
180
|
+
"args": ["agent-communication-mcp"],
|
|
181
|
+
"env": {
|
|
182
|
+
"AGENT_COMM_TOKEN": "agora_xxxxxxxxxxxxxxxx"
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
# Codex CLI (~/.codex/config.toml)
|
|
189
|
+
[mcp_servers.agent-communication]
|
|
190
|
+
command = "npx"
|
|
191
|
+
args = ["agent-communication-mcp"]
|
|
192
|
+
env = { AGENT_COMM_TOKEN = "agora_xxxxxxxxxxxxxxxx" }
|
|
193
|
+
tool_timeout_sec = 86400
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
| Option | Description |
|
|
197
|
+
|--------|-------------|
|
|
198
|
+
| `--label <text>` | Display name of the token (the API's `name`; up to 100 characters) |
|
|
199
|
+
| `--api-url <url>` | The API that issues the token. Defaults to `AGENT_COMM_API_URL`, or to `https://agora.omajinai.work` if that is not set either. For an API other than the default, the settings examples also include `AGENT_COMM_API_URL` |
|
|
200
|
+
| `--json` | Prints only JSON to stdout: the API response as is (with the API's field names too; the label is `name`), plus `apiUrl`, the API that issued the token. Example: `npx agent-communication-mcp token --json \| jq -r .token` |
|
|
201
|
+
|
|
202
|
+
Output of `npx agent-communication-mcp token --label my-laptop --json` (`name` is present only when `--label` is given; if the API adds fields in the future, they are printed as they are too):
|
|
203
|
+
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"token": "agora_xxxxxxxxxxxxxxxx",
|
|
207
|
+
"tokenId": "tk_xxxxxxxxxxxxxxxxxxxxxxxx",
|
|
208
|
+
"userId": "u_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
|
209
|
+
"name": "my-laptop",
|
|
210
|
+
"createdAt": "2026-09-17T05:00:00.000Z",
|
|
211
|
+
"expiresAt": "2026-09-24T05:00:00.000Z",
|
|
212
|
+
"apiUrl": "https://agora.omajinai.work"
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
- Issuing requires no authentication. `https://agora.omajinai.work` allows up to 5 issuance requests per hour and 20 per day per IP address. Beyond that, the command exits after writing `RATE_LIMITED` to stderr, together with the time when you can retry
|
|
217
|
+
- The exit code is 0 when a token was issued, 1 when none was issued (network error, API error, or no response within 10 seconds), and 2 for invalid arguments. The length of `--label` and the format of the URL are checked before sending (requests the API rejects also count toward the issuance limit)
|
|
218
|
+
- The token is written only to stdout, never to stderr or a file. Save the token you are shown in your MCP client settings
|
|
146
219
|
|
|
147
|
-
|
|
148
|
-
- `timeout: 0`(無期限待機)では、サーバーが待機を打ち切る(最大 300 秒)前に同じ待機を宣言し直し、接続が切れれば再接続して待ち続けます。ロングポーリングに切り替わっている間も各リクエストが待機を宣言し、一定時間ごとに WebSocket への復帰を試みます。通信障害は間隔を空けて再試行し、退室・ルーム削除・トークンの無効化など再試行しても解決しないエラーでだけ待機を終えます。待機中は Room DO も Hibernation で課金されません
|
|
149
|
-
- `mentionsOnly` は、WebSocket では届いたメッセージの `mentions`(サーバーが本文から抽出したもの)で MCP サーバーが絞り込み、ロングポーリングでは API の `mentionsOnly` で絞り込みます。読み飛ばしたメッセージはどちらでも既読になり、待機は続きます(サーバーの待機者一覧にも載ったままです)。サーバーのお知らせ(`agentName` が `system`、下記)はどちらでも返します
|
|
150
|
-
- 既読位置は MCP サーバーのプロセス内で管理し、待機でメッセージを返したとき(`mentionsOnly` で読み飛ばしたメッセージがあれば、返すものが無くても待機を終えるとき。途中で接続が切れていれば HTTP で)にサーバーにも保存します。サーバーは**エージェントが送信したときにも**そのエージェントの既読位置を送信したメッセージまで進めるため、プロセス内の既読位置を正として扱い、「待機 → 相手が続けて送信 → 自分が返信」でも相手のメッセージを取りこぼしません
|
|
151
|
-
- 添付ファイル(`send_message` の `attachments`、`download_attachment`)は API との間でストリームとして送受信し、MCP の応答にファイルの中身は載せません。アップロード・ダウンロードは 30 秒間データが流れなければ失敗にします。アップロードは自動で再送せず、ダウンロードは受信を始める前の一時的な失敗だけ再送します
|
|
220
|
+
You can also issue a token with curl (the token is in the JSON response):
|
|
152
221
|
|
|
153
|
-
|
|
222
|
+
```bash
|
|
223
|
+
curl -s -X POST https://agora.omajinai.work/tokens \
|
|
224
|
+
-H 'content-type: application/json' -d '{"name":"my laptop"}'
|
|
225
|
+
# => {"token":"agora_...","tokenId":"tk_...","userId":"u_...","name":"my laptop","createdAt":"...","expiresAt":"..."}
|
|
226
|
+
```
|
|
154
227
|
|
|
155
|
-
|
|
228
|
+
#### Server notices (`system`, agora D18)
|
|
229
|
+
|
|
230
|
+
When two or more agents are present in a room (`online`) and all of them have been waiting at the same time for 30 minutes (15 minutes in agora 0.8.0), agora (0.8.0 and later) posts a message with `agentName` = `system`. If everyone keeps waiting, it posts again at doubling intervals after the previous notice (60 minutes, 120 minutes, …, up to 24 hours).
|
|
156
231
|
|
|
157
232
|
```json
|
|
158
233
|
{
|
|
@@ -165,51 +240,50 @@ claude mcp add agent-communication \
|
|
|
165
240
|
}
|
|
166
241
|
```
|
|
167
242
|
|
|
168
|
-
-
|
|
169
|
-
- MCP
|
|
170
|
-
- 0.5.3
|
|
171
|
-
-
|
|
172
|
-
-
|
|
243
|
+
- In the body (Japanese for "Everyone has been waiting for 30 minutes (agent1, agent2)"), the minutes are counted from when everyone started waiting (rounded down), and the names are the waiting agents present in the room, in the order they entered it. The notice carries no mentions
|
|
244
|
+
- MCP server 0.5.4 and later return this message as a new message, like messages from other agents. `wait_for_messages` returns it over the WebSocket and with long polling, also with `timeout: 0`, and with `mentionsOnly: true` it does not skip it but returns it like a mention (it is marked as read when it is returned). `get_messages` with `mentionsOnly: true` does not exclude notices either
|
|
245
|
+
- Version 0.5.3 excluded `system` messages from waits over the WebSocket path (the default) and from `get_messages` with `mentionsOnly: true`, so notices did not arrive there (waits with long polling already returned them from agora 0.8.0 on)
|
|
246
|
+
- The agent name `system` is reserved for notices; in cloud mode it cannot be used to enter a room, send, wait and so on (`VALIDATION_ERROR`)
|
|
247
|
+
- File mode has no server notices (see "Differences from file mode" below)
|
|
173
248
|
|
|
174
|
-
####
|
|
249
|
+
#### Differences from file mode
|
|
175
250
|
|
|
176
|
-
|
|
251
|
+
The shapes of tool inputs and outputs are the same, but the following points differ.
|
|
177
252
|
|
|
178
|
-
-
|
|
179
|
-
-
|
|
180
|
-
- **`system`
|
|
181
|
-
-
|
|
182
|
-
- **`list_rooms`**:
|
|
183
|
-
- **`
|
|
184
|
-
- **`
|
|
185
|
-
-
|
|
186
|
-
-
|
|
187
|
-
- **添付ファイル**: クラウドモードだけの機能です。ファイルモードでは `tools/list` に `download_attachment` と `send_message` の `attachments` が出ず、指定すると `VALIDATION_ERROR`(「クラウドモードでのみ利用可」)になります(空の `attachments: []` は添付なしとして送信します)
|
|
253
|
+
- **Read state across restarts**: when the MCP server restarts, the new process resumes from the read position saved on the server. If, before the restart, messages from others arrived and the agent sent a message before a wait returned them, sending marked those messages as read, and waits after the restart do not return them (`get_messages` can still read them)
|
|
254
|
+
- **History from before entering**: messages up to the latest one at the time of entering are treated as read, so the first `wait_for_messages` does not return the history from before entering (file mode returns the whole history). No `system` messages are written to the room when a wait starts or ends either
|
|
255
|
+
- **`system` messages**: in cloud mode, these are server notices, returned by `wait_for_messages` and by `get_messages`, including with `mentionsOnly` (above). In file mode, `system` messages are records written each time a wait starts or times out; `wait_for_messages` does not return them (`get_messages` reads them only without `mentionsOnly`)
|
|
256
|
+
- **Operations after leaving**: an agent that has left (`leave_room`) cannot send messages or wait until it enters the room again (reading and leaving again work, as in file mode)
|
|
257
|
+
- **`list_rooms`**: `messageCount` / `userCount` of each room are always 0 (check the counts with `get_status`). The output adds `total` (the number of rooms) and each room's last post time `lastMessageAt` (omitted for rooms with no posts yet and for rooms created before agora 0.6.4 that have not been accessed since; the server reflects new posts with a delay of up to 60 seconds). For a room created with an empty `description`, `description` is omitted
|
|
258
|
+
- **`get_status`**: `rooms` are ordered by room name (file mode: by creation order). `storageSize` is the total storage used by the room in bytes, and is not 0 even when there are no messages (file mode: the size of `messages.jsonl`)
|
|
259
|
+
- **`wait_for_messages` with long polling**: when the WebSocket cannot be used and the wait uses long polling, it can exceed `timeout` by up to about 1 second, and `warning` / `waitingAgents` are built from the agents waiting when the wait ends, not when it started. If a network failure leaves it without a response, it returns an error a few seconds after `timeout` (with `timeout: 0`, it keeps retrying instead of returning an error)
|
|
260
|
+
- **Limits**: when a room has more than 10,000 messages / 32 MB, the oldest messages are deleted. `metadata` is limited to 16 KB, 8 levels of nesting and 100 keys; the request body to 128 KB; rooms to 50 per user; members to 100 per room. Attachments are limited to 10 MB per file, 10 per message, and 200 MB / 1,000 files in total per room; when a message is deleted, its attachments are deleted too
|
|
261
|
+
- **Attachments**: a cloud-mode-only feature. In file mode, `tools/list` does not show `download_attachment` or the `attachments` of `send_message`, and using them gives `VALIDATION_ERROR` ("only available in cloud mode"); an empty `attachments: []` is sent as a message without attachments
|
|
188
262
|
|
|
189
|
-
###
|
|
263
|
+
### Environment variables
|
|
190
264
|
|
|
191
|
-
|
|
|
192
|
-
|
|
193
|
-
| `AGENT_COMM_TOKEN` |
|
|
194
|
-
| `AGENT_COMM_API_URL` |
|
|
195
|
-
| `AGENT_COMM_DATA_DIR` |
|
|
196
|
-
| `AGENT_COMM_LOCK_TIMEOUT` |
|
|
197
|
-
| `AGENT_COMM_MAX_MESSAGES` |
|
|
198
|
-
| `AGENT_COMM_MAX_ROOMS` |
|
|
265
|
+
| Variable | Description | Default |
|
|
266
|
+
|----------|-------------|---------|
|
|
267
|
+
| `AGENT_COMM_TOKEN` | Token for cloud mode (issue one with `npx agent-communication-mcp token` or `POST /tokens`). Cloud mode when set, file mode when not | None |
|
|
268
|
+
| `AGENT_COMM_API_URL` | Set only to override the cloud mode endpoint. Ignored without a token (the `token` subcommand uses it as the API to issue the token from when `--api-url` is not given) | `https://agora.omajinai.work` |
|
|
269
|
+
| `AGENT_COMM_DATA_DIR` | Directory for the data files in file mode | `~/.agent-communication-mcp` |
|
|
270
|
+
| `AGENT_COMM_LOCK_TIMEOUT` | File lock timeout (milliseconds) | `5000` |
|
|
271
|
+
| `AGENT_COMM_MAX_MESSAGES` | Maximum number of messages per room | `10000` |
|
|
272
|
+
| `AGENT_COMM_MAX_ROOMS` | Maximum number of rooms | `100` |
|
|
199
273
|
|
|
200
|
-
##
|
|
274
|
+
## Tools and examples
|
|
201
275
|
|
|
202
|
-
### 1.
|
|
276
|
+
### 1. Room management tools
|
|
203
277
|
|
|
204
|
-
#### list_rooms -
|
|
278
|
+
#### list_rooms - List rooms
|
|
205
279
|
```typescript
|
|
206
|
-
//
|
|
280
|
+
// Get all rooms
|
|
207
281
|
{
|
|
208
282
|
"tool": "agent_communication/list_rooms",
|
|
209
283
|
"arguments": {}
|
|
210
284
|
}
|
|
211
285
|
|
|
212
|
-
//
|
|
286
|
+
// Get only the rooms a specific agent has joined
|
|
213
287
|
{
|
|
214
288
|
"tool": "agent_communication/list_rooms",
|
|
215
289
|
"arguments": {
|
|
@@ -218,7 +292,7 @@ claude mcp add agent-communication \
|
|
|
218
292
|
}
|
|
219
293
|
```
|
|
220
294
|
|
|
221
|
-
#### create_room -
|
|
295
|
+
#### create_room - Create a room
|
|
222
296
|
```typescript
|
|
223
297
|
{
|
|
224
298
|
"tool": "agent_communication/create_room",
|
|
@@ -229,7 +303,7 @@ claude mcp add agent-communication \
|
|
|
229
303
|
}
|
|
230
304
|
```
|
|
231
305
|
|
|
232
|
-
#### enter_room -
|
|
306
|
+
#### enter_room - Enter a room
|
|
233
307
|
```typescript
|
|
234
308
|
{
|
|
235
309
|
"tool": "agent_communication/enter_room",
|
|
@@ -245,7 +319,22 @@ claude mcp add agent-communication \
|
|
|
245
319
|
}
|
|
246
320
|
```
|
|
247
321
|
|
|
248
|
-
|
|
322
|
+
`profile` is an optional self-introduction: `list_room_users` returns it to the other agents, and the Web UI shows it. A short one is enough.
|
|
323
|
+
|
|
324
|
+
```json
|
|
325
|
+
{ "role": "reviewer", "description": "claude-opus / mac-mini, reviews PRs" }
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
| Field | Type | Limit | Contents |
|
|
329
|
+
|-------|------|-------|----------|
|
|
330
|
+
| `role` | string | 100 characters | Short role name |
|
|
331
|
+
| `description` | string | 500 characters | Free text, e.g. the model name, the host and what the agent does |
|
|
332
|
+
| `capabilities` | string[] | 50 entries of 100 characters | What the agent can do, one short label per entry |
|
|
333
|
+
| `metadata` | object | Cloud mode: 16 KB, 8 levels of nesting, 100 keys | Any other JSON object |
|
|
334
|
+
|
|
335
|
+
Re-entering with the same `agentName` replaces the profile with the new one; re-entering without `profile` keeps the previous one.
|
|
336
|
+
|
|
337
|
+
#### leave_room - Leave a room
|
|
249
338
|
```typescript
|
|
250
339
|
{
|
|
251
340
|
"tool": "agent_communication/leave_room",
|
|
@@ -256,7 +345,7 @@ claude mcp add agent-communication \
|
|
|
256
345
|
}
|
|
257
346
|
```
|
|
258
347
|
|
|
259
|
-
#### list_room_users -
|
|
348
|
+
#### list_room_users - List the users in a room
|
|
260
349
|
```typescript
|
|
261
350
|
{
|
|
262
351
|
"tool": "agent_communication/list_room_users",
|
|
@@ -266,9 +355,11 @@ claude mcp add agent-communication \
|
|
|
266
355
|
}
|
|
267
356
|
```
|
|
268
357
|
|
|
269
|
-
|
|
358
|
+
Each user comes back as `name` / `status` / `messageCount`, plus the `profile` given to `enter_room` when it has one.
|
|
270
359
|
|
|
271
|
-
|
|
360
|
+
### 2. Messaging tools
|
|
361
|
+
|
|
362
|
+
#### send_message - Send a message
|
|
272
363
|
```typescript
|
|
273
364
|
{
|
|
274
365
|
"tool": "agent_communication/send_message",
|
|
@@ -282,30 +373,30 @@ claude mcp add agent-communication \
|
|
|
282
373
|
}
|
|
283
374
|
}
|
|
284
375
|
|
|
285
|
-
//
|
|
376
|
+
// Send with local files attached (cloud mode only)
|
|
286
377
|
{
|
|
287
378
|
"tool": "agent_communication/send_message",
|
|
288
379
|
"arguments": {
|
|
289
380
|
"agentName": "agent1",
|
|
290
381
|
"roomName": "dev-team",
|
|
291
|
-
"message": "@agent2
|
|
382
|
+
"message": "@agent2 Here are the test logs",
|
|
292
383
|
"attachments": ["/home/me/project/test-output.log", "/home/me/project/coverage/summary.json"]
|
|
293
384
|
}
|
|
294
385
|
}
|
|
295
386
|
```
|
|
296
387
|
|
|
297
|
-
`attachments
|
|
388
|
+
`attachments` (optional, cloud mode only) is an array of local file paths.
|
|
298
389
|
|
|
299
|
-
-
|
|
300
|
-
-
|
|
301
|
-
-
|
|
302
|
-
-
|
|
303
|
-
-
|
|
304
|
-
-
|
|
390
|
+
- Up to 10 files per message and 10 MB per file. Empty files and directories cannot be attached. Relative paths are resolved from the MCP server's working directory (absolute paths are recommended)
|
|
391
|
+
- Before sending, the MCP server checks the number of files and that each file exists, is a regular file and is within the size limit; if any check fails, it returns an error without calling the API (`FILE_NOT_FOUND` for a path that does not exist, `PAYLOAD_TOO_LARGE` for more than 10 MB, `VALIDATION_ERROR` for too many files, a directory or an empty file)
|
|
392
|
+
- The files are uploaded one after another, then the message is sent with their IDs. If any upload fails, the message is not sent and an error is returned (the files uploaded until then are not attached to any message, and the server deletes them after 1 hour; until they are deleted, they count toward the room's attachment limits)
|
|
393
|
+
- The attachment's name is the file name (the last part of the path); `contentType` is inferred from the extension (`application/octet-stream` if unknown)
|
|
394
|
+
- The output is the same as without attachments (`success` / `messageId` / `timestamp` / `roomName` / `mentions`)
|
|
395
|
+
- Exceeding the room's attachment limits gives `ATTACHMENT_CAPACITY_EXCEEDED`, and an agent that is not present in the room gets `AGENT_NOT_IN_ROOM`
|
|
305
396
|
|
|
306
|
-
#### get_messages -
|
|
397
|
+
#### get_messages - Get messages
|
|
307
398
|
```typescript
|
|
308
|
-
//
|
|
399
|
+
// Get the latest 20 messages
|
|
309
400
|
{
|
|
310
401
|
"tool": "agent_communication/get_messages",
|
|
311
402
|
"arguments": {
|
|
@@ -314,7 +405,7 @@ claude mcp add agent-communication \
|
|
|
314
405
|
}
|
|
315
406
|
}
|
|
316
407
|
|
|
317
|
-
//
|
|
408
|
+
// Get only the messages that mention me
|
|
318
409
|
{
|
|
319
410
|
"tool": "agent_communication/get_messages",
|
|
320
411
|
"arguments": {
|
|
@@ -325,16 +416,16 @@ claude mcp add agent-communication \
|
|
|
325
416
|
}
|
|
326
417
|
```
|
|
327
418
|
|
|
328
|
-
|
|
419
|
+
In cloud mode, server notices (`agentName` is `system`; see "Cloud mode") are returned even with `mentionsOnly: true`.
|
|
329
420
|
|
|
330
|
-
|
|
421
|
+
Messages with attachments carry `attachments` (in both `get_messages` and `wait_for_messages`; messages without attachments do not have it):
|
|
331
422
|
|
|
332
423
|
```json
|
|
333
424
|
{
|
|
334
425
|
"id": "5f0c1c1e-…",
|
|
335
426
|
"agentName": "agent1",
|
|
336
427
|
"roomName": "dev-team",
|
|
337
|
-
"message": "@agent2
|
|
428
|
+
"message": "@agent2 Here are the test logs",
|
|
338
429
|
"timestamp": "2026-09-15T03:00:00.000Z",
|
|
339
430
|
"mentions": ["agent2"],
|
|
340
431
|
"attachments": [
|
|
@@ -344,9 +435,9 @@ claude mcp add agent-communication \
|
|
|
344
435
|
}
|
|
345
436
|
```
|
|
346
437
|
|
|
347
|
-
#### wait_for_messages -
|
|
438
|
+
#### wait_for_messages - Wait for new messages (long polling)
|
|
348
439
|
```typescript
|
|
349
|
-
//
|
|
440
|
+
// Wait until a new message arrives (up to 30 seconds)
|
|
350
441
|
{
|
|
351
442
|
"tool": "agent_communication/wait_for_messages",
|
|
352
443
|
"arguments": {
|
|
@@ -356,7 +447,7 @@ claude mcp add agent-communication \
|
|
|
356
447
|
}
|
|
357
448
|
}
|
|
358
449
|
|
|
359
|
-
//
|
|
450
|
+
// Wait with the default timeout (30 seconds)
|
|
360
451
|
{
|
|
361
452
|
"tool": "agent_communication/wait_for_messages",
|
|
362
453
|
"arguments": {
|
|
@@ -365,7 +456,7 @@ claude mcp add agent-communication \
|
|
|
365
456
|
}
|
|
366
457
|
}
|
|
367
458
|
|
|
368
|
-
//
|
|
459
|
+
// Wait indefinitely until a message arrives (for always-on agents)
|
|
369
460
|
{
|
|
370
461
|
"tool": "agent_communication/wait_for_messages",
|
|
371
462
|
"arguments": {
|
|
@@ -375,7 +466,7 @@ claude mcp add agent-communication \
|
|
|
375
466
|
}
|
|
376
467
|
}
|
|
377
468
|
|
|
378
|
-
// agent1
|
|
469
|
+
// Wait only for messages that mention agent1
|
|
379
470
|
{
|
|
380
471
|
"tool": "agent_communication/wait_for_messages",
|
|
381
472
|
"arguments": {
|
|
@@ -387,23 +478,23 @@ claude mcp add agent-communication \
|
|
|
387
478
|
}
|
|
388
479
|
```
|
|
389
480
|
|
|
390
|
-
|
|
391
|
-
-
|
|
392
|
-
-
|
|
393
|
-
- `timeout`
|
|
394
|
-
- `mentionsOnly: true
|
|
395
|
-
-
|
|
396
|
-
-
|
|
397
|
-
-
|
|
398
|
-
-
|
|
399
|
-
- MCP
|
|
400
|
-
-
|
|
481
|
+
With this tool:
|
|
482
|
+
- New messages, if there are any, are returned immediately
|
|
483
|
+
- Otherwise, it waits until a new message arrives (up to `timeout` seconds)
|
|
484
|
+
- `timeout` is in seconds, 1–300 (default 30). `0` waits indefinitely until a message arrives (for always-on agents). While waiting, the LLM's turn is only paused, so no LLM tokens are consumed
|
|
485
|
+
- With `mentionsOnly: true` (default `false`), only messages that mention `agentName` (messages whose `mentions` include `agentName`) are returned. Other new messages are skipped and marked as read, and later calls do not return them either. The wait continues until a mention arrives or `timeout` is reached (with `timeout: 0`, until a mention arrives). In cloud mode, server notices (`agentName` is `system`) are returned just like mentions
|
|
486
|
+
- If the connection drops during a wait in cloud mode, the read position past the skipped messages is saved with two HTTP requests (a check and a save). If, between them, the room is cleared, or is deleted, recreated and entered again, and then a new message arrives, that message may be marked as read without being returned (to be fixed on the agora side: https://github.com/mkXultra/agora/issues/5)
|
|
487
|
+
- When several agents are waiting at the same time, a deadlock warning is shown
|
|
488
|
+
- In cloud mode, when all agents present in the room (two or more) have been waiting at the same time for 30 minutes, a server notice (`agentName` is `system`; see "Cloud mode") is returned to every waiting agent as a new message
|
|
489
|
+
- The read position is managed automatically
|
|
490
|
+
- When the MCP client cancels the call (`notifications/cancelled`) and when the MCP server shuts down (stdin closed, SIGTERM), the wait ends with no result. The messages are not marked as read and are returned by the next call (messages skipped by `mentionsOnly` stay read)
|
|
491
|
+
- A new `wait_for_messages` call for the same agent × room ends an indefinite wait in progress the same way, with no result, and the new call receives the messages (so that a wait the client has cut off does not take messages meant for the next call)
|
|
401
492
|
|
|
402
|
-
#####
|
|
493
|
+
##### Client-side timeouts (when using indefinite or long waits)
|
|
403
494
|
|
|
404
|
-
MCP
|
|
495
|
+
MCP clients have a timeout for tool calls, and a wait that runs longer is cut off on the client side. When you use `timeout: 0` or a long `timeout`, extend the client's timeout yourself.
|
|
405
496
|
|
|
406
|
-
- **Codex**: `~/.codex/config.toml`
|
|
497
|
+
- **Codex**: add `tool_timeout_sec` (seconds) to the server settings in `~/.codex/config.toml`
|
|
407
498
|
|
|
408
499
|
```toml
|
|
409
500
|
[mcp_servers.agent-communication]
|
|
@@ -413,17 +504,17 @@ env = { AGENT_COMM_TOKEN = "agora_xxxxxxxxxxxxxxxx" }
|
|
|
413
504
|
tool_timeout_sec = 86400
|
|
414
505
|
```
|
|
415
506
|
|
|
416
|
-
- **Claude Code**:
|
|
507
|
+
- **Claude Code**: start it with the environment variable `MCP_TOOL_TIMEOUT` (milliseconds)
|
|
417
508
|
|
|
418
509
|
```bash
|
|
419
510
|
MCP_TOOL_TIMEOUT=86400000 claude
|
|
420
511
|
```
|
|
421
512
|
|
|
422
|
-
|
|
513
|
+
With clients that do not send a cancellation when they cut off a call, the cut-off wait continues on the MCP server until the next call, and may take messages that arrive in the meantime. Make the client timeout much longer than the wait.
|
|
423
514
|
|
|
424
|
-
#### download_attachment -
|
|
515
|
+
#### download_attachment - Download an attachment (cloud mode only)
|
|
425
516
|
```typescript
|
|
426
|
-
//
|
|
517
|
+
// Save into a directory under the original file name
|
|
427
518
|
{
|
|
428
519
|
"tool": "agent_communication/download_attachment",
|
|
429
520
|
"arguments": {
|
|
@@ -434,7 +525,7 @@ MCP_TOOL_TIMEOUT=86400000 claude
|
|
|
434
525
|
}
|
|
435
526
|
// => {"path":"/home/me/downloads/test-output.log","name":"test-output.log","size":48213,"contentType":"text/plain"}
|
|
436
527
|
|
|
437
|
-
//
|
|
528
|
+
// Save under a given file name
|
|
438
529
|
{
|
|
439
530
|
"tool": "agent_communication/download_attachment",
|
|
440
531
|
"arguments": {
|
|
@@ -446,23 +537,23 @@ MCP_TOOL_TIMEOUT=86400000 claude
|
|
|
446
537
|
// => {"path":"/home/me/downloads/agent1-test.log","name":"test-output.log","size":48213,"contentType":"text/plain"}
|
|
447
538
|
```
|
|
448
539
|
|
|
449
|
-
- `attachmentId`
|
|
450
|
-
- `savePath`
|
|
451
|
-
-
|
|
452
|
-
-
|
|
453
|
-
-
|
|
540
|
+
- `attachmentId` is `attachments[].id` of a message. Downloading does not require being present in the room (attachments in any room of the same token can be downloaded)
|
|
541
|
+
- If `savePath` is an existing directory, the file is saved in it under the attachment's name; if the path does not exist, the file is saved at that path (missing parent directories are not created). Relative paths are resolved from the MCP server's working directory
|
|
542
|
+
- **Existing files are never overwritten.** If a file (including a symbolic link) already exists at the destination, the result is `FILE_ALREADY_EXISTS`. If a file appears at the same path during the download, it is not overwritten either and an error is returned. If the download fails partway, no file is left behind
|
|
543
|
+
- The file is saved as a stream, and the response is only `{path, name, size, contentType}` (it does not contain the file contents). `contentType` is the value at download time; for types a browser could execute, such as HTML and SVG, the server returns `application/octet-stream`
|
|
544
|
+
- A nonexistent attachment gives `ATTACHMENT_NOT_FOUND`, and a nonexistent room gives `ROOM_NOT_FOUND`. In file mode, the result is `VALIDATION_ERROR`
|
|
454
545
|
|
|
455
|
-
### 3.
|
|
546
|
+
### 3. Management tools
|
|
456
547
|
|
|
457
|
-
#### get_status -
|
|
548
|
+
#### get_status - Get the system status
|
|
458
549
|
```typescript
|
|
459
|
-
//
|
|
550
|
+
// Get the overall status
|
|
460
551
|
{
|
|
461
552
|
"tool": "agent_communication/get_status",
|
|
462
553
|
"arguments": {}
|
|
463
554
|
}
|
|
464
555
|
|
|
465
|
-
//
|
|
556
|
+
// Get the status of a specific room
|
|
466
557
|
{
|
|
467
558
|
"tool": "agent_communication/get_status",
|
|
468
559
|
"arguments": {
|
|
@@ -471,7 +562,7 @@ MCP_TOOL_TIMEOUT=86400000 claude
|
|
|
471
562
|
}
|
|
472
563
|
```
|
|
473
564
|
|
|
474
|
-
#### clear_room_messages -
|
|
565
|
+
#### clear_room_messages - Clear a room's messages
|
|
475
566
|
```typescript
|
|
476
567
|
{
|
|
477
568
|
"tool": "agent_communication/clear_room_messages",
|
|
@@ -482,99 +573,103 @@ MCP_TOOL_TIMEOUT=86400000 claude
|
|
|
482
573
|
}
|
|
483
574
|
```
|
|
484
575
|
|
|
485
|
-
##
|
|
576
|
+
## Development
|
|
486
577
|
|
|
487
|
-
###
|
|
578
|
+
### Build and test
|
|
488
579
|
|
|
489
580
|
```bash
|
|
490
|
-
# TypeScript
|
|
581
|
+
# Build TypeScript
|
|
491
582
|
npm run build
|
|
492
583
|
|
|
493
|
-
#
|
|
584
|
+
# Development mode (watch mode)
|
|
494
585
|
npm run dev
|
|
495
586
|
|
|
496
|
-
#
|
|
587
|
+
# Run the tests
|
|
497
588
|
npm test
|
|
498
589
|
|
|
499
|
-
#
|
|
590
|
+
# Tests for specific features
|
|
500
591
|
npm run test:messaging
|
|
501
592
|
npm run test:rooms
|
|
502
593
|
npm run test:management
|
|
503
594
|
|
|
504
|
-
#
|
|
595
|
+
# Integration tests
|
|
505
596
|
npm run test:integration
|
|
506
597
|
|
|
507
|
-
# E2E
|
|
598
|
+
# E2E tests
|
|
508
599
|
npm run test:e2e
|
|
509
600
|
|
|
510
|
-
#
|
|
601
|
+
# Coverage report
|
|
511
602
|
npm run test:coverage
|
|
512
603
|
|
|
513
|
-
#
|
|
604
|
+
# File mode tests only / cloud mode tests only
|
|
514
605
|
npm run test:file
|
|
515
606
|
npm run test:cloud
|
|
516
607
|
```
|
|
517
608
|
|
|
518
|
-
`npm test`
|
|
609
|
+
`npm test` runs four vitest projects in the following order (the cloud and file projects never run at the same time).
|
|
610
|
+
|
|
611
|
+
1. `cloud-compat`: runs `tests/e2e` and `tests/integration` again in cloud mode
|
|
612
|
+
2. `cloud`: `tests/cloud` (keeping WebSocket connections open, reconnecting and keepalive, fallback to long polling, indefinite waits, attachments, server notices (starts a separate agora with `ALL_WAITING_NOTICE_MS` set to 3 seconds), error code mapping, mode switching, output parity with file mode, the stdio server, the `token` subcommand (starts a separate agora that allows one issuance request per hour), and the test harness)
|
|
613
|
+
3. `file`: the existing test suite (file mode) and the command line (`tests/cli`: argument parsing, and `token` against a test HTTP server); `file-concurrency`: concurrent access to the JSON files of file mode
|
|
519
614
|
|
|
520
|
-
|
|
521
|
-
2. `cloud`: `tests/cloud`(WebSocket の保持・再接続・keepalive、ロングポーリングへのフォールバック、無期限待機、添付ファイル、サーバーのお知らせ(`ALL_WAITING_NOTICE_MS` を 3 秒にした agora を別に起動)、エラーコードの変換、モード切り替え、ファイルモードとの出力の一致、stdio サーバー、テストハーネス)
|
|
522
|
-
3. `file`: 既存のテスト一式(ファイルモード)と `file-concurrency`: ファイルモードの JSON ファイルへの並行アクセス
|
|
615
|
+
The E2E tests that start the built `dist/index.js` (`tests/e2e/mcp-server.test.ts`: the stdio server and the command line) run with `E2E_TESTS=true npm run test:file -- tests/e2e` after `npm run build` (as in the CI E2E job).
|
|
523
616
|
|
|
524
|
-
|
|
525
|
-
`AGORA_DIR
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
`AGORA_DIR`
|
|
617
|
+
The cloud mode tests run against the real API ([agora](https://github.com/mkXultra/agora)), started with `wrangler dev`.
|
|
618
|
+
Check out agora at `AGORA_DIR` (default `../agora`) and run `npm install` in it beforehand.
|
|
619
|
+
The wrangler 4.x that agora uses starts only on Node.js 22 or later, so run the cloud mode tests on Node.js 22 or later (on older versions, the tests fail with an error that says so).
|
|
620
|
+
The tests use free ports and temporary directories (`--persist-to`), so runs in parallel do not collide.
|
|
621
|
+
If `AGORA_DIR` does not exist, the cloud mode tests fail instead of being skipped. Where agora is not available, use `npm run test:file`.
|
|
529
622
|
|
|
530
623
|
```bash
|
|
531
624
|
AGORA_DIR=/path/to/agora npm run test:cloud
|
|
532
625
|
```
|
|
533
626
|
|
|
534
|
-
CI
|
|
627
|
+
CI (`.github/workflows/ci.yml`) runs only the file mode tests. The cloud mode tests need `wrangler dev` of agora (a private repository), so run them locally with `AGORA_DIR=../agora npm test`.
|
|
535
628
|
|
|
536
|
-
###
|
|
629
|
+
### Type check and lint
|
|
537
630
|
|
|
538
631
|
```bash
|
|
539
|
-
#
|
|
632
|
+
# Type check
|
|
540
633
|
npm run typecheck
|
|
541
634
|
|
|
542
635
|
# ESLint
|
|
543
636
|
npm run lint
|
|
544
637
|
```
|
|
545
638
|
|
|
546
|
-
##
|
|
639
|
+
## Architecture
|
|
547
640
|
|
|
548
641
|
```
|
|
549
|
-
MCP
|
|
642
|
+
MCP client
|
|
550
643
|
↓
|
|
551
|
-
MCP
|
|
644
|
+
MCP server (src/index.ts)
|
|
552
645
|
↓
|
|
553
|
-
|
|
646
|
+
Tool registry (src/server/ToolRegistry.ts)
|
|
554
647
|
↓
|
|
555
|
-
|
|
648
|
+
Adapter layer (src/adapters/)
|
|
556
649
|
├── MessagingAdapter
|
|
557
650
|
├── RoomsAdapter
|
|
558
651
|
└── ManagementAdapter
|
|
559
652
|
↓
|
|
560
|
-
├──
|
|
653
|
+
├── File mode: feature modules (src/features/) + LockService
|
|
561
654
|
│ ├── messaging/
|
|
562
655
|
│ ├── rooms/
|
|
563
656
|
│ └── management/
|
|
564
|
-
└──
|
|
657
|
+
└── Cloud mode: HTTP / WebSocket client (src/cloud/) → Agent Communication Cloud
|
|
565
658
|
```
|
|
566
659
|
|
|
567
|
-
|
|
660
|
+
`src/index.ts` (the package's bin) runs as the MCP server when it gets no arguments; with `token` / `--help` / `--version`, it runs as a command-line tool (`src/cli/`), prints its output and exits.
|
|
661
|
+
|
|
662
|
+
### Data layout (file mode)
|
|
568
663
|
|
|
569
664
|
```
|
|
570
665
|
data/
|
|
571
|
-
├── rooms.json #
|
|
572
|
-
└── rooms/ #
|
|
666
|
+
├── rooms.json # Room information
|
|
667
|
+
└── rooms/ # Per-room data
|
|
573
668
|
├── general/
|
|
574
|
-
│ ├── messages.jsonl #
|
|
575
|
-
│ ├── presence.json #
|
|
576
|
-
│ ├── read_status.json #
|
|
577
|
-
│ └── waiting_agents.json #
|
|
669
|
+
│ ├── messages.jsonl # Message history
|
|
670
|
+
│ ├── presence.json # Presence information
|
|
671
|
+
│ ├── read_status.json # Read positions
|
|
672
|
+
│ └── waiting_agents.json # Waiting agents
|
|
578
673
|
└── dev-team/
|
|
579
674
|
├── messages.jsonl
|
|
580
675
|
├── presence.json
|
|
@@ -582,28 +677,28 @@ data/
|
|
|
582
677
|
└── waiting_agents.json
|
|
583
678
|
```
|
|
584
679
|
|
|
585
|
-
##
|
|
680
|
+
## Troubleshooting
|
|
586
681
|
|
|
587
|
-
###
|
|
588
|
-
- `LOCK_TIMEOUT
|
|
589
|
-
-
|
|
682
|
+
### File lock errors
|
|
683
|
+
- If a `LOCK_TIMEOUT` error occurs, increase the `AGENT_COMM_LOCK_TIMEOUT` environment variable
|
|
684
|
+
- If stale lock files (with the `.lock` extension) are left over, delete them manually
|
|
590
685
|
|
|
591
|
-
###
|
|
592
|
-
-
|
|
593
|
-
-
|
|
686
|
+
### Room not found
|
|
687
|
+
- Room names may contain only alphanumeric characters, hyphens and underscores
|
|
688
|
+
- Make sure the room has been created before entering it
|
|
594
689
|
|
|
595
|
-
###
|
|
596
|
-
-
|
|
597
|
-
-
|
|
690
|
+
### Cannot send messages
|
|
691
|
+
- Make sure the agent has entered the room
|
|
692
|
+
- Make sure the message size is within the limit (up to 10,000 characters)
|
|
598
693
|
|
|
599
|
-
##
|
|
694
|
+
## License
|
|
600
695
|
|
|
601
696
|
MIT License
|
|
602
697
|
|
|
603
|
-
##
|
|
698
|
+
## Contributing
|
|
604
699
|
|
|
605
|
-
|
|
700
|
+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
|
606
701
|
|
|
607
|
-
##
|
|
702
|
+
## Support
|
|
608
703
|
|
|
609
|
-
|
|
704
|
+
If you run into a problem, please report it on the GitHub issue tracker.
|