@contextstream/mcp-server 0.3.7 → 0.3.9

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 +72 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4877,23 +4877,70 @@ var ContextStreamClient = class {
4877
4877
  context.workspace_source = resolved.source;
4878
4878
  context.workspace_resolved_from = resolved.source === "local_config" ? `${rootPath}/.contextstream/config.json` : "parent_folder_mapping";
4879
4879
  } else {
4880
+ const folderName = rootPath?.split("/").pop()?.toLowerCase() || "";
4880
4881
  try {
4881
4882
  const workspaces = await this.listWorkspaces({ page_size: 50 });
4882
4883
  if (workspaces.items && workspaces.items.length > 0) {
4883
- context.status = "requires_workspace_selection";
4884
- context.workspace_candidates = workspaces.items.map((w) => ({
4885
- id: w.id,
4886
- name: w.name,
4887
- description: w.description
4888
- }));
4889
- context.message = `New folder detected: "${rootPath?.split("/").pop()}". Please select which workspace this belongs to, or create a new one.`;
4890
- context.ide_roots = ideRoots;
4891
- context.folder_name = rootPath?.split("/").pop();
4892
- return context;
4884
+ let matchedWorkspace;
4885
+ let matchSource;
4886
+ matchedWorkspace = workspaces.items.find(
4887
+ (w) => w.name.toLowerCase() === folderName
4888
+ );
4889
+ if (matchedWorkspace) {
4890
+ matchSource = "workspace_name_exact";
4891
+ }
4892
+ if (!matchedWorkspace) {
4893
+ matchedWorkspace = workspaces.items.find(
4894
+ (w) => w.name.toLowerCase().includes(folderName) || folderName.includes(w.name.toLowerCase())
4895
+ );
4896
+ if (matchedWorkspace) {
4897
+ matchSource = "workspace_name_partial";
4898
+ }
4899
+ }
4900
+ if (!matchedWorkspace) {
4901
+ for (const ws of workspaces.items) {
4902
+ try {
4903
+ const projects = await this.listProjects({ workspace_id: ws.id, page_size: 50 });
4904
+ const matchingProject = projects.items?.find(
4905
+ (p) => p.name.toLowerCase() === folderName || p.name.toLowerCase().includes(folderName) || folderName.includes(p.name.toLowerCase())
4906
+ );
4907
+ if (matchingProject) {
4908
+ matchedWorkspace = ws;
4909
+ matchSource = "project_name_match";
4910
+ projectId = matchingProject.id;
4911
+ context.project_source = "matched_existing";
4912
+ break;
4913
+ }
4914
+ } catch {
4915
+ }
4916
+ }
4917
+ }
4918
+ if (matchedWorkspace) {
4919
+ workspaceId = matchedWorkspace.id;
4920
+ workspaceName = matchedWorkspace.name;
4921
+ context.workspace_source = matchSource;
4922
+ context.workspace_auto_matched = true;
4923
+ writeLocalConfig(rootPath, {
4924
+ workspace_id: matchedWorkspace.id,
4925
+ workspace_name: matchedWorkspace.name,
4926
+ associated_at: (/* @__PURE__ */ new Date()).toISOString()
4927
+ });
4928
+ } else {
4929
+ context.status = "requires_workspace_selection";
4930
+ context.workspace_candidates = workspaces.items.map((w) => ({
4931
+ id: w.id,
4932
+ name: w.name,
4933
+ description: w.description
4934
+ }));
4935
+ context.message = `New folder detected: "${rootPath?.split("/").pop()}". Please select which workspace this belongs to, or create a new one.`;
4936
+ context.ide_roots = ideRoots;
4937
+ context.folder_name = rootPath?.split("/").pop();
4938
+ return context;
4939
+ }
4893
4940
  } else {
4894
4941
  const newWorkspace = await this.createWorkspace({
4895
- name: "My Workspace",
4896
- description: "Default workspace created by ContextStream",
4942
+ name: folderName || "My Workspace",
4943
+ description: `Workspace created for ${rootPath}`,
4897
4944
  visibility: "private"
4898
4945
  });
4899
4946
  if (newWorkspace.id) {
@@ -4929,10 +4976,22 @@ var ContextStreamClient = class {
4929
4976
  const projectName = rootPath.split("/").pop() || "My Project";
4930
4977
  try {
4931
4978
  const projects = await this.listProjects({ workspace_id: workspaceId });
4932
- const existingProject = projects.items?.find((p) => p.name === projectName);
4979
+ const projectNameLower = projectName.toLowerCase();
4980
+ let existingProject = projects.items?.find((p) => p.name.toLowerCase() === projectNameLower);
4981
+ if (existingProject) {
4982
+ context.project_match_type = "exact";
4983
+ } else {
4984
+ existingProject = projects.items?.find(
4985
+ (p) => p.name.toLowerCase().includes(projectNameLower) || projectNameLower.includes(p.name.toLowerCase())
4986
+ );
4987
+ if (existingProject) {
4988
+ context.project_match_type = "partial";
4989
+ }
4990
+ }
4933
4991
  if (existingProject) {
4934
4992
  projectId = existingProject.id;
4935
4993
  context.project_source = "existing";
4994
+ context.matched_project_name = existingProject.name;
4936
4995
  } else {
4937
4996
  const newProject = await this.createProject({
4938
4997
  name: projectName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contextstream/mcp-server",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
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",