@contextstream/mcp-server 0.3.66 → 0.3.67

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 +44 -33
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4915,12 +4915,14 @@ var ContextStreamClient = class {
4915
4915
  }
4916
4916
  withDefaults(input) {
4917
4917
  const { defaultWorkspaceId, defaultProjectId } = this.config;
4918
- const workspaceId = input.workspace_id || defaultWorkspaceId;
4919
- const useDefaultProject = !input.project_id && (!input.workspace_id || input.workspace_id === defaultWorkspaceId);
4918
+ const providedWorkspaceId = this.coerceUuid(input.workspace_id);
4919
+ const workspaceId = providedWorkspaceId || defaultWorkspaceId;
4920
+ const providedProjectId = this.coerceUuid(input.project_id);
4921
+ const useDefaultProject = !providedProjectId && (!providedWorkspaceId || providedWorkspaceId === defaultWorkspaceId);
4920
4922
  return {
4921
4923
  ...input,
4922
4924
  workspace_id: workspaceId,
4923
- project_id: input.project_id || (useDefaultProject ? defaultProjectId : void 0)
4925
+ project_id: providedProjectId || (useDefaultProject ? defaultProjectId : void 0)
4924
4926
  };
4925
4927
  }
4926
4928
  coerceUuid(value) {
@@ -6123,8 +6125,9 @@ var ContextStreamClient = class {
6123
6125
  let decisionCount = 0;
6124
6126
  let memoryCount = 0;
6125
6127
  try {
6126
- const ws = await this.getWorkspace(withDefaults.workspace_id);
6127
- workspaceName = ws?.name;
6128
+ const wsResponse = await this.getWorkspace(withDefaults.workspace_id);
6129
+ const ws = unwrapApiResponse(wsResponse);
6130
+ workspaceName = pickString(ws?.name) ?? void 0;
6128
6131
  if (workspaceName) {
6129
6132
  parts.push(`\u{1F4C1} Workspace: ${workspaceName}`);
6130
6133
  }
@@ -6132,8 +6135,9 @@ var ContextStreamClient = class {
6132
6135
  }
6133
6136
  if (withDefaults.project_id) {
6134
6137
  try {
6135
- const proj = await this.getProject(withDefaults.project_id);
6136
- projectName = proj?.name;
6138
+ const projResponse = await this.getProject(withDefaults.project_id);
6139
+ const proj = unwrapApiResponse(projResponse);
6140
+ projectName = pickString(proj?.name) ?? void 0;
6137
6141
  if (projectName) {
6138
6142
  parts.push(`\u{1F4C2} Project: ${projectName}`);
6139
6143
  }
@@ -6543,21 +6547,25 @@ var ContextStreamClient = class {
6543
6547
  const items = [];
6544
6548
  const errors = [];
6545
6549
  try {
6546
- const ws = await this.getWorkspace(withDefaults.workspace_id);
6547
- if (ws?.name) {
6548
- items.push({ type: "W", key: "workspace", value: ws.name, relevance: 1 });
6550
+ const wsResponse = await this.getWorkspace(withDefaults.workspace_id);
6551
+ const ws = unwrapApiResponse(wsResponse);
6552
+ const workspaceName = pickString(ws?.name);
6553
+ if (workspaceName) {
6554
+ items.push({ type: "W", key: "workspace", value: workspaceName, relevance: 1 });
6549
6555
  } else {
6550
- items.push({ type: "W", key: "workspace", value: withDefaults.workspace_id.slice(0, 8), relevance: 1 });
6556
+ items.push({ type: "W", key: "workspace", value: `id:${withDefaults.workspace_id}`, relevance: 1 });
6551
6557
  }
6552
6558
  } catch (e) {
6553
6559
  errors.push(`workspace: ${e?.message || "fetch failed"}`);
6554
- items.push({ type: "W", key: "workspace", value: `id:${withDefaults.workspace_id.slice(0, 8)}`, relevance: 0.5 });
6560
+ items.push({ type: "W", key: "workspace", value: `id:${withDefaults.workspace_id}`, relevance: 0.5 });
6555
6561
  }
6556
6562
  if (withDefaults.project_id) {
6557
6563
  try {
6558
- const proj = await this.getProject(withDefaults.project_id);
6559
- if (proj?.name) {
6560
- items.push({ type: "P", key: "project", value: proj.name, relevance: 1 });
6564
+ const projResponse = await this.getProject(withDefaults.project_id);
6565
+ const proj = unwrapApiResponse(projResponse);
6566
+ const projectName = pickString(proj?.name);
6567
+ if (projectName) {
6568
+ items.push({ type: "P", key: "project", value: projectName, relevance: 1 });
6561
6569
  }
6562
6570
  } catch (e) {
6563
6571
  errors.push(`project: ${e?.message || "fetch failed"}`);
@@ -6681,7 +6689,7 @@ var ContextStreamClient = class {
6681
6689
  candidateContext = candidateLines.join("\n");
6682
6690
  }
6683
6691
  if (context.length === 0 && withDefaults.workspace_id) {
6684
- const wsHint = items.find((i) => i.type === "W")?.value || withDefaults.workspace_id.slice(0, 8);
6692
+ const wsHint = items.find((i) => i.type === "W")?.value || withDefaults.workspace_id;
6685
6693
  context = format === "minified" ? `W:${wsHint}|[NO_MATCHES]` : `[CTX]
6686
6694
  W:${wsHint}
6687
6695
  [NO_MATCHES]
@@ -6713,6 +6721,8 @@ W:${wsHint}
6713
6721
  token_estimate: Math.ceil(context.length / 4),
6714
6722
  format,
6715
6723
  sources_used: items.filter((i) => context.includes(i.value.slice(0, 20))).length,
6724
+ workspace_id: withDefaults.workspace_id,
6725
+ project_id: withDefaults.project_id,
6716
6726
  ...versionNotice ? { version_notice: versionNotice } : {},
6717
6727
  ...errors.length > 0 && { errors }
6718
6728
  // Include errors for debugging
@@ -7827,6 +7837,11 @@ var DEFAULT_PARAM_DESCRIPTIONS = {
7827
7837
  context_hint: "User message used to fetch relevant context.",
7828
7838
  context: "Context to match relevant reminders."
7829
7839
  };
7840
+ var uuidSchema2 = external_exports.string().uuid();
7841
+ function normalizeUuid(value) {
7842
+ if (!value) return void 0;
7843
+ return uuidSchema2.safeParse(value).success ? value : void 0;
7844
+ }
7830
7845
  var WRITE_VERBS = /* @__PURE__ */ new Set([
7831
7846
  "create",
7832
7847
  "update",
@@ -8478,14 +8493,16 @@ Upgrade: ${upgradeUrl2}` : "";
8478
8493
  };
8479
8494
  }
8480
8495
  function resolveWorkspaceId(explicitWorkspaceId) {
8481
- if (explicitWorkspaceId) return explicitWorkspaceId;
8496
+ const normalizedExplicit = normalizeUuid(explicitWorkspaceId);
8497
+ if (normalizedExplicit) return normalizedExplicit;
8482
8498
  const ctx = sessionManager?.getContext();
8483
- return typeof ctx?.workspace_id === "string" ? ctx.workspace_id : void 0;
8499
+ return normalizeUuid(typeof ctx?.workspace_id === "string" ? ctx.workspace_id : void 0);
8484
8500
  }
8485
8501
  function resolveProjectId(explicitProjectId) {
8486
- if (explicitProjectId) return explicitProjectId;
8502
+ const normalizedExplicit = normalizeUuid(explicitProjectId);
8503
+ if (normalizedExplicit) return normalizedExplicit;
8487
8504
  const ctx = sessionManager?.getContext();
8488
- return typeof ctx?.project_id === "string" ? ctx.project_id : void 0;
8505
+ return normalizeUuid(typeof ctx?.project_id === "string" ? ctx.project_id : void 0);
8489
8506
  }
8490
8507
  async function validateReadableDirectory(inputPath) {
8491
8508
  const resolvedPath = path4.resolve(inputPath);
@@ -9704,11 +9721,12 @@ Memory: events(crud) nodes(knowledge) search(find) decisions(choices)`,
9704
9721
  description: `Retrieve user preferences, coding style, and persona from memory.
9705
9722
  Use this to understand how the user likes to work and adapt your responses accordingly.`,
9706
9723
  inputSchema: external_exports.object({
9707
- workspace_id: external_exports.string().uuid().optional().describe("Workspace to get user context from")
9724
+ workspace_id: external_exports.string().optional().describe("Workspace ID (UUID). Invalid values are ignored.")
9708
9725
  })
9709
9726
  },
9710
9727
  async (input) => {
9711
- const result = await client.getUserContext(input);
9728
+ const workspaceId = resolveWorkspaceId(input.workspace_id);
9729
+ const result = await client.getUserContext({ workspace_id: workspaceId });
9712
9730
  return { content: [{ type: "text", text: formatContent(result) }], structuredContent: toStructured(result) };
9713
9731
  }
9714
9732
  );
@@ -10072,8 +10090,8 @@ Returns lessons filtered by:
10072
10090
  - Category: workflow, code_quality, verification, communication, project_specific
10073
10091
  - Severity: low, medium, high, critical`,
10074
10092
  inputSchema: external_exports.object({
10075
- workspace_id: external_exports.string().uuid().optional(),
10076
- project_id: external_exports.string().uuid().optional(),
10093
+ workspace_id: external_exports.string().optional().describe("Workspace ID (UUID). Invalid values are ignored."),
10094
+ project_id: external_exports.string().optional().describe("Project ID (UUID). Invalid values are ignored."),
10077
10095
  query: external_exports.string().optional().describe('Search for relevant lessons (e.g., "git push images")'),
10078
10096
  category: external_exports.enum(["workflow", "code_quality", "verification", "communication", "project_specific"]).optional().describe("Filter by category"),
10079
10097
  severity: external_exports.enum(["low", "medium", "high", "critical"]).optional().describe("Filter by minimum severity"),
@@ -10081,15 +10099,8 @@ Returns lessons filtered by:
10081
10099
  })
10082
10100
  },
10083
10101
  async (input) => {
10084
- let workspaceId = input.workspace_id;
10085
- let projectId = input.project_id;
10086
- if (!workspaceId && sessionManager) {
10087
- const ctx = sessionManager.getContext();
10088
- if (ctx) {
10089
- workspaceId = ctx.workspace_id;
10090
- projectId = projectId || ctx.project_id;
10091
- }
10092
- }
10102
+ const workspaceId = resolveWorkspaceId(input.workspace_id);
10103
+ const projectId = resolveProjectId(input.project_id);
10093
10104
  const searchQuery = input.query ? `${input.query} lesson prevention warning` : "lesson prevention warning mistake";
10094
10105
  const searchResult = await client.memorySearch({
10095
10106
  query: searchQuery,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@contextstream/mcp-server",
3
3
  "mcpName": "io.github.contextstreamio/mcp-server",
4
- "version": "0.3.66",
4
+ "version": "0.3.67",
5
5
  "description": "MCP server exposing ContextStream public API - code context, memory, search, and AI tools for developers",
6
6
  "type": "module",
7
7
  "license": "MIT",