@contextstream/mcp-server 0.3.43 → 0.3.45
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 +108 -60
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5686,58 +5686,38 @@ var ContextStreamClient = class {
|
|
|
5686
5686
|
}
|
|
5687
5687
|
/**
|
|
5688
5688
|
* Fallback to individual API calls if batched endpoint is unavailable.
|
|
5689
|
+
* Uses Promise.allSettled for parallel execution (faster than sequential).
|
|
5689
5690
|
*/
|
|
5690
5691
|
async _fetchSessionContextFallback(context, workspaceId, projectId, params) {
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5699
|
-
}
|
|
5700
|
-
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
workspace_id: workspaceId,
|
|
5705
|
-
limit: 10
|
|
5706
|
-
});
|
|
5707
|
-
} catch {
|
|
5708
|
-
}
|
|
5709
|
-
}
|
|
5710
|
-
if (params.include_decisions !== false) {
|
|
5711
|
-
try {
|
|
5712
|
-
context.recent_decisions = await this.memoryDecisions({
|
|
5713
|
-
workspace_id: workspaceId,
|
|
5714
|
-
limit: 5
|
|
5715
|
-
});
|
|
5716
|
-
} catch {
|
|
5717
|
-
}
|
|
5718
|
-
}
|
|
5719
|
-
if (params.context_hint) {
|
|
5720
|
-
try {
|
|
5721
|
-
context.relevant_context = await this.memorySearch({
|
|
5722
|
-
query: params.context_hint,
|
|
5723
|
-
workspace_id: workspaceId,
|
|
5724
|
-
limit: 5
|
|
5725
|
-
});
|
|
5726
|
-
} catch {
|
|
5727
|
-
}
|
|
5728
|
-
}
|
|
5729
|
-
try {
|
|
5730
|
-
const lessons = await this.getHighPriorityLessons({
|
|
5692
|
+
const requests = [
|
|
5693
|
+
// 0: workspace overview
|
|
5694
|
+
this.workspaceOverview(workspaceId).catch(() => null),
|
|
5695
|
+
// 1: project overview (if projectId exists)
|
|
5696
|
+
projectId ? this.projectOverview(projectId).catch(() => null) : Promise.resolve(null),
|
|
5697
|
+
// 2: recent memory events
|
|
5698
|
+
params.include_recent_memory !== false ? this.listMemoryEvents({ workspace_id: workspaceId, limit: 10 }).catch(() => null) : Promise.resolve(null),
|
|
5699
|
+
// 3: recent decisions
|
|
5700
|
+
params.include_decisions !== false ? this.memoryDecisions({ workspace_id: workspaceId, limit: 5 }).catch(() => null) : Promise.resolve(null),
|
|
5701
|
+
// 4: relevant context from semantic search
|
|
5702
|
+
params.context_hint ? this.memorySearch({ query: params.context_hint, workspace_id: workspaceId, limit: 5 }).catch(() => null) : Promise.resolve(null),
|
|
5703
|
+
// 5: high-priority lessons
|
|
5704
|
+
this.getHighPriorityLessons({
|
|
5731
5705
|
workspace_id: workspaceId,
|
|
5732
5706
|
project_id: projectId,
|
|
5733
5707
|
context_hint: params.context_hint,
|
|
5734
5708
|
limit: 5
|
|
5735
|
-
})
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5709
|
+
}).catch(() => null)
|
|
5710
|
+
];
|
|
5711
|
+
const results = await Promise.all(requests);
|
|
5712
|
+
if (results[0]) context.workspace = results[0];
|
|
5713
|
+
if (results[1]) context.project = results[1];
|
|
5714
|
+
if (results[2]) context.recent_memory = results[2];
|
|
5715
|
+
if (results[3]) context.recent_decisions = results[3];
|
|
5716
|
+
if (results[4]) context.relevant_context = results[4];
|
|
5717
|
+
const lessons = results[5];
|
|
5718
|
+
if (lessons && Array.isArray(lessons) && lessons.length > 0) {
|
|
5719
|
+
context.lessons = lessons;
|
|
5720
|
+
context.lessons_warning = `\u26A0\uFE0F ${lessons.length} lesson(s) from past mistakes. Review before making changes.`;
|
|
5741
5721
|
}
|
|
5742
5722
|
}
|
|
5743
5723
|
/**
|
|
@@ -7606,6 +7586,8 @@ var CORE_TOOLSET = /* @__PURE__ */ new Set([
|
|
|
7606
7586
|
"generate_editor_rules",
|
|
7607
7587
|
"workspace_associate",
|
|
7608
7588
|
"workspace_bootstrap",
|
|
7589
|
+
"projects_create",
|
|
7590
|
+
"projects_list",
|
|
7609
7591
|
"auth_me",
|
|
7610
7592
|
"mcp_server_version"
|
|
7611
7593
|
]);
|
|
@@ -7956,16 +7938,82 @@ Upgrade: ${upgradeUrl}` : "";
|
|
|
7956
7938
|
"projects_create",
|
|
7957
7939
|
{
|
|
7958
7940
|
title: "Create project",
|
|
7959
|
-
description:
|
|
7941
|
+
description: `Create a new project within a workspace.
|
|
7942
|
+
Use this when you need to create a project for a specific folder/codebase.
|
|
7943
|
+
If workspace_id is not provided, uses the current session's workspace.
|
|
7944
|
+
Optionally associates a local folder and generates AI editor rules.
|
|
7945
|
+
|
|
7946
|
+
Access: Free`,
|
|
7960
7947
|
inputSchema: external_exports.object({
|
|
7961
|
-
name: external_exports.string(),
|
|
7962
|
-
description: external_exports.string().optional(),
|
|
7963
|
-
workspace_id: external_exports.string().uuid().optional()
|
|
7948
|
+
name: external_exports.string().describe("Project name"),
|
|
7949
|
+
description: external_exports.string().optional().describe("Project description"),
|
|
7950
|
+
workspace_id: external_exports.string().uuid().optional().describe("Workspace ID (uses current session workspace if not provided)"),
|
|
7951
|
+
folder_path: external_exports.string().optional().describe("Optional: Local folder path to associate with this project"),
|
|
7952
|
+
generate_editor_rules: external_exports.boolean().optional().describe("Generate AI editor rules in folder_path (requires folder_path)")
|
|
7964
7953
|
})
|
|
7965
7954
|
},
|
|
7966
7955
|
async (input) => {
|
|
7967
|
-
const
|
|
7968
|
-
|
|
7956
|
+
const workspaceId = resolveWorkspaceId(input.workspace_id);
|
|
7957
|
+
if (!workspaceId) {
|
|
7958
|
+
return errorResult("Error: workspace_id is required. Please call session_init first or provide workspace_id explicitly.");
|
|
7959
|
+
}
|
|
7960
|
+
const result = await client.createProject({
|
|
7961
|
+
name: input.name,
|
|
7962
|
+
description: input.description,
|
|
7963
|
+
workspace_id: workspaceId
|
|
7964
|
+
});
|
|
7965
|
+
const projectData = result;
|
|
7966
|
+
let rulesGenerated = [];
|
|
7967
|
+
if (input.folder_path && projectData.id) {
|
|
7968
|
+
try {
|
|
7969
|
+
const configDir = path4.join(input.folder_path, ".contextstream");
|
|
7970
|
+
const configPath = path4.join(configDir, "config.json");
|
|
7971
|
+
if (!fs3.existsSync(configDir)) {
|
|
7972
|
+
fs3.mkdirSync(configDir, { recursive: true });
|
|
7973
|
+
}
|
|
7974
|
+
const config = {
|
|
7975
|
+
workspace_id: workspaceId,
|
|
7976
|
+
project_id: projectData.id,
|
|
7977
|
+
project_name: input.name
|
|
7978
|
+
};
|
|
7979
|
+
fs3.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
7980
|
+
if (input.generate_editor_rules) {
|
|
7981
|
+
for (const editor of getAvailableEditors()) {
|
|
7982
|
+
const rule = generateRuleContent(editor, {
|
|
7983
|
+
workspaceId,
|
|
7984
|
+
projectName: input.name
|
|
7985
|
+
});
|
|
7986
|
+
if (rule) {
|
|
7987
|
+
const filePath = path4.join(input.folder_path, rule.filename);
|
|
7988
|
+
try {
|
|
7989
|
+
let existingContent = "";
|
|
7990
|
+
try {
|
|
7991
|
+
existingContent = fs3.readFileSync(filePath, "utf-8");
|
|
7992
|
+
} catch {
|
|
7993
|
+
}
|
|
7994
|
+
if (!existingContent) {
|
|
7995
|
+
fs3.writeFileSync(filePath, rule.content);
|
|
7996
|
+
rulesGenerated.push(rule.filename);
|
|
7997
|
+
} else if (!existingContent.includes("ContextStream")) {
|
|
7998
|
+
fs3.writeFileSync(filePath, existingContent + "\n\n" + rule.content);
|
|
7999
|
+
rulesGenerated.push(rule.filename + " (appended)");
|
|
8000
|
+
}
|
|
8001
|
+
} catch {
|
|
8002
|
+
}
|
|
8003
|
+
}
|
|
8004
|
+
}
|
|
8005
|
+
}
|
|
8006
|
+
} catch (err) {
|
|
8007
|
+
console.error("[ContextStream] Failed to write project config:", err);
|
|
8008
|
+
}
|
|
8009
|
+
}
|
|
8010
|
+
const response = {
|
|
8011
|
+
...result,
|
|
8012
|
+
folder_path: input.folder_path,
|
|
8013
|
+
config_written: input.folder_path ? true : void 0,
|
|
8014
|
+
editor_rules_generated: rulesGenerated.length > 0 ? rulesGenerated : void 0
|
|
8015
|
+
};
|
|
8016
|
+
return { content: [{ type: "text", text: formatContent(response) }], structuredContent: toStructured(response) };
|
|
7969
8017
|
}
|
|
7970
8018
|
);
|
|
7971
8019
|
registerTool(
|
|
@@ -10697,9 +10745,9 @@ var SessionManager = class {
|
|
|
10697
10745
|
};
|
|
10698
10746
|
|
|
10699
10747
|
// src/index.ts
|
|
10700
|
-
import { existsSync as
|
|
10748
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
10701
10749
|
import { homedir as homedir3 } from "os";
|
|
10702
|
-
import { join as
|
|
10750
|
+
import { join as join7 } from "path";
|
|
10703
10751
|
|
|
10704
10752
|
// src/setup.ts
|
|
10705
10753
|
import * as fs5 from "node:fs/promises";
|
|
@@ -11543,14 +11591,14 @@ Applying to ${projects.length} project(s)...`);
|
|
|
11543
11591
|
|
|
11544
11592
|
// src/index.ts
|
|
11545
11593
|
function showFirstRunMessage() {
|
|
11546
|
-
const configDir =
|
|
11547
|
-
const starShownFile =
|
|
11548
|
-
if (
|
|
11594
|
+
const configDir = join7(homedir3(), ".contextstream");
|
|
11595
|
+
const starShownFile = join7(configDir, ".star-shown");
|
|
11596
|
+
if (existsSync3(starShownFile)) {
|
|
11549
11597
|
return;
|
|
11550
11598
|
}
|
|
11551
|
-
if (!
|
|
11599
|
+
if (!existsSync3(configDir)) {
|
|
11552
11600
|
try {
|
|
11553
|
-
|
|
11601
|
+
mkdirSync3(configDir, { recursive: true });
|
|
11554
11602
|
} catch {
|
|
11555
11603
|
return;
|
|
11556
11604
|
}
|
|
@@ -11563,7 +11611,7 @@ function showFirstRunMessage() {
|
|
|
11563
11611
|
console.error("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501");
|
|
11564
11612
|
console.error("");
|
|
11565
11613
|
try {
|
|
11566
|
-
|
|
11614
|
+
writeFileSync3(starShownFile, (/* @__PURE__ */ new Date()).toISOString());
|
|
11567
11615
|
} catch {
|
|
11568
11616
|
}
|
|
11569
11617
|
}
|
package/package.json
CHANGED