@contextstream/mcp-server 0.3.5 → 0.3.7
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.js +116 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4595,22 +4595,53 @@ var ContextStreamClient = class {
|
|
|
4595
4595
|
uuidSchema.parse(projectId);
|
|
4596
4596
|
return request(this.config, `/projects/${projectId}/index`, { body: {} });
|
|
4597
4597
|
}
|
|
4598
|
-
// Search
|
|
4598
|
+
// Search - each method adds required search_type and filters fields
|
|
4599
4599
|
searchSemantic(body) {
|
|
4600
|
-
return request(this.config, "/search/semantic", {
|
|
4600
|
+
return request(this.config, "/search/semantic", {
|
|
4601
|
+
body: {
|
|
4602
|
+
...this.withDefaults(body),
|
|
4603
|
+
search_type: "semantic",
|
|
4604
|
+
filters: body.workspace_id ? {} : { file_types: [], languages: [], file_paths: [], exclude_paths: [], content_types: [], tags: [] }
|
|
4605
|
+
}
|
|
4606
|
+
});
|
|
4601
4607
|
}
|
|
4602
4608
|
searchHybrid(body) {
|
|
4603
|
-
return request(this.config, "/search/hybrid", {
|
|
4609
|
+
return request(this.config, "/search/hybrid", {
|
|
4610
|
+
body: {
|
|
4611
|
+
...this.withDefaults(body),
|
|
4612
|
+
search_type: "hybrid",
|
|
4613
|
+
filters: body.workspace_id ? {} : { file_types: [], languages: [], file_paths: [], exclude_paths: [], content_types: [], tags: [] }
|
|
4614
|
+
}
|
|
4615
|
+
});
|
|
4604
4616
|
}
|
|
4605
4617
|
searchKeyword(body) {
|
|
4606
|
-
return request(this.config, "/search/keyword", {
|
|
4618
|
+
return request(this.config, "/search/keyword", {
|
|
4619
|
+
body: {
|
|
4620
|
+
...this.withDefaults(body),
|
|
4621
|
+
search_type: "keyword",
|
|
4622
|
+
filters: body.workspace_id ? {} : { file_types: [], languages: [], file_paths: [], exclude_paths: [], content_types: [], tags: [] }
|
|
4623
|
+
}
|
|
4624
|
+
});
|
|
4607
4625
|
}
|
|
4608
4626
|
searchPattern(body) {
|
|
4609
|
-
return request(this.config, "/search/pattern", {
|
|
4627
|
+
return request(this.config, "/search/pattern", {
|
|
4628
|
+
body: {
|
|
4629
|
+
...this.withDefaults(body),
|
|
4630
|
+
search_type: "pattern",
|
|
4631
|
+
filters: body.workspace_id ? {} : { file_types: [], languages: [], file_paths: [], exclude_paths: [], content_types: [], tags: [] }
|
|
4632
|
+
}
|
|
4633
|
+
});
|
|
4610
4634
|
}
|
|
4611
4635
|
// Memory / Knowledge
|
|
4612
4636
|
createMemoryEvent(body) {
|
|
4613
|
-
|
|
4637
|
+
const withDefaults = this.withDefaults(body);
|
|
4638
|
+
if (!withDefaults.workspace_id) {
|
|
4639
|
+
throw new Error("workspace_id is required for creating memory events. Set defaultWorkspaceId in config or provide workspace_id.");
|
|
4640
|
+
}
|
|
4641
|
+
if (!body.content || body.content.trim().length === 0) {
|
|
4642
|
+
throw new Error("content is required and cannot be empty");
|
|
4643
|
+
}
|
|
4644
|
+
return request(this.config, "/memory/events", { body: withDefaults });
|
|
4614
4645
|
}
|
|
4615
4646
|
bulkIngestEvents(body) {
|
|
4616
4647
|
return request(this.config, "/memory/events/ingest", { body: this.withDefaults(body) });
|
|
@@ -5408,10 +5439,23 @@ function registerTools(server, client, sessionManager) {
|
|
|
5408
5439
|
};
|
|
5409
5440
|
}
|
|
5410
5441
|
function registerTool(name, config, handler) {
|
|
5442
|
+
const safeHandler = async (input) => {
|
|
5443
|
+
try {
|
|
5444
|
+
return await handler(input);
|
|
5445
|
+
} catch (error) {
|
|
5446
|
+
const errorMessage = error?.message || String(error);
|
|
5447
|
+
const errorDetails = error?.body || error?.details || null;
|
|
5448
|
+
const errorCode = error?.code || error?.status || "UNKNOWN_ERROR";
|
|
5449
|
+
const serializedError = new Error(
|
|
5450
|
+
`[${errorCode}] ${errorMessage}${errorDetails ? `: ${JSON.stringify(errorDetails)}` : ""}`
|
|
5451
|
+
);
|
|
5452
|
+
throw serializedError;
|
|
5453
|
+
}
|
|
5454
|
+
};
|
|
5411
5455
|
server.registerTool(
|
|
5412
5456
|
name,
|
|
5413
5457
|
config,
|
|
5414
|
-
wrapWithAutoContext(name,
|
|
5458
|
+
wrapWithAutoContext(name, safeHandler)
|
|
5415
5459
|
);
|
|
5416
5460
|
}
|
|
5417
5461
|
registerTool(
|
|
@@ -6303,7 +6347,29 @@ Use this to persist decisions, insights, preferences, or important information.`
|
|
|
6303
6347
|
})
|
|
6304
6348
|
},
|
|
6305
6349
|
async (input) => {
|
|
6306
|
-
|
|
6350
|
+
let workspaceId = input.workspace_id;
|
|
6351
|
+
let projectId = input.project_id;
|
|
6352
|
+
if (!workspaceId && sessionManager) {
|
|
6353
|
+
const ctx = sessionManager.getContext();
|
|
6354
|
+
if (ctx) {
|
|
6355
|
+
workspaceId = ctx.workspace_id;
|
|
6356
|
+
projectId = projectId || ctx.project_id;
|
|
6357
|
+
}
|
|
6358
|
+
}
|
|
6359
|
+
if (!workspaceId) {
|
|
6360
|
+
return {
|
|
6361
|
+
content: [{
|
|
6362
|
+
type: "text",
|
|
6363
|
+
text: "Error: workspace_id is required. Please call session_init first or provide workspace_id explicitly."
|
|
6364
|
+
}],
|
|
6365
|
+
isError: true
|
|
6366
|
+
};
|
|
6367
|
+
}
|
|
6368
|
+
const result = await client.captureContext({
|
|
6369
|
+
...input,
|
|
6370
|
+
workspace_id: workspaceId,
|
|
6371
|
+
project_id: projectId
|
|
6372
|
+
});
|
|
6307
6373
|
return { content: [{ type: "text", text: formatContent(result) }], structuredContent: toStructured(result) };
|
|
6308
6374
|
}
|
|
6309
6375
|
);
|
|
@@ -6322,7 +6388,20 @@ Returns memory matches, relevant code, and related decisions in one call.`,
|
|
|
6322
6388
|
})
|
|
6323
6389
|
},
|
|
6324
6390
|
async (input) => {
|
|
6325
|
-
|
|
6391
|
+
let workspaceId = input.workspace_id;
|
|
6392
|
+
let projectId = input.project_id;
|
|
6393
|
+
if (!workspaceId && sessionManager) {
|
|
6394
|
+
const ctx = sessionManager.getContext();
|
|
6395
|
+
if (ctx) {
|
|
6396
|
+
workspaceId = ctx.workspace_id;
|
|
6397
|
+
projectId = projectId || ctx.project_id;
|
|
6398
|
+
}
|
|
6399
|
+
}
|
|
6400
|
+
const result = await client.smartSearch({
|
|
6401
|
+
...input,
|
|
6402
|
+
workspace_id: workspaceId,
|
|
6403
|
+
project_id: projectId
|
|
6404
|
+
});
|
|
6326
6405
|
return { content: [{ type: "text", text: formatContent(result) }], structuredContent: toStructured(result) };
|
|
6327
6406
|
}
|
|
6328
6407
|
);
|
|
@@ -6340,6 +6419,21 @@ Example: "Remember that I prefer TypeScript strict mode" or "Remember we decided
|
|
|
6340
6419
|
})
|
|
6341
6420
|
},
|
|
6342
6421
|
async (input) => {
|
|
6422
|
+
let workspaceId = input.workspace_id;
|
|
6423
|
+
let projectId = input.project_id;
|
|
6424
|
+
if (!workspaceId && sessionManager) {
|
|
6425
|
+
const ctx = sessionManager.getContext();
|
|
6426
|
+
if (ctx) {
|
|
6427
|
+
workspaceId = ctx.workspace_id;
|
|
6428
|
+
projectId = projectId || ctx.project_id;
|
|
6429
|
+
}
|
|
6430
|
+
}
|
|
6431
|
+
if (!workspaceId) {
|
|
6432
|
+
return {
|
|
6433
|
+
content: [{ type: "text", text: "Error: workspace_id is required. Please call session_init first." }],
|
|
6434
|
+
isError: true
|
|
6435
|
+
};
|
|
6436
|
+
}
|
|
6343
6437
|
const lowerContent = input.content.toLowerCase();
|
|
6344
6438
|
let eventType = "insight";
|
|
6345
6439
|
if (lowerContent.includes("prefer") || lowerContent.includes("like") || lowerContent.includes("always")) {
|
|
@@ -6350,8 +6444,8 @@ Example: "Remember that I prefer TypeScript strict mode" or "Remember we decided
|
|
|
6350
6444
|
eventType = "task";
|
|
6351
6445
|
}
|
|
6352
6446
|
const result = await client.captureContext({
|
|
6353
|
-
workspace_id:
|
|
6354
|
-
project_id:
|
|
6447
|
+
workspace_id: workspaceId,
|
|
6448
|
+
project_id: projectId,
|
|
6355
6449
|
event_type: eventType,
|
|
6356
6450
|
title: input.content.slice(0, 100),
|
|
6357
6451
|
content: input.content,
|
|
@@ -6373,10 +6467,19 @@ Example: "What were the auth decisions?" or "What are my TypeScript preferences?
|
|
|
6373
6467
|
})
|
|
6374
6468
|
},
|
|
6375
6469
|
async (input) => {
|
|
6470
|
+
let workspaceId = input.workspace_id;
|
|
6471
|
+
let projectId = input.project_id;
|
|
6472
|
+
if (!workspaceId && sessionManager) {
|
|
6473
|
+
const ctx = sessionManager.getContext();
|
|
6474
|
+
if (ctx) {
|
|
6475
|
+
workspaceId = ctx.workspace_id;
|
|
6476
|
+
projectId = projectId || ctx.project_id;
|
|
6477
|
+
}
|
|
6478
|
+
}
|
|
6376
6479
|
const result = await client.smartSearch({
|
|
6377
6480
|
query: input.query,
|
|
6378
|
-
workspace_id:
|
|
6379
|
-
project_id:
|
|
6481
|
+
workspace_id: workspaceId,
|
|
6482
|
+
project_id: projectId,
|
|
6380
6483
|
include_decisions: true
|
|
6381
6484
|
});
|
|
6382
6485
|
return { content: [{ type: "text", text: formatContent(result) }], structuredContent: toStructured(result) };
|
package/package.json
CHANGED