@chamade/mcp-server 1.1.8 → 2.0.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/dist/index.d.ts +8 -1
- package/dist/index.js +238 -214
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,14 @@
|
|
|
7
7
|
* and receive live transcripts via resource subscriptions.
|
|
8
8
|
*
|
|
9
9
|
* Two modes:
|
|
10
|
-
* - Standard MCP (default): agent polls
|
|
10
|
+
* - Standard MCP (default): agent polls chamade_call_status for transcripts
|
|
11
11
|
* - Channel mode (--channel): transcripts and events pushed via notifications
|
|
12
|
+
*
|
|
13
|
+
* Tools: 13 total
|
|
14
|
+
* DM: chamade_dm_chat, chamade_dm_typing
|
|
15
|
+
* Call: chamade_call_join, chamade_call_accept, chamade_call_refuse,
|
|
16
|
+
* chamade_call_say, chamade_call_chat, chamade_call_typing,
|
|
17
|
+
* chamade_call_status, chamade_call_leave, chamade_call_list
|
|
18
|
+
* Other: chamade_inbox, chamade_account
|
|
12
19
|
*/
|
|
13
20
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -7,8 +7,15 @@
|
|
|
7
7
|
* and receive live transcripts via resource subscriptions.
|
|
8
8
|
*
|
|
9
9
|
* Two modes:
|
|
10
|
-
* - Standard MCP (default): agent polls
|
|
10
|
+
* - Standard MCP (default): agent polls chamade_call_status for transcripts
|
|
11
11
|
* - Channel mode (--channel): transcripts and events pushed via notifications
|
|
12
|
+
*
|
|
13
|
+
* Tools: 13 total
|
|
14
|
+
* DM: chamade_dm_chat, chamade_dm_typing
|
|
15
|
+
* Call: chamade_call_join, chamade_call_accept, chamade_call_refuse,
|
|
16
|
+
* chamade_call_say, chamade_call_chat, chamade_call_typing,
|
|
17
|
+
* chamade_call_status, chamade_call_leave, chamade_call_list
|
|
18
|
+
* Other: chamade_inbox, chamade_account
|
|
12
19
|
*/
|
|
13
20
|
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
14
21
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
@@ -83,59 +90,60 @@ const CHANNEL_PREAMBLE = [
|
|
|
83
90
|
"## Channel mode — events arrive automatically",
|
|
84
91
|
"",
|
|
85
92
|
"Transcripts, messages, and calls are pushed to you in real-time.",
|
|
86
|
-
"Do NOT poll
|
|
87
|
-
"When you receive transcript lines, respond using
|
|
88
|
-
"When you receive a message, reply using
|
|
89
|
-
"When you receive an incoming call, use
|
|
90
|
-
"You can still call
|
|
93
|
+
"Do NOT poll chamade_call_status in a loop — you will be notified automatically.",
|
|
94
|
+
"When you receive transcript lines, respond using chamade_call_say (TTS) or chamade_call_chat (text).",
|
|
95
|
+
"When you receive a message, reply using chamade_dm_chat.",
|
|
96
|
+
"When you receive an incoming call, use chamade_call_accept to pick up.",
|
|
97
|
+
"You can still call chamade_call_status manually to catch up on missed transcript.",
|
|
91
98
|
"",
|
|
92
99
|
].join("\n");
|
|
93
100
|
const BASE_INSTRUCTIONS = [
|
|
94
101
|
"Chamade is a voice gateway for AI agents. It lets you join voice meetings (Discord, Teams, Meet, Telegram, SIP) and interact via speech and text.",
|
|
95
102
|
"",
|
|
96
103
|
"## Voice call workflow",
|
|
97
|
-
"1. Use
|
|
98
|
-
"2. Poll
|
|
99
|
-
"3. When you see new transcript, respond to the CONTENT using
|
|
104
|
+
"1. Use chamade_call_join to enter a meeting — returns a call_id and capabilities.",
|
|
105
|
+
"2. Poll chamade_call_status in a loop to read new transcript lines (delta pattern — only new lines since last call).",
|
|
106
|
+
"3. When you see new transcript, respond to the CONTENT using chamade_call_say (TTS) or chamade_call_chat (text).",
|
|
100
107
|
"4. Repeat step 2-3. Keep the call active — do NOT leave between exchanges.",
|
|
101
|
-
"5. Use
|
|
108
|
+
"5. Use chamade_call_leave only when explicitly asked or when the meeting ends.",
|
|
102
109
|
"",
|
|
103
110
|
"## SIP phone calls",
|
|
104
111
|
"SIP supports both outbound and inbound calls. Setup depends on the tier:",
|
|
105
|
-
"- Outbound (Pro plan only): call
|
|
106
|
-
"- Inbound (répondeur): user activates a phone number (DID) in the dashboard. Incoming calls appear as 'ringing' in
|
|
112
|
+
"- Outbound (Pro plan only): call chamade_call_join with platform='sip' and meeting_url='sip:+33...@provider'. Uses the user's own SIP trunk (configured in the dashboard).",
|
|
113
|
+
"- Inbound (répondeur): user activates a phone number (DID) in the dashboard. Incoming calls appear as 'ringing' in chamade_call_list.",
|
|
107
114
|
"- Inbound (BYOT): user connects their own SIP trunk + DIDs in the dashboard. Same inbound flow.",
|
|
108
115
|
"",
|
|
109
116
|
"Inbound call workflow:",
|
|
110
|
-
"1. Use
|
|
111
|
-
"2. Use
|
|
112
|
-
"3. Use
|
|
117
|
+
"1. Use chamade_call_list to see ringing calls (poll regularly).",
|
|
118
|
+
"2. Use chamade_call_accept to pick up the call.",
|
|
119
|
+
"3. Use chamade_call_say to speak and chamade_call_status to read transcript (same as outbound).",
|
|
113
120
|
"4. If auto_answer is enabled, calls go straight to 'active' — no need to answer.",
|
|
121
|
+
"5. Use chamade_call_refuse to reject a ringing call.",
|
|
114
122
|
"",
|
|
115
123
|
"## Recovery from disconnection",
|
|
116
124
|
"If the bridge restarts or connection is lost, the call state becomes 'disconnected'.",
|
|
117
|
-
"
|
|
118
|
-
"To recover: call
|
|
125
|
+
"chamade_call_status will show instructions to reconnect.",
|
|
126
|
+
"To recover: call chamade_call_join again with the same platform and meeting_url.",
|
|
119
127
|
"A new call_id is issued. Previous transcript is lost.",
|
|
120
128
|
"",
|
|
121
129
|
"## DM / Messaging workflow",
|
|
122
130
|
"1. Use chamade_inbox to check for incoming DM conversations.",
|
|
123
|
-
"2. Before composing a reply, use
|
|
124
|
-
"3. Use
|
|
125
|
-
"4. When a
|
|
131
|
+
"2. Before composing a reply, use chamade_dm_typing to show the user you are working on it.",
|
|
132
|
+
"3. Use chamade_dm_chat to reply — specify the platform (e.g. 'teams', 'discord').",
|
|
133
|
+
"4. When a call_invite event has a call_id, use chamade_call_say/chamade_call_status on that call.",
|
|
126
134
|
"",
|
|
127
135
|
"## Capabilities",
|
|
128
136
|
"Each call and conversation returns a capabilities array. Meaning:",
|
|
129
137
|
"- listen: receive audio transcripts (STT)",
|
|
130
|
-
"- speak: send audio via TTS (
|
|
138
|
+
"- speak: send audio via TTS (chamade_call_say)",
|
|
131
139
|
"- read: receive text chat messages",
|
|
132
|
-
"- write: send text chat messages (
|
|
133
|
-
"- typing: typing indicator supported
|
|
140
|
+
"- write: send text chat messages (chamade_call_chat)",
|
|
141
|
+
"- typing: typing indicator supported",
|
|
134
142
|
"- files: file sharing supported",
|
|
135
143
|
"",
|
|
136
144
|
"Per-platform defaults:",
|
|
137
145
|
"- discord/teams: listen, speak, read, write, typing, files (full voice + chat)",
|
|
138
|
-
"- meet: listen, read, write (no TTS — use
|
|
146
|
+
"- meet: listen, read, write (no TTS — use chamade_call_chat instead). Note: chat (read/write) only works for calendar-scheduled meetings. Ad-hoc Meet links have no chat API access. IMPORTANT: when the bot joins a Meet call, a participant in the meeting must manually accept it (Google shows a 'Someone wants to join' popup). Tell the user to accept the bot in the Meet UI.",
|
|
139
147
|
"- zoom: listen, speak, read, write, files",
|
|
140
148
|
"- telegram: read, write, typing, files (text DM only, no voice join)",
|
|
141
149
|
"- whatsapp: read, write (text DM only, no voice join, no typing indicator)",
|
|
@@ -143,7 +151,7 @@ const BASE_INSTRUCTIONS = [
|
|
|
143
151
|
"- nctalk: listen, speak, read, write, typing",
|
|
144
152
|
"- slack: read, write, files (text only, no voice — Huddles have no API)",
|
|
145
153
|
"",
|
|
146
|
-
"If 'speak' is not in capabilities, use
|
|
154
|
+
"If 'speak' is not in capabilities, use chamade_call_chat to send text instead of chamade_call_say.",
|
|
147
155
|
"",
|
|
148
156
|
"## Platform requirements",
|
|
149
157
|
"Each platform requires specific setup. Use chamade_account to check what is already configured.",
|
|
@@ -173,8 +181,8 @@ const BASE_INSTRUCTIONS = [
|
|
|
173
181
|
"- \"Voice quota exceeded\" → monthly voice minutes used up (free plan: 10 min/month)",
|
|
174
182
|
"- \"SIP not available on free plan\" → user needs to upgrade to Pro for SIP calls",
|
|
175
183
|
"- \"No SIP trunk configured\" → user needs to connect a SIP trunk in the dashboard for outbound SIP",
|
|
176
|
-
"- \"Direct audio requires a Pro plan\" → direct audio streaming (raw PCM via WebSocket) is Pro only. Free users can still use
|
|
177
|
-
"- \"Slack does not support voice calls\" → use chamade_inbox/
|
|
184
|
+
"- \"Direct audio requires a Pro plan\" → direct audio streaming (raw PCM via WebSocket) is Pro only. Free users can still use chamade_call_say (TTS) within their voice quota",
|
|
185
|
+
"- \"Slack does not support voice calls\" → use chamade_inbox/chamade_dm_chat for Slack messaging instead",
|
|
178
186
|
"",
|
|
179
187
|
"## Account management",
|
|
180
188
|
`Chamade is fully bot-friendly. All account management (API keys, bot tokens, platform connections, SIP, billing) is available via the REST API at the same endpoints the dashboard uses. See ${CHAMADE_URL}/llms.txt for the full machine-readable documentation. This MCP server focuses on runtime operations (calls + messaging); use the REST API directly for account setup and configuration.`,
|
|
@@ -196,15 +204,18 @@ const INSTRUCTIONS = CHANNEL_MODE
|
|
|
196
204
|
// ---------------------------------------------------------------------------
|
|
197
205
|
const server = new McpServer({
|
|
198
206
|
name: "chamade",
|
|
199
|
-
version: "
|
|
207
|
+
version: "2.0.0",
|
|
200
208
|
}, {
|
|
201
209
|
capabilities: CHANNEL_MODE
|
|
202
210
|
? { experimental: { "claude/channel": {} } }
|
|
203
211
|
: undefined,
|
|
204
212
|
instructions: INSTRUCTIONS,
|
|
205
213
|
});
|
|
206
|
-
//
|
|
207
|
-
|
|
214
|
+
// ===========================================================================
|
|
215
|
+
// CALL TOOLS
|
|
216
|
+
// ===========================================================================
|
|
217
|
+
// -- Tool: call_join ----------------------------------------------------------
|
|
218
|
+
server.tool("chamade_call_join", "Join a voice meeting on any platform (Discord, Teams, Meet, Telegram, SIP, WhatsApp). Returns a call_id. After joining, poll chamade_call_status regularly to read new transcript lines. Use chamade_call_say to speak (TTS) and chamade_call_leave to hang up. Keep the call active — do NOT leave between exchanges.", {
|
|
208
219
|
platform: z
|
|
209
220
|
.enum(["discord", "teams", "meet", "telegram", "sip", "nctalk", "zoom", "whatsapp"])
|
|
210
221
|
.describe("Meeting platform"),
|
|
@@ -245,13 +256,13 @@ server.tool("chamade_join", "Join a voice meeting on any platform (Discord, Team
|
|
|
245
256
|
lines.push(`Audio: ${audio.sample_rate}Hz ${audio.format} (${audio.frame_duration_ms}ms frames, ${audio.frame_bytes} bytes/frame)`);
|
|
246
257
|
}
|
|
247
258
|
if (!capabilities.includes("speak")) {
|
|
248
|
-
lines.push(`Note: TTS (speak) is not supported on ${platform}. Use
|
|
259
|
+
lines.push(`Note: TTS (speak) is not supported on ${platform}. Use chamade_call_chat to send text instead.`);
|
|
249
260
|
}
|
|
250
261
|
if (CHANNEL_MODE) {
|
|
251
|
-
lines.push(``, `Transcript will be pushed automatically. Use
|
|
262
|
+
lines.push(``, `Transcript will be pushed automatically. Use chamade_call_say to speak, chamade_call_chat to send text, chamade_call_leave to hang up.`);
|
|
252
263
|
}
|
|
253
264
|
else {
|
|
254
|
-
lines.push(`Transcript: chamade://calls/${callId}/transcript`, ``, `Use
|
|
265
|
+
lines.push(`Transcript: chamade://calls/${callId}/transcript`, ``, `Use chamade_call_say to speak, chamade_call_chat to send text, chamade_call_status to check transcript, chamade_call_leave to hang up.`);
|
|
255
266
|
}
|
|
256
267
|
return {
|
|
257
268
|
content: [
|
|
@@ -262,9 +273,59 @@ server.tool("chamade_join", "Join a voice meeting on any platform (Discord, Team
|
|
|
262
273
|
],
|
|
263
274
|
};
|
|
264
275
|
});
|
|
265
|
-
// -- Tool:
|
|
266
|
-
server.tool("
|
|
267
|
-
call_id: z.string().describe("Call ID
|
|
276
|
+
// -- Tool: call_accept --------------------------------------------------------
|
|
277
|
+
server.tool("chamade_call_accept", "Answer a ringing inbound call. Use this when chamade_call_list or a call_invite event shows a call in 'ringing' state (incoming phone call). The call transitions to 'active' and you can start speaking.", {
|
|
278
|
+
call_id: z.string().describe("Call ID of the ringing call"),
|
|
279
|
+
}, async ({ call_id }) => {
|
|
280
|
+
await chamadePost(`/api/call/${call_id}/accept`, {});
|
|
281
|
+
// Fetch call details to get real capabilities and platform
|
|
282
|
+
const data = (await chamadeGet(`/api/call/${call_id}`));
|
|
283
|
+
const platform = data.platform || "sip";
|
|
284
|
+
const capabilities = data.capabilities ?? ["listen", "speak"];
|
|
285
|
+
// Track the call locally
|
|
286
|
+
calls.set(call_id, {
|
|
287
|
+
callId: call_id,
|
|
288
|
+
platform,
|
|
289
|
+
meetingUrl: data.meeting_url || "",
|
|
290
|
+
capabilities,
|
|
291
|
+
lastTranscriptLength: 0,
|
|
292
|
+
});
|
|
293
|
+
// Channel mode: auto-watch for transcript push
|
|
294
|
+
if (CHANNEL_MODE) {
|
|
295
|
+
channelWatchCall(call_id);
|
|
296
|
+
}
|
|
297
|
+
const lines = [
|
|
298
|
+
`Answered call ${call_id}.`,
|
|
299
|
+
`State: active`,
|
|
300
|
+
`Capabilities: ${capabilities.join(", ")}`,
|
|
301
|
+
``,
|
|
302
|
+
`Use chamade_call_say to speak, chamade_call_status to check transcript, chamade_call_leave to hang up.`,
|
|
303
|
+
];
|
|
304
|
+
if (!capabilities.includes("speak")) {
|
|
305
|
+
lines.push(`Note: TTS (speak) is not supported on ${platform}. Use chamade_call_chat to send text instead.`);
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
content: [
|
|
309
|
+
{
|
|
310
|
+
type: "text",
|
|
311
|
+
text: lines.join("\n"),
|
|
312
|
+
},
|
|
313
|
+
],
|
|
314
|
+
};
|
|
315
|
+
});
|
|
316
|
+
// -- Tool: call_refuse --------------------------------------------------------
|
|
317
|
+
server.tool("chamade_call_refuse", "Refuse (reject) a ringing inbound call. The call is ended and the caller hears a disconnect.", {
|
|
318
|
+
call_id: z.string().describe("Call ID of the ringing call"),
|
|
319
|
+
}, async ({ call_id }) => {
|
|
320
|
+
await chamadePost(`/api/call/${call_id}/refuse`, {});
|
|
321
|
+
calls.delete(call_id);
|
|
322
|
+
return {
|
|
323
|
+
content: [{ type: "text", text: `Refused call ${call_id}.` }],
|
|
324
|
+
};
|
|
325
|
+
});
|
|
326
|
+
// -- Tool: call_say -----------------------------------------------------------
|
|
327
|
+
server.tool("chamade_call_say", "Speak text aloud in the meeting via TTS. Write naturally and concisely — avoid markdown, code blocks, or long lists as the text is converted to speech. Respond to the CONTENT of what people say, do not echo or repeat their words. Use punctuation to shape delivery: '...' for hesitation, '!' for energy, '—' for a pause. Use CAPS sparingly for emphasis.", {
|
|
328
|
+
call_id: z.string().describe("Call ID from chamade_call_join"),
|
|
268
329
|
text: z.string().describe("Text to speak aloud"),
|
|
269
330
|
}, async ({ call_id, text }) => {
|
|
270
331
|
await chamadePost(`/api/call/${call_id}/say`, { text });
|
|
@@ -272,9 +333,9 @@ server.tool("chamade_say", "Speak text aloud in the meeting via TTS. Write natur
|
|
|
272
333
|
content: [{ type: "text", text: `Speaking: "${text}"` }],
|
|
273
334
|
};
|
|
274
335
|
});
|
|
275
|
-
// -- Tool:
|
|
276
|
-
server.tool("
|
|
277
|
-
call_id: z.string().describe("Call ID from
|
|
336
|
+
// -- Tool: call_chat ----------------------------------------------------------
|
|
337
|
+
server.tool("chamade_call_chat", "Send a text chat message in the meeting. Set sender_name to identify yourself (e.g. your name or 'AI Assistant').", {
|
|
338
|
+
call_id: z.string().describe("Call ID from chamade_call_join"),
|
|
278
339
|
text: z.string().describe("Chat message to send"),
|
|
279
340
|
sender_name: z.string().optional().describe("Display name shown in the chat (e.g. 'Claude', 'AI Assistant')"),
|
|
280
341
|
}, async ({ call_id, text, sender_name }) => {
|
|
@@ -286,9 +347,18 @@ server.tool("chamade_chat", "Send a text chat message in the meeting. Set sender
|
|
|
286
347
|
content: [{ type: "text", text: `Chat sent: "${text}"` }],
|
|
287
348
|
};
|
|
288
349
|
});
|
|
289
|
-
// -- Tool:
|
|
290
|
-
server.tool("
|
|
291
|
-
call_id: z.string().describe("Call ID from
|
|
350
|
+
// -- Tool: call_typing --------------------------------------------------------
|
|
351
|
+
server.tool("chamade_call_typing", "Send a typing indicator in the call's chat. Only works on platforms with 'typing' in capabilities.", {
|
|
352
|
+
call_id: z.string().describe("Call ID from chamade_call_join"),
|
|
353
|
+
}, async ({ call_id }) => {
|
|
354
|
+
await chamadePost(`/api/call/${call_id}/typing`, {});
|
|
355
|
+
return {
|
|
356
|
+
content: [{ type: "text", text: "Typing indicator sent." }],
|
|
357
|
+
};
|
|
358
|
+
});
|
|
359
|
+
// -- Tool: call_status --------------------------------------------------------
|
|
360
|
+
server.tool("chamade_call_status", "Get call status and new transcript lines since last check. Poll this regularly to listen to what people are saying. Returns only new lines since the previous call (delta pattern).", {
|
|
361
|
+
call_id: z.string().describe("Call ID from chamade_call_join"),
|
|
292
362
|
}, async ({ call_id }) => {
|
|
293
363
|
const state = calls.get(call_id);
|
|
294
364
|
const since = state?.lastTranscriptLength ?? 0;
|
|
@@ -321,15 +391,15 @@ server.tool("chamade_status", "Get call status and new transcript lines since la
|
|
|
321
391
|
data.ended_at ? `Ended: ${data.ended_at}` : "",
|
|
322
392
|
];
|
|
323
393
|
if (data.state === "ringing") {
|
|
324
|
-
statusLines.push(``, `Incoming call! Use
|
|
394
|
+
statusLines.push(``, `Incoming call! Use chamade_call_accept to pick up, or chamade_call_refuse to reject.`);
|
|
325
395
|
}
|
|
326
396
|
if (data.state === "disconnected") {
|
|
327
397
|
const meetingUrl = state?.meetingUrl || data.meeting_url || "";
|
|
328
398
|
const platform = state?.platform || data.platform || "";
|
|
329
|
-
statusLines.push(``,
|
|
399
|
+
statusLines.push(``, `Bridge connection lost. The voice session has been interrupted.`, `To reconnect, call chamade_call_join again with platform="${platform}" and meeting_url="${meetingUrl}".`, `A new call_id will be issued. Previous transcript is lost.`);
|
|
330
400
|
}
|
|
331
401
|
if (!capabilities.includes("speak")) {
|
|
332
|
-
statusLines.push(`Note: TTS (speak) is not supported on ${data.platform}. Use
|
|
402
|
+
statusLines.push(`Note: TTS (speak) is not supported on ${data.platform}. Use chamade_call_chat to send text instead.`);
|
|
333
403
|
}
|
|
334
404
|
return {
|
|
335
405
|
content: [
|
|
@@ -342,73 +412,9 @@ server.tool("chamade_status", "Get call status and new transcript lines since la
|
|
|
342
412
|
],
|
|
343
413
|
};
|
|
344
414
|
});
|
|
345
|
-
// -- Tool:
|
|
346
|
-
server.tool("
|
|
347
|
-
call_id: z.string().describe("Call ID
|
|
348
|
-
}, async ({ call_id }) => {
|
|
349
|
-
await chamadePost(`/api/call/${call_id}/answer`, {});
|
|
350
|
-
// Fetch call details to get real capabilities and platform
|
|
351
|
-
const data = (await chamadeGet(`/api/call/${call_id}`));
|
|
352
|
-
const platform = data.platform || "sip";
|
|
353
|
-
const capabilities = data.capabilities ?? ["listen", "speak"];
|
|
354
|
-
// Track the call locally
|
|
355
|
-
calls.set(call_id, {
|
|
356
|
-
callId: call_id,
|
|
357
|
-
platform,
|
|
358
|
-
meetingUrl: data.meeting_url || "",
|
|
359
|
-
capabilities,
|
|
360
|
-
lastTranscriptLength: 0,
|
|
361
|
-
});
|
|
362
|
-
// Channel mode: auto-watch for transcript push
|
|
363
|
-
if (CHANNEL_MODE) {
|
|
364
|
-
channelWatchCall(call_id);
|
|
365
|
-
}
|
|
366
|
-
const lines = [
|
|
367
|
-
`Answered call ${call_id}.`,
|
|
368
|
-
`State: active`,
|
|
369
|
-
`Capabilities: ${capabilities.join(", ")}`,
|
|
370
|
-
``,
|
|
371
|
-
`Use chamade_say to speak, chamade_status to check transcript, chamade_leave to hang up.`,
|
|
372
|
-
];
|
|
373
|
-
if (!capabilities.includes("speak")) {
|
|
374
|
-
lines.push(`Note: TTS (speak) is not supported on ${platform}. Use chamade_chat to send text instead.`);
|
|
375
|
-
}
|
|
376
|
-
return {
|
|
377
|
-
content: [
|
|
378
|
-
{
|
|
379
|
-
type: "text",
|
|
380
|
-
text: lines.join("\n"),
|
|
381
|
-
},
|
|
382
|
-
],
|
|
383
|
-
};
|
|
384
|
-
});
|
|
385
|
-
// -- Tool: typing -----------------------------------------------------------
|
|
386
|
-
server.tool("chamade_typing", "Send a typing indicator. Use this before composing a reply so the user sees you are working on it. Only works on platforms with 'typing' in capabilities (Discord, Teams, Telegram, NC Talk).", {
|
|
387
|
-
call_id: z
|
|
388
|
-
.string()
|
|
389
|
-
.optional()
|
|
390
|
-
.describe("Call ID (for typing in a call's chat)"),
|
|
391
|
-
conversation_id: z
|
|
392
|
-
.string()
|
|
393
|
-
.optional()
|
|
394
|
-
.describe("Conversation ID (for typing in a DM)"),
|
|
395
|
-
}, async ({ call_id, conversation_id }) => {
|
|
396
|
-
if (call_id) {
|
|
397
|
-
await chamadePost(`/api/call/${call_id}/typing`, {});
|
|
398
|
-
}
|
|
399
|
-
else if (conversation_id) {
|
|
400
|
-
await chamadePost("/api/typing", { conversation_id });
|
|
401
|
-
}
|
|
402
|
-
else {
|
|
403
|
-
throw new Error("Either call_id or conversation_id is required");
|
|
404
|
-
}
|
|
405
|
-
return {
|
|
406
|
-
content: [{ type: "text", text: "Typing indicator sent." }],
|
|
407
|
-
};
|
|
408
|
-
});
|
|
409
|
-
// -- Tool: leave ------------------------------------------------------------
|
|
410
|
-
server.tool("chamade_leave", "Leave the meeting and hang up. Only use when explicitly asked to leave or when the meeting is over.", {
|
|
411
|
-
call_id: z.string().describe("Call ID from chamade_join"),
|
|
415
|
+
// -- Tool: call_leave ---------------------------------------------------------
|
|
416
|
+
server.tool("chamade_call_leave", "Leave the meeting and hang up. Only use when explicitly asked to leave or when the meeting is over.", {
|
|
417
|
+
call_id: z.string().describe("Call ID from chamade_call_join"),
|
|
412
418
|
}, async ({ call_id }) => {
|
|
413
419
|
calls.delete(call_id);
|
|
414
420
|
// Channel mode: stop watching
|
|
@@ -420,8 +426,8 @@ server.tool("chamade_leave", "Leave the meeting and hang up. Only use when expli
|
|
|
420
426
|
content: [{ type: "text", text: `Left call ${call_id}.` }],
|
|
421
427
|
};
|
|
422
428
|
});
|
|
423
|
-
// -- Tool:
|
|
424
|
-
server.tool("
|
|
429
|
+
// -- Tool: call_list ----------------------------------------------------------
|
|
430
|
+
server.tool("chamade_call_list", "List all active calls.", {}, async () => {
|
|
425
431
|
const data = (await chamadeGet("/api/calls"));
|
|
426
432
|
if (data.calls.length === 0) {
|
|
427
433
|
return {
|
|
@@ -438,57 +444,63 @@ server.tool("chamade_list_calls", "List all active calls.", {}, async () => {
|
|
|
438
444
|
content: [{ type: "text", text: lines.join("\n") }],
|
|
439
445
|
};
|
|
440
446
|
});
|
|
441
|
-
//
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
const limitStr = concurrent.limit === 0 ? "unlimited" : String(concurrent.limit);
|
|
457
|
-
lines.push(`Active calls: ${concurrent.active} / ${limitStr}`);
|
|
458
|
-
}
|
|
459
|
-
// Platform statuses
|
|
460
|
-
const platforms = data.platforms;
|
|
461
|
-
if (platforms) {
|
|
462
|
-
lines.push("", "Platforms:");
|
|
463
|
-
for (const [name, status] of Object.entries(platforms)) {
|
|
464
|
-
const icon = status.startsWith("ok") ? "+" : status.startsWith("error") ? "!" : "-";
|
|
465
|
-
lines.push(` ${icon} ${name}: ${status}`);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
447
|
+
// ===========================================================================
|
|
448
|
+
// DM TOOLS
|
|
449
|
+
// ===========================================================================
|
|
450
|
+
// -- Tool: dm_chat ------------------------------------------------------------
|
|
451
|
+
server.tool("chamade_dm_chat", "Send a message to the active DM conversation on a platform. The message will be delivered to the user on their platform (Discord, Telegram, Teams, etc.).", {
|
|
452
|
+
platform: z
|
|
453
|
+
.enum(["discord", "teams", "telegram", "whatsapp", "slack", "nctalk"])
|
|
454
|
+
.describe("Platform where the DM conversation is active"),
|
|
455
|
+
text: z.string().describe("Message text to send"),
|
|
456
|
+
}, async ({ platform, text }) => {
|
|
457
|
+
channelStopTyping(platform);
|
|
458
|
+
const data = (await chamadePost("/api/dm/chat", {
|
|
459
|
+
platform,
|
|
460
|
+
text,
|
|
461
|
+
}));
|
|
468
462
|
return {
|
|
469
|
-
content: [
|
|
463
|
+
content: [
|
|
464
|
+
{
|
|
465
|
+
type: "text",
|
|
466
|
+
text: `Message sent to ${platform} (${data.delivery || "async"}): "${text}"`,
|
|
467
|
+
},
|
|
468
|
+
],
|
|
470
469
|
};
|
|
471
470
|
});
|
|
472
|
-
// -- Tool:
|
|
473
|
-
server.tool("
|
|
474
|
-
|
|
475
|
-
.
|
|
471
|
+
// -- Tool: dm_typing ----------------------------------------------------------
|
|
472
|
+
server.tool("chamade_dm_typing", "Send a typing indicator on a DM conversation. Use this before composing a reply so the user sees you are working on it. Only works on platforms with 'typing' in capabilities (Discord, Teams, Telegram, NC Talk).", {
|
|
473
|
+
platform: z
|
|
474
|
+
.enum(["discord", "teams", "telegram", "whatsapp", "slack", "nctalk"])
|
|
475
|
+
.describe("Platform where the DM conversation is active"),
|
|
476
|
+
}, async ({ platform }) => {
|
|
477
|
+
await chamadePost("/api/dm/typing", { platform });
|
|
478
|
+
return {
|
|
479
|
+
content: [{ type: "text", text: `Typing indicator sent on ${platform}.` }],
|
|
480
|
+
};
|
|
481
|
+
});
|
|
482
|
+
// ===========================================================================
|
|
483
|
+
// OTHER TOOLS
|
|
484
|
+
// ===========================================================================
|
|
485
|
+
// -- Tool: inbox --------------------------------------------------------------
|
|
486
|
+
server.tool("chamade_inbox", "Check inbox for DM conversations. Without a platform, lists all active conversations. With a platform, returns the active DM conversation details and message history for that platform.", {
|
|
487
|
+
platform: z
|
|
488
|
+
.enum(["discord", "teams", "telegram", "whatsapp", "slack", "nctalk"])
|
|
476
489
|
.optional()
|
|
477
|
-
.describe("Optional
|
|
490
|
+
.describe("Optional: get messages for a specific platform's DM"),
|
|
478
491
|
limit: z
|
|
479
492
|
.number()
|
|
480
493
|
.default(20)
|
|
481
494
|
.describe("Max messages to return (when viewing a conversation)"),
|
|
482
|
-
}, async ({
|
|
483
|
-
if (
|
|
484
|
-
const data = (await chamadeGet(`/api/inbox
|
|
495
|
+
}, async ({ platform, limit }) => {
|
|
496
|
+
if (platform) {
|
|
497
|
+
const data = (await chamadeGet(`/api/inbox?platform=${platform}&limit=${limit}`));
|
|
485
498
|
const conv = data.conversation;
|
|
486
499
|
const messages = data.messages;
|
|
487
500
|
const capabilities = conv.capabilities ?? [];
|
|
488
501
|
const lines = [
|
|
489
|
-
`Conversation: ${conv.id}`,
|
|
490
502
|
`Platform: ${conv.platform}`,
|
|
491
|
-
`Contact: ${conv.remote_name ||
|
|
503
|
+
`Contact: ${conv.remote_name || "unknown"}`,
|
|
492
504
|
`Type: ${conv.channel_type}`,
|
|
493
505
|
`Capabilities: ${capabilities.join(", ") || "text"}`,
|
|
494
506
|
`Messages: ${conv.message_count}`,
|
|
@@ -521,32 +533,44 @@ server.tool("chamade_inbox", "Check inbox for DM conversations. Without conversa
|
|
|
521
533
|
const capabilities = c.capabilities ?? [];
|
|
522
534
|
const cap = capabilities.length > 0 ? ` [${capabilities.join(",")}]` : "";
|
|
523
535
|
const callInfo = c.call_id ? ` (voice: ${c.call_id})` : "";
|
|
524
|
-
return `- ${c.
|
|
536
|
+
return `- ${c.platform} — ${c.remote_name || "unknown"} — ${c.message_count} msgs${cap}${callInfo}`;
|
|
525
537
|
});
|
|
526
538
|
return {
|
|
527
539
|
content: [{ type: "text", text: lines.join("\n") }],
|
|
528
540
|
};
|
|
529
541
|
});
|
|
530
|
-
// -- Tool:
|
|
531
|
-
server.tool("
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
const
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
}
|
|
542
|
+
// -- Tool: account ------------------------------------------------------------
|
|
543
|
+
server.tool("chamade_account", "Check account status: plan, credit/quota remaining, and per-platform readiness (ok, not_configured, error). Use this to diagnose setup issues or check remaining credit before making calls.", {}, async () => {
|
|
544
|
+
const data = (await chamadeGet("/api/account"));
|
|
545
|
+
const lines = [`Plan: ${data.plan}`];
|
|
546
|
+
// Credit or voice quota
|
|
547
|
+
const credit = data.credit;
|
|
548
|
+
const voice = data.voice_quota;
|
|
549
|
+
if (credit) {
|
|
550
|
+
lines.push(`Credit: ${credit.remaining_eur.toFixed(2)} EUR remaining (${credit.used_eur.toFixed(2)} / ${credit.total_eur.toFixed(2)} EUR used)`);
|
|
551
|
+
}
|
|
552
|
+
else if (voice) {
|
|
553
|
+
lines.push(`Voice quota: ${voice.used_minutes.toFixed(1)} / ${voice.limit_minutes} min used`);
|
|
554
|
+
}
|
|
555
|
+
const concurrent = data.concurrent_calls;
|
|
556
|
+
if (concurrent) {
|
|
557
|
+
const limitStr = concurrent.limit === 0 ? "unlimited" : String(concurrent.limit);
|
|
558
|
+
lines.push(`Active calls: ${concurrent.active} / ${limitStr}`);
|
|
559
|
+
}
|
|
560
|
+
// Platform statuses
|
|
561
|
+
const platforms = data.platforms;
|
|
562
|
+
if (platforms) {
|
|
563
|
+
lines.push("", "Platforms:");
|
|
564
|
+
for (const [name, status] of Object.entries(platforms)) {
|
|
565
|
+
const icon = status.startsWith("ok") ? "+" : status.startsWith("error") ? "!" : "-";
|
|
566
|
+
lines.push(` ${icon} ${name}: ${status}`);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
540
569
|
return {
|
|
541
|
-
content: [
|
|
542
|
-
{
|
|
543
|
-
type: "text",
|
|
544
|
-
text: `Message sent (${data.delivery || "async"}): "${text}"`,
|
|
545
|
-
},
|
|
546
|
-
],
|
|
570
|
+
content: [{ type: "text", text: lines.join("\n") }],
|
|
547
571
|
};
|
|
548
572
|
});
|
|
549
|
-
// -- Resource: transcript
|
|
573
|
+
// -- Resource: transcript -----------------------------------------------------
|
|
550
574
|
const transcriptTemplate = new ResourceTemplate("chamade://calls/{call_id}/transcript", {
|
|
551
575
|
list: async () => {
|
|
552
576
|
return {
|
|
@@ -603,18 +627,18 @@ const _callWatchers = new Map();
|
|
|
603
627
|
const _closedWatchers = new Set();
|
|
604
628
|
const _typingActive = new Set();
|
|
605
629
|
/**
|
|
606
|
-
* Start typing indicator for a conversation.
|
|
630
|
+
* Start typing indicator for a DM conversation (keyed by platform).
|
|
607
631
|
* Sends a single POST — Maquisard manages the repeat loop internally
|
|
608
632
|
* and stops it automatically when a message is sent.
|
|
609
633
|
*/
|
|
610
|
-
function channelStartTyping(
|
|
611
|
-
if (_typingActive.has(
|
|
634
|
+
function channelStartTyping(platform) {
|
|
635
|
+
if (_typingActive.has(platform))
|
|
612
636
|
return;
|
|
613
|
-
_typingActive.add(
|
|
614
|
-
chamadePost("/api/typing", {
|
|
637
|
+
_typingActive.add(platform);
|
|
638
|
+
chamadePost("/api/dm/typing", { platform }).catch(() => { });
|
|
615
639
|
}
|
|
616
|
-
function channelStopTyping(
|
|
617
|
-
_typingActive.delete(
|
|
640
|
+
function channelStopTyping(platform) {
|
|
641
|
+
_typingActive.delete(platform);
|
|
618
642
|
}
|
|
619
643
|
/**
|
|
620
644
|
* Push a channel notification to Claude Code.
|
|
@@ -639,6 +663,12 @@ async function channelPush(content, meta = {}) {
|
|
|
639
663
|
/**
|
|
640
664
|
* Watch a call's transcript via WebSocket push.
|
|
641
665
|
* Opens a WS to /api/call/{id}/stream and pushes each event.
|
|
666
|
+
*
|
|
667
|
+
* Events from server (already remapped by Chamade backend):
|
|
668
|
+
* - call_transcript: speaker + text
|
|
669
|
+
* - call_chat: sender + text
|
|
670
|
+
* - call_state: state changes
|
|
671
|
+
* - call_error: errors
|
|
642
672
|
*/
|
|
643
673
|
function channelWatchCall(callId) {
|
|
644
674
|
if (_callWatchers.has(callId) || _closedWatchers.has(callId))
|
|
@@ -660,28 +690,27 @@ function channelWatchCall(callId) {
|
|
|
660
690
|
try {
|
|
661
691
|
const data = JSON.parse(raw.toString());
|
|
662
692
|
switch (data.type) {
|
|
663
|
-
case "
|
|
693
|
+
case "call_transcript":
|
|
664
694
|
retryCount = 0; // Real data — reset retry counter
|
|
665
695
|
if (data.is_final !== false) {
|
|
666
|
-
await channelPush(`[${data.speaker || "?"}] ${data.text || ""}`, { type: "
|
|
696
|
+
await channelPush(`[${data.speaker || "?"}] ${data.text || ""}`, { type: "call_transcript", call_id: callId });
|
|
667
697
|
}
|
|
668
698
|
break;
|
|
669
|
-
case "
|
|
670
|
-
|
|
671
|
-
await channelPush(`[chat:${data.sender || "?"}] ${data.text || ""}`, { type: "chat", call_id: callId });
|
|
699
|
+
case "call_chat":
|
|
700
|
+
await channelPush(`[chat:${data.sender || "?"}] ${data.text || ""}`, { type: "call_chat", call_id: callId });
|
|
672
701
|
break;
|
|
673
|
-
case "
|
|
674
|
-
await channelPush(`Call state: ${data.state}`, { type: "
|
|
702
|
+
case "call_state":
|
|
703
|
+
await channelPush(`Call state: ${data.state}`, { type: "call_state", call_id: callId });
|
|
675
704
|
if (data.state === "ended" || data.state === "error") {
|
|
676
705
|
channelUnwatchCall(callId);
|
|
677
706
|
}
|
|
678
707
|
break;
|
|
679
|
-
case "
|
|
680
|
-
await channelPush(`Call error: ${data.message || data.code || "unknown"}`, { type: "
|
|
708
|
+
case "call_error":
|
|
709
|
+
await channelPush(`Call error: ${data.message || data.code || "unknown"}`, { type: "call_error", call_id: callId });
|
|
681
710
|
// Stop watching on any terminal error
|
|
682
711
|
channelUnwatchCall(callId);
|
|
683
712
|
if (data.code === "bridge_disconnected") {
|
|
684
|
-
await channelPush(`Bridge connection lost for call ${callId}. Use
|
|
713
|
+
await channelPush(`Bridge connection lost for call ${callId}. Use chamade_call_join with the same meeting_url to reconnect.`, { type: "call_state", call_id: callId });
|
|
685
714
|
}
|
|
686
715
|
break;
|
|
687
716
|
}
|
|
@@ -700,7 +729,7 @@ function channelWatchCall(callId) {
|
|
|
700
729
|
else if (!_closedWatchers.has(callId)) {
|
|
701
730
|
console.error(`[chamade-channel] Call ${callId}: max retries (${MAX_RETRIES}) reached, giving up`);
|
|
702
731
|
channelUnwatchCall(callId);
|
|
703
|
-
channelPush(`Call ${callId} ended (connection lost). Use
|
|
732
|
+
channelPush(`Call ${callId} ended (connection lost). Use chamade_call_leave to clean up, or chamade_call_join to reconnect.`, { type: "call_state", call_id: callId });
|
|
704
733
|
}
|
|
705
734
|
});
|
|
706
735
|
ws.on("error", () => {
|
|
@@ -726,6 +755,13 @@ function channelUnwatchCall(callId) {
|
|
|
726
755
|
/**
|
|
727
756
|
* Watch inbox for DMs, incoming calls, and conversation events.
|
|
728
757
|
* Reconnects automatically on disconnect.
|
|
758
|
+
*
|
|
759
|
+
* Events from server (already remapped by Chamade backend):
|
|
760
|
+
* - dm_chat: new DM message
|
|
761
|
+
* - dm_started: new DM conversation
|
|
762
|
+
* - dm_ended: DM conversation closed
|
|
763
|
+
* - call_invite: incoming call (SIP or DM voice)
|
|
764
|
+
* - call_state: call state change (disconnected, etc.)
|
|
729
765
|
*/
|
|
730
766
|
function channelWatchInbox() {
|
|
731
767
|
let retryDelay = 1000;
|
|
@@ -751,46 +787,34 @@ function channelWatchInbox() {
|
|
|
751
787
|
try {
|
|
752
788
|
const data = JSON.parse(raw.toString());
|
|
753
789
|
switch (data.type) {
|
|
754
|
-
case "
|
|
755
|
-
// Auto-send
|
|
756
|
-
if (data.
|
|
757
|
-
channelStartTyping(data.
|
|
790
|
+
case "dm_chat":
|
|
791
|
+
// Auto-send typing indicator by platform
|
|
792
|
+
if (data.platform) {
|
|
793
|
+
channelStartTyping(data.platform);
|
|
758
794
|
}
|
|
759
795
|
await channelPush(`New message from ${data.sender_name || "unknown"} on ${data.platform}: "${data.text}"`, {
|
|
760
|
-
type: "
|
|
761
|
-
conversation_id: data.conversation_id || "",
|
|
796
|
+
type: "dm_chat",
|
|
762
797
|
platform: data.platform || "",
|
|
763
798
|
});
|
|
764
799
|
break;
|
|
765
|
-
case "
|
|
766
|
-
await channelPush(`Incoming call from ${data.caller
|
|
767
|
-
// Auto-watch if already active (auto_answer)
|
|
800
|
+
case "call_invite":
|
|
801
|
+
await channelPush(`Incoming call${data.caller ? ` from ${data.caller}` : ""} on ${data.platform || "sip"}. Call ID: ${data.call_id}. State: ${data.state || "ringing"}. Use chamade_call_accept to pick up.`, { type: "call_invite", call_id: data.call_id || "" });
|
|
802
|
+
// Auto-watch if already active (auto_answer or DM voice)
|
|
768
803
|
if (data.state === "active" && data.call_id) {
|
|
769
804
|
channelWatchCall(data.call_id);
|
|
770
805
|
}
|
|
771
806
|
break;
|
|
772
|
-
case "
|
|
773
|
-
await channelPush(`Voice started. Call ID: ${data.call_id}. Platform: ${data.platform}.`, {
|
|
774
|
-
type: "voice_started",
|
|
775
|
-
call_id: data.call_id || "",
|
|
776
|
-
conversation_id: data.conversation_id || "",
|
|
777
|
-
});
|
|
778
|
-
if (data.call_id) {
|
|
779
|
-
channelWatchCall(data.call_id);
|
|
780
|
-
}
|
|
781
|
-
break;
|
|
782
|
-
case "conversation_started":
|
|
807
|
+
case "dm_started":
|
|
783
808
|
await channelPush(`New conversation from ${data.remote_name || "unknown"} on ${data.platform}.`, {
|
|
784
|
-
type: "
|
|
785
|
-
conversation_id: data.conversation_id || "",
|
|
809
|
+
type: "dm_started",
|
|
786
810
|
platform: data.platform || "",
|
|
787
811
|
});
|
|
788
812
|
break;
|
|
789
|
-
case "
|
|
790
|
-
await channelPush(`Conversation ended.`, { type: "
|
|
813
|
+
case "dm_ended":
|
|
814
|
+
await channelPush(`Conversation ended on ${data.platform || "unknown"}.`, { type: "dm_ended", platform: data.platform || "" });
|
|
791
815
|
break;
|
|
792
|
-
case "
|
|
793
|
-
await channelPush(`Call
|
|
816
|
+
case "call_state":
|
|
817
|
+
await channelPush(`Call ${data.call_id}: ${data.state}${data.message ? ` — ${data.message}` : ""}`, { type: "call_state", call_id: data.call_id || "" });
|
|
794
818
|
break;
|
|
795
819
|
}
|
|
796
820
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chamade/mcp-server",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "MCP server for Chamade — voice gateway for AI agents. Join Discord, Teams, Meet, Telegram, SIP, Zoom meetings and interact via speech and text. Supports Claude Code channel mode for push events.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|