@contextstream/mcp-server 0.3.23 → 0.3.24

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.
Files changed (2) hide show
  1. package/dist/index.js +77 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5112,6 +5112,38 @@ var ContextStreamClient = class {
5112
5112
  context.workspace_error = String(e);
5113
5113
  }
5114
5114
  }
5115
+ if (!workspaceId && !params.allow_no_workspace) {
5116
+ const folderDisplayName = rootPath?.split("/").pop() || "this folder";
5117
+ context.ide_roots = ideRoots;
5118
+ context.folder_name = folderDisplayName;
5119
+ if (rootPath) {
5120
+ context.folder_path = rootPath;
5121
+ }
5122
+ context.suggested_project_name = folderDisplayName;
5123
+ try {
5124
+ const workspaces = await this.listWorkspaces({ page_size: 50 });
5125
+ const items = Array.isArray(workspaces.items) ? workspaces.items : [];
5126
+ if (items.length > 0) {
5127
+ context.status = "requires_workspace_selection";
5128
+ context.workspace_candidates = items.map((w) => ({
5129
+ id: w.id,
5130
+ name: w.name,
5131
+ description: w.description
5132
+ }));
5133
+ context.message = `This folder is not associated with a workspace yet. Please select which workspace to use, or create a new one.`;
5134
+ return context;
5135
+ }
5136
+ context.status = "requires_workspace_name";
5137
+ context.workspace_source = "none_found";
5138
+ context.message = `No workspaces found for this account. Ask the user for a name for a new workspace, then create a project for "${folderDisplayName}".`;
5139
+ return context;
5140
+ } catch (e) {
5141
+ context.status = "requires_workspace_selection";
5142
+ context.workspace_error = String(e);
5143
+ context.message = `Unable to resolve a workspace automatically (${String(e)}). Please provide workspace_id, or create one with workspace_bootstrap.`;
5144
+ return context;
5145
+ }
5146
+ }
5115
5147
  if (!projectId && workspaceId && rootPath && params.auto_index !== false) {
5116
5148
  const projectName = rootPath.split("/").pop() || "My Project";
5117
5149
  try {
@@ -5181,6 +5213,9 @@ var ContextStreamClient = class {
5181
5213
  context.workspace_name = workspaceName;
5182
5214
  context.project_id = projectId;
5183
5215
  context.ide_roots = ideRoots;
5216
+ if (!workspaceId) {
5217
+ context.workspace_warning = "No workspace was resolved for this session. Workspace-level tools (memory/search/graph) may not work until you associate this folder with a workspace.";
5218
+ }
5184
5219
  if (workspaceId) {
5185
5220
  try {
5186
5221
  const batchedContext = await this._fetchSessionContextBatched({
@@ -7495,7 +7530,8 @@ This does semantic search on the first message. You only need context_smart on s
7495
7530
  context_hint: external_exports.string().optional().describe("RECOMMENDED: Pass the user's first message here for semantic search. This finds relevant context from ANY time, not just recent items."),
7496
7531
  include_recent_memory: external_exports.boolean().optional().describe("Include recent memory events (default: true)"),
7497
7532
  include_decisions: external_exports.boolean().optional().describe("Include recent decisions (default: true)"),
7498
- auto_index: external_exports.boolean().optional().describe("Automatically create and index project from IDE workspace (default: true)")
7533
+ auto_index: external_exports.boolean().optional().describe("Automatically create and index project from IDE workspace (default: true)"),
7534
+ allow_no_workspace: external_exports.boolean().optional().describe("If true, allow session_init to return connected even if no workspace is resolved (workspace-level tools may not work).")
7499
7535
  })
7500
7536
  },
7501
7537
  async (input) => {
@@ -7514,7 +7550,46 @@ This does semantic search on the first message. You only need context_smart on s
7514
7550
  if (sessionManager) {
7515
7551
  sessionManager.markInitialized(result);
7516
7552
  }
7517
- return { content: [{ type: "text", text: formatContent(result) }], structuredContent: toStructured(result) };
7553
+ const status = typeof result.status === "string" ? result.status : "";
7554
+ const workspaceWarning = typeof result.workspace_warning === "string" ? result.workspace_warning : "";
7555
+ let text = formatContent(result);
7556
+ if (status === "requires_workspace_name") {
7557
+ const folderPath = typeof result.folder_path === "string" ? result.folder_path : typeof input.folder_path === "string" ? input.folder_path : "";
7558
+ text = [
7559
+ "Action required: no workspaces found for this account.",
7560
+ "Ask the user for a name for the new workspace, then run `workspace_bootstrap`.",
7561
+ folderPath ? `Recommended: workspace_bootstrap(workspace_name: "<name>", folder_path: "${folderPath}")` : 'Recommended: workspace_bootstrap(workspace_name: "<name>", folder_path: "<your repo folder>")',
7562
+ "",
7563
+ "--- Raw Response ---",
7564
+ "",
7565
+ formatContent(result)
7566
+ ].join("\n");
7567
+ } else if (status === "requires_workspace_selection") {
7568
+ const folderName = typeof result.folder_name === "string" ? result.folder_name : typeof input.folder_path === "string" ? input.folder_path.split("/").pop() || "this folder" : "this folder";
7569
+ const candidates = Array.isArray(result.workspace_candidates) ? result.workspace_candidates : [];
7570
+ const lines = [];
7571
+ lines.push(`Action required: select a workspace for "${folderName}" (or create a new one).`);
7572
+ if (candidates.length > 0) {
7573
+ lines.push("");
7574
+ lines.push("Available workspaces:");
7575
+ candidates.slice(0, 25).forEach((w, i) => {
7576
+ const name = w.name || "Untitled";
7577
+ const id = w.id ? ` (${w.id})` : "";
7578
+ const desc = w.description ? ` - ${w.description}` : "";
7579
+ lines.push(` ${i + 1}. ${name}${id}${desc}`);
7580
+ });
7581
+ }
7582
+ lines.push("");
7583
+ lines.push("Then run `workspace_associate` with the selected workspace_id and your folder_path.");
7584
+ lines.push("");
7585
+ lines.push("--- Raw Response ---");
7586
+ lines.push("");
7587
+ lines.push(formatContent(result));
7588
+ text = lines.join("\n");
7589
+ } else if (workspaceWarning) {
7590
+ text = [`Warning: ${workspaceWarning}`, "", formatContent(result)].join("\n");
7591
+ }
7592
+ return { content: [{ type: "text", text }], structuredContent: toStructured(result) };
7518
7593
  }
7519
7594
  );
7520
7595
  registerTool(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contextstream/mcp-server",
3
- "version": "0.3.23",
3
+ "version": "0.3.24",
4
4
  "description": "MCP server exposing ContextStream public API - code context, memory, search, and AI tools for developers",
5
5
  "type": "module",
6
6
  "license": "MIT",