@band-ai/sdk 0.1.10 → 0.2.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.md +54 -54
- package/dist/{ClaudeSDKAdapter-DfjaI5ke.d.cts → ClaudeSDKAdapter-BY4zEbCl.d.cts} +12 -10
- package/dist/{ClaudeSDKAdapter-DonPGJ43.d.ts → ClaudeSDKAdapter-Cna5P1dR.d.ts} +12 -10
- package/dist/{acp-server-NZAeg-WO.d.ts → acp-server-CiUqN3G3.d.ts} +2 -2
- package/dist/{acp-server-CUBXIiG6.d.cts → acp-server-Dlj7D563.d.cts} +2 -2
- package/dist/adapters.cjs +250 -183
- package/dist/adapters.d.cts +21 -19
- package/dist/adapters.d.ts +21 -19
- package/dist/adapters.js +65 -44
- package/dist/backends-D-dBdDm-.d.ts +27 -0
- package/dist/backends-ZLxmQrTZ.d.cts +27 -0
- package/dist/{chunk-2BHHR6YW.js → chunk-4IAXZBXX.js} +62 -23
- package/dist/{chunk-SG4WLD2H.js → chunk-EAI2M3WM.js} +38 -94
- package/dist/{chunk-YR3BOQNW.js → chunk-JY75VSQK.js} +7 -7
- package/dist/{chunk-RDM4TE4B.js → chunk-LBWKISBS.js} +19 -1
- package/dist/{chunk-FP237EAG.js → chunk-N2QTUMGO.js} +112 -195
- package/dist/{chunk-J3M3PFFY.js → chunk-NMZLX7TP.js} +35 -31
- package/dist/{chunk-6RXWL6TC.js → chunk-NT7TBFX2.js} +1 -1
- package/dist/{chunk-MLROFDKR.js → chunk-RV76SKFT.js} +39 -33
- package/dist/{chunk-XA4N2JPH.js → chunk-TLBCKDQO.js} +23 -23
- package/dist/{chunk-IZPV6QS6.js → chunk-WL2HNJZ6.js} +38 -11
- package/dist/{chunk-DNPVCR3S.js → chunk-WLCM2OXG.js} +31 -31
- package/dist/config.cjs +40 -13
- package/dist/config.d.cts +7 -1
- package/dist/config.d.ts +7 -1
- package/dist/config.js +2 -2
- package/dist/converters.cjs +61 -61
- package/dist/converters.d.cts +5 -5
- package/dist/converters.d.ts +5 -5
- package/dist/converters.js +4 -4
- package/dist/core.cjs +8 -8
- package/dist/core.d.cts +9 -9
- package/dist/core.d.ts +9 -9
- package/dist/core.js +3 -3
- package/dist/{dtos-Dd_fTfLn.d.cts → dtos-B8KU_q4d.d.cts} +2 -2
- package/dist/{dtos-Dd_fTfLn.d.ts → dtos-B8KU_q4d.d.ts} +2 -2
- package/dist/index.cjs +459 -504
- package/dist/index.d.cts +16 -15
- package/dist/index.d.ts +16 -15
- package/dist/index.js +15 -13
- package/dist/linear.cjs +74 -74
- package/dist/linear.d.cts +14 -14
- package/dist/linear.d.ts +14 -14
- package/dist/linear.js +72 -72
- package/dist/mcp-claude.cjs +37 -36
- package/dist/mcp-claude.d.cts +3 -3
- package/dist/mcp-claude.d.ts +3 -3
- package/dist/mcp-claude.js +7 -6
- package/dist/mcp.cjs +103 -62
- package/dist/mcp.d.cts +29 -16
- package/dist/mcp.d.ts +29 -16
- package/dist/mcp.js +14 -14
- package/dist/{opencode--iA5-KYk.d.cts → opencode-2YdscIc1.d.cts} +5 -5
- package/dist/{opencode-YNacv-eJ.d.ts → opencode-Bld62x5t.d.ts} +5 -5
- package/dist/{pagination-BBLsYLhT.d.ts → pagination-BgEx-HeL.d.ts} +2 -2
- package/dist/{pagination-CqidD-L_.d.cts → pagination-DqdkQArT.d.cts} +2 -2
- package/dist/{protocols-BF6jamIl.d.ts → protocols-Bwwcql0h.d.ts} +1 -1
- package/dist/{protocols-D2bTrQ_t.d.cts → protocols-Bz1rxcUg.d.cts} +1 -1
- package/dist/rest.cjs +41 -97
- package/dist/rest.d.cts +7 -7
- package/dist/rest.d.ts +7 -7
- package/dist/rest.js +2 -2
- package/dist/runtime.cjs +293 -464
- package/dist/runtime.d.cts +16 -28
- package/dist/runtime.d.ts +16 -28
- package/dist/runtime.js +12 -63
- package/dist/{schemas-CI0qgcp_.d.cts → schemas-BotL3ZLH.d.cts} +40 -54
- package/dist/{schemas-B1Fd3oUM.d.ts → schemas-DBsC4J1g.d.ts} +40 -54
- package/dist/{sdk-D2rTDU_o.d.cts → sdk-BTciSLRQ.d.cts} +5 -5
- package/dist/{sdk-CyqN1W5g.d.ts → sdk-qKJtMma_.d.ts} +5 -5
- package/dist/{simpleAdapter-qQt-tSz4.d.ts → simpleAdapter--wznuoOw.d.ts} +1 -1
- package/dist/{simpleAdapter-C_f-01Cu.d.cts → simpleAdapter-BpT4XbZC.d.cts} +1 -1
- package/dist/testing.d.cts +3 -3
- package/dist/testing.d.ts +3 -3
- package/dist/{types-DNySTI_8.d.ts → types-BTN_ZETM.d.ts} +2 -2
- package/dist/{types-D3AsUnd0.d.ts → types-BgYFd_Yw.d.cts} +5 -5
- package/dist/{types-DtMms5Fi.d.cts → types-BivGO7I9.d.ts} +5 -5
- package/dist/{types-CKqrhGB1.d.cts → types-D958TC71.d.cts} +2 -2
- package/package.json +6 -5
- package/dist/backends-DYtEhCZG.d.cts +0 -25
- package/dist/backends-oYAb7EU-.d.ts +0 -25
package/dist/mcp.cjs
CHANGED
|
@@ -113,9 +113,9 @@ var init_memory = __esm({
|
|
|
113
113
|
"active",
|
|
114
114
|
// Normal, visible memories
|
|
115
115
|
"superseded",
|
|
116
|
-
// Outdated; soft-deleted via
|
|
116
|
+
// Outdated; soft-deleted via band_supersede_memory
|
|
117
117
|
"archived",
|
|
118
|
-
// Hidden but preserved via
|
|
118
|
+
// Hidden but preserved via band_archive_memory
|
|
119
119
|
"all"
|
|
120
120
|
// Any status (no filter)
|
|
121
121
|
];
|
|
@@ -134,14 +134,14 @@ function getToolDescription(name) {
|
|
|
134
134
|
const model = TOOL_MODELS[name];
|
|
135
135
|
return model?.description ?? `Execute ${name}`;
|
|
136
136
|
}
|
|
137
|
-
var TOOL_MODELS, ALL_TOOL_NAMES, MEMORY_TOOL_NAMES, CONTACT_TOOL_NAMES, BASE_TOOL_NAMES, CHAT_TOOL_NAMES, MCP_TOOL_PREFIX;
|
|
137
|
+
var TOOL_MODELS, ALL_TOOL_NAMES, MEMORY_TOOL_NAMES, CONTACT_TOOL_NAMES, BASE_TOOL_NAMES, CHAT_TOOL_NAMES, MCP_TOOL_PREFIX, MCP_SERVER_NAME;
|
|
138
138
|
var init_schemas = __esm({
|
|
139
139
|
"src/runtime/tools/schemas.ts"() {
|
|
140
140
|
"use strict";
|
|
141
141
|
init_chatEvents();
|
|
142
142
|
init_memory();
|
|
143
143
|
TOOL_MODELS = {
|
|
144
|
-
|
|
144
|
+
band_send_message: {
|
|
145
145
|
description: "Send a message to the chat room. Use this to respond to users or other agents. Messages require at least one @mention in the mentions array. You MUST use this tool to communicate \u2014 plain text responses won't reach users. When delegating, send the full task context in this message instead of assuming hidden state.",
|
|
146
146
|
properties: {
|
|
147
147
|
content: {
|
|
@@ -157,7 +157,7 @@ var init_schemas = __esm({
|
|
|
157
157
|
},
|
|
158
158
|
required: ["content", "mentions"]
|
|
159
159
|
},
|
|
160
|
-
|
|
160
|
+
band_send_event: {
|
|
161
161
|
description: "Send an event to the chat room. No mentions required. 'thought': Share your reasoning or plan BEFORE taking actions. Explain what you're about to do and why. 'error': Report an error or problem that occurred. 'task': Report task progress or completion status. Always send a thought before complex actions to keep users informed.",
|
|
162
162
|
properties: {
|
|
163
163
|
content: {
|
|
@@ -176,12 +176,12 @@ var init_schemas = __esm({
|
|
|
176
176
|
},
|
|
177
177
|
required: ["content", "message_type"]
|
|
178
178
|
},
|
|
179
|
-
|
|
180
|
-
description: "Add a participant (agent or user) to the chat room by name. IMPORTANT: Use
|
|
179
|
+
band_add_participant: {
|
|
180
|
+
description: "Add a participant (agent or user) to the chat room by name. IMPORTANT: Use band_lookup_peers() first to find available agents. Pass the exact peer name from band_lookup_peers, not the handle. For normal delegation, omit role or use 'member'.",
|
|
181
181
|
properties: {
|
|
182
182
|
name: {
|
|
183
183
|
type: "string",
|
|
184
|
-
description: "Name of participant to add (must match a name from
|
|
184
|
+
description: "Name of participant to add (must match a name from band_lookup_peers)."
|
|
185
185
|
},
|
|
186
186
|
role: {
|
|
187
187
|
type: "string",
|
|
@@ -191,7 +191,7 @@ var init_schemas = __esm({
|
|
|
191
191
|
},
|
|
192
192
|
required: ["name"]
|
|
193
193
|
},
|
|
194
|
-
|
|
194
|
+
band_remove_participant: {
|
|
195
195
|
description: "Remove a participant from the chat room by name.",
|
|
196
196
|
properties: {
|
|
197
197
|
name: {
|
|
@@ -201,12 +201,12 @@ var init_schemas = __esm({
|
|
|
201
201
|
},
|
|
202
202
|
required: ["name"]
|
|
203
203
|
},
|
|
204
|
-
|
|
204
|
+
band_get_participants: {
|
|
205
205
|
description: "Get a list of all participants in the current chat room.",
|
|
206
206
|
properties: {},
|
|
207
207
|
required: []
|
|
208
208
|
},
|
|
209
|
-
|
|
209
|
+
band_lookup_peers: {
|
|
210
210
|
description: "List available peers (agents and users) that can be added to this room. Automatically excludes peers already in the room. Returns dict with 'peers' list and 'metadata' (page, page_size, total_count, total_pages). Use this to find specialized agents (e.g., Weather Agent) when you cannot answer a question directly.",
|
|
211
211
|
properties: {
|
|
212
212
|
page: {
|
|
@@ -221,7 +221,7 @@ var init_schemas = __esm({
|
|
|
221
221
|
},
|
|
222
222
|
required: []
|
|
223
223
|
},
|
|
224
|
-
|
|
224
|
+
band_create_chatroom: {
|
|
225
225
|
description: "Create a new chat room for a specific task or conversation.",
|
|
226
226
|
properties: {
|
|
227
227
|
task_id: {
|
|
@@ -231,7 +231,7 @@ var init_schemas = __esm({
|
|
|
231
231
|
},
|
|
232
232
|
required: []
|
|
233
233
|
},
|
|
234
|
-
|
|
234
|
+
band_list_contacts: {
|
|
235
235
|
description: "List agent's contacts with pagination.",
|
|
236
236
|
properties: {
|
|
237
237
|
page: {
|
|
@@ -248,7 +248,7 @@ var init_schemas = __esm({
|
|
|
248
248
|
},
|
|
249
249
|
required: []
|
|
250
250
|
},
|
|
251
|
-
|
|
251
|
+
band_add_contact: {
|
|
252
252
|
description: "Send a contact request to add someone as a contact. Returns 'pending' when request is created. Returns 'approved' when inverse request existed and was auto-accepted.",
|
|
253
253
|
properties: {
|
|
254
254
|
handle: {
|
|
@@ -262,7 +262,7 @@ var init_schemas = __esm({
|
|
|
262
262
|
},
|
|
263
263
|
required: ["handle"]
|
|
264
264
|
},
|
|
265
|
-
|
|
265
|
+
band_remove_contact: {
|
|
266
266
|
description: "Remove an existing contact by handle or ID.",
|
|
267
267
|
properties: {
|
|
268
268
|
handle: {
|
|
@@ -276,7 +276,7 @@ var init_schemas = __esm({
|
|
|
276
276
|
},
|
|
277
277
|
required: []
|
|
278
278
|
},
|
|
279
|
-
|
|
279
|
+
band_list_contact_requests: {
|
|
280
280
|
description: "List both received and sent contact requests. Received requests are always filtered to pending status. Sent requests can be filtered by status.",
|
|
281
281
|
properties: {
|
|
282
282
|
page: {
|
|
@@ -298,7 +298,7 @@ var init_schemas = __esm({
|
|
|
298
298
|
},
|
|
299
299
|
required: []
|
|
300
300
|
},
|
|
301
|
-
|
|
301
|
+
band_respond_contact_request: {
|
|
302
302
|
description: "Respond to a contact request. 'approve'/'reject': For requests you RECEIVED (handle = requester's handle). 'cancel': For requests you SENT (handle = recipient's handle).",
|
|
303
303
|
properties: {
|
|
304
304
|
action: {
|
|
@@ -317,7 +317,7 @@ var init_schemas = __esm({
|
|
|
317
317
|
},
|
|
318
318
|
required: ["action"]
|
|
319
319
|
},
|
|
320
|
-
|
|
320
|
+
band_list_memories: {
|
|
321
321
|
description: "List memories accessible to the agent. Returns memories about the specified subject (cross-agent sharing) and organization-wide shared memories.",
|
|
322
322
|
properties: {
|
|
323
323
|
subject_id: {
|
|
@@ -362,7 +362,7 @@ var init_schemas = __esm({
|
|
|
362
362
|
},
|
|
363
363
|
required: []
|
|
364
364
|
},
|
|
365
|
-
|
|
365
|
+
band_store_memory: {
|
|
366
366
|
description: "Store a new memory entry. The memory will be associated with the authenticated agent as the source. For subject-scoped memories, provide a subject_id. For organization-scoped memories, omit subject_id.",
|
|
367
367
|
properties: {
|
|
368
368
|
content: {
|
|
@@ -404,7 +404,7 @@ var init_schemas = __esm({
|
|
|
404
404
|
},
|
|
405
405
|
required: ["content", "system", "type", "segment", "thought"]
|
|
406
406
|
},
|
|
407
|
-
|
|
407
|
+
band_get_memory: {
|
|
408
408
|
description: "Retrieve a specific memory by ID.",
|
|
409
409
|
properties: {
|
|
410
410
|
memory_id: {
|
|
@@ -414,7 +414,7 @@ var init_schemas = __esm({
|
|
|
414
414
|
},
|
|
415
415
|
required: ["memory_id"]
|
|
416
416
|
},
|
|
417
|
-
|
|
417
|
+
band_supersede_memory: {
|
|
418
418
|
description: "Mark a memory as superseded (soft delete). Use when information is outdated or incorrect. The memory remains for audit trail but won't appear in normal queries. Only the source agent can supersede.",
|
|
419
419
|
properties: {
|
|
420
420
|
memory_id: {
|
|
@@ -424,7 +424,7 @@ var init_schemas = __esm({
|
|
|
424
424
|
},
|
|
425
425
|
required: ["memory_id"]
|
|
426
426
|
},
|
|
427
|
-
|
|
427
|
+
band_archive_memory: {
|
|
428
428
|
description: "Archive a memory (hide but preserve). Use when memory is valid but not currently needed. Archived memories can be restored later by humans. Only the source agent can archive.",
|
|
429
429
|
properties: {
|
|
430
430
|
memory_id: {
|
|
@@ -437,18 +437,18 @@ var init_schemas = __esm({
|
|
|
437
437
|
};
|
|
438
438
|
ALL_TOOL_NAMES = new Set(Object.keys(TOOL_MODELS));
|
|
439
439
|
MEMORY_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
440
|
-
"
|
|
441
|
-
"
|
|
442
|
-
"
|
|
443
|
-
"
|
|
444
|
-
"
|
|
440
|
+
"band_list_memories",
|
|
441
|
+
"band_store_memory",
|
|
442
|
+
"band_get_memory",
|
|
443
|
+
"band_supersede_memory",
|
|
444
|
+
"band_archive_memory"
|
|
445
445
|
]);
|
|
446
446
|
CONTACT_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
447
|
-
"
|
|
448
|
-
"
|
|
449
|
-
"
|
|
450
|
-
"
|
|
451
|
-
"
|
|
447
|
+
"band_list_contacts",
|
|
448
|
+
"band_add_contact",
|
|
449
|
+
"band_remove_contact",
|
|
450
|
+
"band_list_contact_requests",
|
|
451
|
+
"band_respond_contact_request"
|
|
452
452
|
]);
|
|
453
453
|
BASE_TOOL_NAMES = new Set(
|
|
454
454
|
[...ALL_TOOL_NAMES].filter((name) => !MEMORY_TOOL_NAMES.has(name))
|
|
@@ -456,7 +456,8 @@ var init_schemas = __esm({
|
|
|
456
456
|
CHAT_TOOL_NAMES = new Set(
|
|
457
457
|
[...BASE_TOOL_NAMES].filter((name) => !CONTACT_TOOL_NAMES.has(name))
|
|
458
458
|
);
|
|
459
|
-
MCP_TOOL_PREFIX = "
|
|
459
|
+
MCP_TOOL_PREFIX = "mcp__band__";
|
|
460
|
+
MCP_SERVER_NAME = "band";
|
|
460
461
|
}
|
|
461
462
|
});
|
|
462
463
|
|
|
@@ -669,9 +670,9 @@ var init_zod = __esm({
|
|
|
669
670
|
// src/mcp/sdk.ts
|
|
670
671
|
var sdk_exports = {};
|
|
671
672
|
__export(sdk_exports, {
|
|
672
|
-
|
|
673
|
+
createBandSdkMcpServer: () => createBandSdkMcpServer
|
|
673
674
|
});
|
|
674
|
-
function
|
|
675
|
+
function createBandSdkMcpServer(options) {
|
|
675
676
|
const registrationOptions = {
|
|
676
677
|
enableMemoryTools: options.enableMemoryTools,
|
|
677
678
|
enableContactTools: true,
|
|
@@ -683,7 +684,7 @@ function createThenvoiSdkMcpServer(options) {
|
|
|
683
684
|
const contextCache = /* @__PURE__ */ new Map();
|
|
684
685
|
const MAX_CONTEXT_CACHE_ENTRIES = 100;
|
|
685
686
|
const serverConfig = (0, import_claude_agent_sdk.createSdkMcpServer)({
|
|
686
|
-
name:
|
|
687
|
+
name: MCP_SERVER_NAME,
|
|
687
688
|
tools: toolDefinitions
|
|
688
689
|
});
|
|
689
690
|
return {
|
|
@@ -916,14 +917,14 @@ var init_sdk = __esm({
|
|
|
916
917
|
// src/mcp/index.ts
|
|
917
918
|
var mcp_exports = {};
|
|
918
919
|
__export(mcp_exports, {
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
920
|
+
BandMcpServer: () => BandMcpServer,
|
|
921
|
+
BandMcpSseServer: () => BandMcpSseServer,
|
|
922
|
+
BandMcpStdioServer: () => BandMcpStdioServer,
|
|
922
923
|
buildRoomScopedRegistrations: () => buildRoomScopedRegistrations,
|
|
923
924
|
buildSingleContextRegistrations: () => buildSingleContextRegistrations,
|
|
924
|
-
|
|
925
|
+
createBandMcpBackend: () => createBandMcpBackend,
|
|
925
926
|
errorResult: () => errorResult,
|
|
926
|
-
|
|
927
|
+
getBandSdkMcpServerConfig: () => getBandSdkMcpServerConfig,
|
|
927
928
|
successResult: () => successResult
|
|
928
929
|
});
|
|
929
930
|
module.exports = __toCommonJS(mcp_exports);
|
|
@@ -932,10 +933,31 @@ module.exports = __toCommonJS(mcp_exports);
|
|
|
932
933
|
init_schemas();
|
|
933
934
|
init_registrations();
|
|
934
935
|
|
|
936
|
+
// src/mcp/auth.ts
|
|
937
|
+
var import_node_crypto = require("crypto");
|
|
938
|
+
function generateAuthToken() {
|
|
939
|
+
return (0, import_node_crypto.randomBytes)(32).toString("hex");
|
|
940
|
+
}
|
|
941
|
+
function isAuthorizedRequest(authorizationHeader, authToken) {
|
|
942
|
+
if (!authToken) {
|
|
943
|
+
return true;
|
|
944
|
+
}
|
|
945
|
+
if (!authorizationHeader) {
|
|
946
|
+
return false;
|
|
947
|
+
}
|
|
948
|
+
const expected = Buffer.from(`Bearer ${authToken}`);
|
|
949
|
+
const actual = Buffer.from(authorizationHeader);
|
|
950
|
+
if (expected.length !== actual.length) {
|
|
951
|
+
return false;
|
|
952
|
+
}
|
|
953
|
+
return (0, import_node_crypto.timingSafeEqual)(expected, actual);
|
|
954
|
+
}
|
|
955
|
+
|
|
935
956
|
// src/mcp/stdio.ts
|
|
936
957
|
init_registrations();
|
|
937
958
|
init_zod();
|
|
938
|
-
|
|
959
|
+
init_schemas();
|
|
960
|
+
var BandMcpStdioServer = class {
|
|
939
961
|
options;
|
|
940
962
|
registrations;
|
|
941
963
|
mcpServer = null;
|
|
@@ -964,7 +986,7 @@ var ThenvoiMcpStdioServer = class {
|
|
|
964
986
|
const { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio.js");
|
|
965
987
|
const { z: z2 } = await import("zod");
|
|
966
988
|
const mcpServer = new McpServer({
|
|
967
|
-
name: this.options.name ??
|
|
989
|
+
name: this.options.name ?? MCP_SERVER_NAME,
|
|
968
990
|
version: "1.0.0"
|
|
969
991
|
});
|
|
970
992
|
registerTools(mcpServer, z2, this.registrations);
|
|
@@ -997,12 +1019,13 @@ function registerTools(mcpServer, z2, registrations) {
|
|
|
997
1019
|
// src/mcp/server.ts
|
|
998
1020
|
init_registrations();
|
|
999
1021
|
init_zod();
|
|
1022
|
+
init_schemas();
|
|
1000
1023
|
var PORT_RANGE_START = 5e4;
|
|
1001
1024
|
var PORT_RANGE_END = 6e4;
|
|
1002
1025
|
var MCP_SERVER_VERSION = "1.0.0";
|
|
1003
1026
|
var SESSION_IDLE_TTL_MS = 15 * 60 * 1e3;
|
|
1004
1027
|
var SESSION_SWEEP_INTERVAL_MS = 60 * 1e3;
|
|
1005
|
-
var
|
|
1028
|
+
var BandMcpServer = class {
|
|
1006
1029
|
options;
|
|
1007
1030
|
registrations;
|
|
1008
1031
|
httpServer = null;
|
|
@@ -1046,7 +1069,7 @@ var ThenvoiMcpServer = class {
|
|
|
1046
1069
|
const http = await import("http");
|
|
1047
1070
|
const { randomUUID } = await import("crypto");
|
|
1048
1071
|
const { z: z2 } = await import("zod");
|
|
1049
|
-
const serverName = this.options.name ??
|
|
1072
|
+
const serverName = this.options.name ?? MCP_SERVER_NAME;
|
|
1050
1073
|
const app = express();
|
|
1051
1074
|
app.use(express.json());
|
|
1052
1075
|
app.get("/healthz", (_req, res) => {
|
|
@@ -1054,6 +1077,10 @@ var ThenvoiMcpServer = class {
|
|
|
1054
1077
|
});
|
|
1055
1078
|
const handleMcpRequest = async (req, res) => {
|
|
1056
1079
|
try {
|
|
1080
|
+
if (!isAuthorizedRequest(req.headers.authorization, this.options.authToken)) {
|
|
1081
|
+
sendMcpError(res, 401, "Unauthorized");
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1057
1084
|
const sessionId = getSessionIdHeader(req.headers["mcp-session-id"]);
|
|
1058
1085
|
let session = sessionId ? this.sessions.get(sessionId) : void 0;
|
|
1059
1086
|
if (!session) {
|
|
@@ -1229,11 +1256,12 @@ function checkPort(http, port) {
|
|
|
1229
1256
|
// src/mcp/sse.ts
|
|
1230
1257
|
init_registrations();
|
|
1231
1258
|
init_zod();
|
|
1259
|
+
init_schemas();
|
|
1232
1260
|
var PORT_RANGE_START2 = 5e4;
|
|
1233
1261
|
var PORT_RANGE_END2 = 6e4;
|
|
1234
1262
|
var SESSION_IDLE_TTL_MS2 = 15 * 60 * 1e3;
|
|
1235
1263
|
var SESSION_SWEEP_INTERVAL_MS2 = 60 * 1e3;
|
|
1236
|
-
var
|
|
1264
|
+
var BandMcpSseServer = class {
|
|
1237
1265
|
options;
|
|
1238
1266
|
registrations;
|
|
1239
1267
|
httpServer = null;
|
|
@@ -1280,10 +1308,14 @@ var ThenvoiMcpSseServer = class {
|
|
|
1280
1308
|
app.get("/healthz", (_req, res) => {
|
|
1281
1309
|
res.json({ status: "ok" });
|
|
1282
1310
|
});
|
|
1283
|
-
app.get("/sse", async (
|
|
1311
|
+
app.get("/sse", async (req, res) => {
|
|
1312
|
+
if (!isAuthorizedRequest(req.headers.authorization, this.options.authToken)) {
|
|
1313
|
+
res.status(401).send("Unauthorized");
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1284
1316
|
const transport = new SSEServerTransport("/messages", res);
|
|
1285
1317
|
const mcpServer = new McpServer({
|
|
1286
|
-
name: this.options.name ??
|
|
1318
|
+
name: this.options.name ?? MCP_SERVER_NAME,
|
|
1287
1319
|
version: "1.0.0"
|
|
1288
1320
|
});
|
|
1289
1321
|
registerTools3(mcpServer, z2, this.registrations);
|
|
@@ -1305,6 +1337,10 @@ var ThenvoiMcpSseServer = class {
|
|
|
1305
1337
|
});
|
|
1306
1338
|
});
|
|
1307
1339
|
app.post("/messages", async (req, res) => {
|
|
1340
|
+
if (!isAuthorizedRequest(req.headers.authorization, this.options.authToken)) {
|
|
1341
|
+
res.status(401).send("Unauthorized");
|
|
1342
|
+
return;
|
|
1343
|
+
}
|
|
1308
1344
|
const sessionId = typeof req.query.sessionId === "string" ? req.query.sessionId : null;
|
|
1309
1345
|
if (!sessionId) {
|
|
1310
1346
|
res.status(400).send("Missing sessionId");
|
|
@@ -1418,15 +1454,15 @@ function checkPort2(http, port) {
|
|
|
1418
1454
|
}
|
|
1419
1455
|
|
|
1420
1456
|
// src/mcp/backends.ts
|
|
1421
|
-
async function
|
|
1457
|
+
async function createBandMcpBackend(options) {
|
|
1422
1458
|
const registrationOptions = {
|
|
1423
1459
|
enableMemoryTools: options.enableMemoryTools,
|
|
1424
1460
|
enableContactTools: true,
|
|
1425
1461
|
additionalTools: options.additionalTools
|
|
1426
1462
|
};
|
|
1427
1463
|
if (options.kind === "sdk") {
|
|
1428
|
-
const {
|
|
1429
|
-
const server2 =
|
|
1464
|
+
const { createBandSdkMcpServer: createBandSdkMcpServer2 } = await Promise.resolve().then(() => (init_sdk(), sdk_exports));
|
|
1465
|
+
const server2 = createBandSdkMcpServer2({
|
|
1430
1466
|
getToolsForRoom: options.getToolsForRoom,
|
|
1431
1467
|
multiRoom: options.multiRoom,
|
|
1432
1468
|
enableMemoryTools: options.enableMemoryTools,
|
|
@@ -1443,7 +1479,7 @@ async function createThenvoiMcpBackend(options) {
|
|
|
1443
1479
|
const registrations = options.multiRoom === false ? buildSingleContextRegistrations(resolvedTools, registrationOptions) : buildRoomScopedRegistrations(resolvedTools, registrationOptions);
|
|
1444
1480
|
const allowedTools = mcpToolNames(new Set(registrations.map((registration) => registration.name)));
|
|
1445
1481
|
if (options.kind === "stdio") {
|
|
1446
|
-
const server2 = new
|
|
1482
|
+
const server2 = new BandMcpStdioServer({
|
|
1447
1483
|
tools: resolvedTools,
|
|
1448
1484
|
enableMemoryTools: options.enableMemoryTools,
|
|
1449
1485
|
enableContactTools: true,
|
|
@@ -1459,40 +1495,45 @@ async function createThenvoiMcpBackend(options) {
|
|
|
1459
1495
|
}
|
|
1460
1496
|
};
|
|
1461
1497
|
}
|
|
1498
|
+
const authToken = generateAuthToken();
|
|
1462
1499
|
if (options.kind === "sse") {
|
|
1463
|
-
const server2 = new
|
|
1500
|
+
const server2 = new BandMcpSseServer({
|
|
1464
1501
|
tools: resolvedTools,
|
|
1465
1502
|
enableMemoryTools: options.enableMemoryTools,
|
|
1466
1503
|
enableContactTools: true,
|
|
1467
|
-
additionalTools: options.additionalTools
|
|
1504
|
+
additionalTools: options.additionalTools,
|
|
1505
|
+
authToken
|
|
1468
1506
|
});
|
|
1469
1507
|
await server2.start();
|
|
1470
1508
|
return {
|
|
1471
1509
|
kind: "sse",
|
|
1472
1510
|
server: server2,
|
|
1473
1511
|
allowedTools,
|
|
1512
|
+
authToken,
|
|
1474
1513
|
stop: async () => {
|
|
1475
1514
|
await server2.stop();
|
|
1476
1515
|
}
|
|
1477
1516
|
};
|
|
1478
1517
|
}
|
|
1479
|
-
const server = new
|
|
1518
|
+
const server = new BandMcpServer({
|
|
1480
1519
|
tools: resolvedTools,
|
|
1481
1520
|
enableMemoryTools: options.enableMemoryTools,
|
|
1482
1521
|
enableContactTools: true,
|
|
1483
|
-
additionalTools: options.additionalTools
|
|
1522
|
+
additionalTools: options.additionalTools,
|
|
1523
|
+
authToken
|
|
1484
1524
|
});
|
|
1485
1525
|
await server.start();
|
|
1486
1526
|
return {
|
|
1487
1527
|
kind: "http",
|
|
1488
1528
|
server,
|
|
1489
1529
|
allowedTools,
|
|
1530
|
+
authToken,
|
|
1490
1531
|
stop: async () => {
|
|
1491
1532
|
await server.stop();
|
|
1492
1533
|
}
|
|
1493
1534
|
};
|
|
1494
1535
|
}
|
|
1495
|
-
function
|
|
1536
|
+
function getBandSdkMcpServerConfig(backend) {
|
|
1496
1537
|
if (backend.kind !== "sdk") {
|
|
1497
1538
|
throw new Error(`Expected sdk MCP backend, received ${backend.kind}`);
|
|
1498
1539
|
}
|
|
@@ -1503,13 +1544,13 @@ function getThenvoiSdkMcpServerConfig(backend) {
|
|
|
1503
1544
|
init_registrations();
|
|
1504
1545
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1505
1546
|
0 && (module.exports = {
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1547
|
+
BandMcpServer,
|
|
1548
|
+
BandMcpSseServer,
|
|
1549
|
+
BandMcpStdioServer,
|
|
1509
1550
|
buildRoomScopedRegistrations,
|
|
1510
1551
|
buildSingleContextRegistrations,
|
|
1511
|
-
|
|
1552
|
+
createBandMcpBackend,
|
|
1512
1553
|
errorResult,
|
|
1513
|
-
|
|
1554
|
+
getBandSdkMcpServerConfig,
|
|
1514
1555
|
successResult
|
|
1515
1556
|
});
|
package/dist/mcp.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import { M as McpToolRegistration } from './sdk-
|
|
3
|
-
export {
|
|
4
|
-
import { A as AdapterToolsProtocol } from './protocols-
|
|
1
|
+
export { B as BandMcpBackend, a as BandMcpBackendKind, C as CreateBandMcpBackendOptions, c as createBandMcpBackend, g as getBandSdkMcpServerConfig } from './backends-ZLxmQrTZ.cjs';
|
|
2
|
+
import { M as McpToolRegistration } from './sdk-BTciSLRQ.cjs';
|
|
3
|
+
export { a as BuildRegistrationsOptions, b as McpToolInputSchema, c as McpToolResult, d as buildRoomScopedRegistrations, e as buildSingleContextRegistrations, f as errorResult, s as successResult } from './sdk-BTciSLRQ.cjs';
|
|
4
|
+
import { A as AdapterToolsProtocol } from './protocols-Bz1rxcUg.cjs';
|
|
5
5
|
import { Readable, Writable } from 'node:stream';
|
|
6
6
|
import '@anthropic-ai/claude-agent-sdk';
|
|
7
|
-
import './dtos-
|
|
7
|
+
import './dtos-B8KU_q4d.cjs';
|
|
8
8
|
|
|
9
|
-
interface
|
|
9
|
+
interface BandMcpServerOptions {
|
|
10
10
|
/** Single tools instance (no room scoping) or a resolver function for room-scoped tools. */
|
|
11
11
|
tools: AdapterToolsProtocol | ((roomId: string) => AdapterToolsProtocol | undefined);
|
|
12
12
|
/** Server name advertised to MCP clients. */
|
|
@@ -19,21 +19,27 @@ interface ThenvoiMcpServerOptions {
|
|
|
19
19
|
enableContactTools?: boolean;
|
|
20
20
|
/** Additional MCP tool registrations to expose alongside the built-in tools. */
|
|
21
21
|
additionalTools?: McpToolRegistration[];
|
|
22
|
+
/**
|
|
23
|
+
* When set, every `/mcp` request must carry `Authorization: Bearer <authToken>`
|
|
24
|
+
* or is rejected with a 401. Unset (the default) leaves the server open, matching
|
|
25
|
+
* prior behavior for callers that don't opt in.
|
|
26
|
+
*/
|
|
27
|
+
authToken?: string;
|
|
22
28
|
}
|
|
23
29
|
/**
|
|
24
|
-
* Standalone MCP server that exposes
|
|
30
|
+
* Standalone MCP server that exposes Band agent tools over Streamable HTTP.
|
|
25
31
|
*
|
|
26
32
|
* Uses `@modelcontextprotocol/server` (optional peer dependency) and `express`.
|
|
27
33
|
* Install with: `npm install @modelcontextprotocol/server express`
|
|
28
34
|
*/
|
|
29
|
-
declare class
|
|
35
|
+
declare class BandMcpServer {
|
|
30
36
|
private readonly options;
|
|
31
37
|
private readonly registrations;
|
|
32
38
|
private httpServer;
|
|
33
39
|
private actualPort;
|
|
34
40
|
private readonly sessions;
|
|
35
41
|
private sessionSweepTimer;
|
|
36
|
-
constructor(options:
|
|
42
|
+
constructor(options: BandMcpServerOptions);
|
|
37
43
|
/** Port the server is listening on. Null if not started. */
|
|
38
44
|
get port(): number | null;
|
|
39
45
|
/** MCP endpoint URL. Null if not started. */
|
|
@@ -48,22 +54,29 @@ declare class ThenvoiMcpServer {
|
|
|
48
54
|
private closeIdleSessions;
|
|
49
55
|
}
|
|
50
56
|
|
|
51
|
-
interface
|
|
57
|
+
interface BandMcpSseServerOptions {
|
|
52
58
|
tools: AdapterToolsProtocol | ((roomId: string) => AdapterToolsProtocol | undefined);
|
|
53
59
|
name?: string;
|
|
54
60
|
port?: number;
|
|
55
61
|
enableMemoryTools?: boolean;
|
|
56
62
|
enableContactTools?: boolean;
|
|
57
63
|
additionalTools?: McpToolRegistration[];
|
|
64
|
+
/**
|
|
65
|
+
* When set, every `/sse` and `/messages` request must carry
|
|
66
|
+
* `Authorization: Bearer <authToken>` or is rejected with a 401. Unset (the
|
|
67
|
+
* default) leaves the server open, matching prior behavior for callers that
|
|
68
|
+
* don't opt in.
|
|
69
|
+
*/
|
|
70
|
+
authToken?: string;
|
|
58
71
|
}
|
|
59
|
-
declare class
|
|
72
|
+
declare class BandMcpSseServer {
|
|
60
73
|
private readonly options;
|
|
61
74
|
private readonly registrations;
|
|
62
75
|
private httpServer;
|
|
63
76
|
private actualPort;
|
|
64
77
|
private readonly sessions;
|
|
65
78
|
private sweepTimer;
|
|
66
|
-
constructor(options:
|
|
79
|
+
constructor(options: BandMcpSseServerOptions);
|
|
67
80
|
get port(): number | null;
|
|
68
81
|
get sseUrl(): string | null;
|
|
69
82
|
get toolNames(): string[];
|
|
@@ -74,7 +87,7 @@ declare class ThenvoiMcpSseServer {
|
|
|
74
87
|
private closeIdleSessions;
|
|
75
88
|
}
|
|
76
89
|
|
|
77
|
-
interface
|
|
90
|
+
interface BandMcpStdioServerOptions {
|
|
78
91
|
tools: AdapterToolsProtocol | ((roomId: string) => AdapterToolsProtocol | undefined);
|
|
79
92
|
name?: string;
|
|
80
93
|
enableMemoryTools?: boolean;
|
|
@@ -83,15 +96,15 @@ interface ThenvoiMcpStdioServerOptions {
|
|
|
83
96
|
stdin?: Readable;
|
|
84
97
|
stdout?: Writable;
|
|
85
98
|
}
|
|
86
|
-
declare class
|
|
99
|
+
declare class BandMcpStdioServer {
|
|
87
100
|
private readonly options;
|
|
88
101
|
private readonly registrations;
|
|
89
102
|
private mcpServer;
|
|
90
103
|
private transport;
|
|
91
|
-
constructor(options:
|
|
104
|
+
constructor(options: BandMcpStdioServerOptions);
|
|
92
105
|
get toolNames(): string[];
|
|
93
106
|
start(): Promise<void>;
|
|
94
107
|
stop(): Promise<void>;
|
|
95
108
|
}
|
|
96
109
|
|
|
97
|
-
export {
|
|
110
|
+
export { BandMcpServer, type BandMcpServerOptions, BandMcpSseServer, type BandMcpSseServerOptions, BandMcpStdioServer, type BandMcpStdioServerOptions, McpToolRegistration };
|