@contextstream/mcp-server 0.4.15 → 0.4.16

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 +45 -37
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -9420,6 +9420,30 @@ Upgrade: ${upgradeUrl2}` : "";
9420
9420
  }
9421
9421
  return { ok: true, resolvedPath };
9422
9422
  }
9423
+ function startBackgroundIngest(projectId, resolvedPath, ingestOptions, options = {}) {
9424
+ (async () => {
9425
+ try {
9426
+ if (options.preflight) {
9427
+ const fileCheck = await countIndexableFiles(resolvedPath, { maxFiles: 1 });
9428
+ if (fileCheck.count === 0) {
9429
+ console.error(`[ContextStream] No indexable files found in ${resolvedPath}. Skipping ingest.`);
9430
+ return;
9431
+ }
9432
+ }
9433
+ let totalIndexed = 0;
9434
+ let batchCount = 0;
9435
+ console.error(`[ContextStream] Starting background ingestion for project ${projectId} from ${resolvedPath}`);
9436
+ for await (const batch of readAllFilesInBatches(resolvedPath, { batchSize: 50 })) {
9437
+ const result = await client.ingestFiles(projectId, batch, ingestOptions);
9438
+ totalIndexed += result.data?.files_indexed ?? batch.length;
9439
+ batchCount++;
9440
+ }
9441
+ console.error(`[ContextStream] Completed background ingestion: ${totalIndexed} files in ${batchCount} batches`);
9442
+ } catch (error) {
9443
+ console.error(`[ContextStream] Ingestion failed:`, error);
9444
+ }
9445
+ })();
9446
+ }
9423
9447
  registerTool(
9424
9448
  "mcp_server_version",
9425
9449
  {
@@ -10356,7 +10380,8 @@ ${formatContent(result)}`
10356
10380
  title: "Ingest local files",
10357
10381
  description: `Read ALL files from a local directory and ingest them for indexing.
10358
10382
  This indexes your entire project by reading files in batches.
10359
- Automatically detects code files and skips ignored directories like node_modules, target, dist, etc.`,
10383
+ Automatically detects code files and skips ignored directories like node_modules, target, dist, etc.
10384
+ Runs in the background and returns immediately; use 'projects_index_status' to monitor progress.`,
10360
10385
  inputSchema: external_exports.object({
10361
10386
  project_id: external_exports.string().uuid().optional().describe("Project to ingest files into (defaults to current session project)"),
10362
10387
  path: external_exports.string().describe("Local directory path to read files from"),
@@ -10373,31 +10398,11 @@ Automatically detects code files and skips ignored directories like node_modules
10373
10398
  if (!pathCheck.ok) {
10374
10399
  return errorResult(pathCheck.error);
10375
10400
  }
10376
- const fileCheck = await countIndexableFiles(pathCheck.resolvedPath, { maxFiles: 1 });
10377
- if (fileCheck.count === 0) {
10378
- return errorResult(
10379
- `Error: no indexable files found in directory: ${input.path}. The directory may be empty or contain only ignored files/directories. Supported file types include: .ts, .js, .py, .rs, .go, .java, .md, .json, etc.`
10380
- );
10381
- }
10382
10401
  const ingestOptions = {
10383
10402
  ...input.write_to_disk !== void 0 && { write_to_disk: input.write_to_disk },
10384
10403
  ...input.overwrite !== void 0 && { overwrite: input.overwrite }
10385
10404
  };
10386
- (async () => {
10387
- try {
10388
- let totalIndexed = 0;
10389
- let batchCount = 0;
10390
- console.error(`[ContextStream] Starting background ingestion for project ${projectId} from ${pathCheck.resolvedPath}`);
10391
- for await (const batch of readAllFilesInBatches(pathCheck.resolvedPath, { batchSize: 50 })) {
10392
- const result = await client.ingestFiles(projectId, batch, ingestOptions);
10393
- totalIndexed += result.data?.files_indexed ?? batch.length;
10394
- batchCount++;
10395
- }
10396
- console.error(`[ContextStream] Completed background ingestion: ${totalIndexed} files in ${batchCount} batches`);
10397
- } catch (error) {
10398
- console.error(`[ContextStream] Ingestion failed:`, error);
10399
- }
10400
- })();
10405
+ startBackgroundIngest(projectId, pathCheck.resolvedPath, ingestOptions, { preflight: true });
10401
10406
  const summary = {
10402
10407
  status: "started",
10403
10408
  message: "Ingestion running in background",
@@ -13489,24 +13494,27 @@ Use this to remove a reminder that is no longer relevant.`,
13489
13494
  if (!validPath.ok) {
13490
13495
  return errorResult(validPath.error);
13491
13496
  }
13492
- let totalFiles = 0;
13493
- let batches = 0;
13494
- for await (const batch of readAllFilesInBatches(validPath.resolvedPath, { batchSize: 50 })) {
13495
- if (batch.length === 0) continue;
13496
- await client.ingestFiles(projectId, batch, {
13497
- overwrite: input.overwrite,
13498
- write_to_disk: input.write_to_disk
13499
- });
13500
- totalFiles += batch.length;
13501
- batches += 1;
13502
- }
13497
+ const ingestOptions = {
13498
+ ...input.write_to_disk !== void 0 && { write_to_disk: input.write_to_disk },
13499
+ ...input.overwrite !== void 0 && { overwrite: input.overwrite }
13500
+ };
13501
+ startBackgroundIngest(projectId, validPath.resolvedPath, ingestOptions);
13503
13502
  const result = {
13503
+ status: "started",
13504
+ message: "Ingestion running in background",
13504
13505
  project_id: projectId,
13505
- files_ingested: totalFiles,
13506
- batches,
13507
- path: validPath.resolvedPath
13506
+ path: validPath.resolvedPath,
13507
+ ...input.write_to_disk !== void 0 && { write_to_disk: input.write_to_disk },
13508
+ ...input.overwrite !== void 0 && { overwrite: input.overwrite },
13509
+ note: "Use 'project' with action 'index_status' to monitor progress."
13510
+ };
13511
+ return {
13512
+ content: [{
13513
+ type: "text",
13514
+ text: `Ingestion started in background for directory: ${validPath.resolvedPath}. Use 'project' with action 'index_status' to monitor progress.`
13515
+ }],
13516
+ structuredContent: toStructured(result)
13508
13517
  };
13509
- return { content: [{ type: "text", text: formatContent(result) }], structuredContent: toStructured(result) };
13510
13518
  }
13511
13519
  default:
13512
13520
  return errorResult(`Unknown action: ${input.action}`);
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.4.15",
4
+ "version": "0.4.16",
5
5
  "description": "ContextStream MCP server - v0.4.x with consolidated domain tools (~11 tools, ~75% token reduction). Code context, memory, search, and AI tools.",
6
6
  "type": "module",
7
7
  "license": "MIT",