@cognistore/mcp-server 2.2.2 → 2.2.3
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 +65 -20
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -15,13 +15,13 @@ import * as sqliteVec from "sqlite-vec";
|
|
|
15
15
|
|
|
16
16
|
// ../../packages/shared/dist/types/knowledge.js
|
|
17
17
|
var KnowledgeType;
|
|
18
|
-
(function(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
(function(KnowledgeType3) {
|
|
19
|
+
KnowledgeType3["DECISION"] = "decision";
|
|
20
|
+
KnowledgeType3["PATTERN"] = "pattern";
|
|
21
|
+
KnowledgeType3["FIX"] = "fix";
|
|
22
|
+
KnowledgeType3["CONSTRAINT"] = "constraint";
|
|
23
|
+
KnowledgeType3["GOTCHA"] = "gotcha";
|
|
24
|
+
KnowledgeType3["SYSTEM"] = "system";
|
|
25
25
|
})(KnowledgeType || (KnowledgeType = {}));
|
|
26
26
|
var KnowledgeStatus;
|
|
27
27
|
(function(KnowledgeStatus2) {
|
|
@@ -140,6 +140,24 @@ var mergeTagsBatchSchema = z.object({
|
|
|
140
140
|
to: z.string().min(1, "to is required")
|
|
141
141
|
})).min(1, "at least one merge is required").max(50, "at most 50 merges per batch")
|
|
142
142
|
});
|
|
143
|
+
var MAX_IMPORT_ITEMS = 5e4;
|
|
144
|
+
var importKnowledgeEntrySchema = z.object({
|
|
145
|
+
title: z.string().max(2e3).optional(),
|
|
146
|
+
content: z.string().min(1).max(5e5),
|
|
147
|
+
tags: z.array(z.string().max(200)).max(200).optional().default([]),
|
|
148
|
+
type: knowledgeTypeSchema,
|
|
149
|
+
scope: z.string().min(1).max(300),
|
|
150
|
+
source: z.string().max(300).optional(),
|
|
151
|
+
confidenceScore: z.number().min(0).max(1).optional(),
|
|
152
|
+
expiresAt: z.string().max(64).nullable().optional(),
|
|
153
|
+
relatedIds: z.array(z.string().max(64)).nullable().optional(),
|
|
154
|
+
agentId: z.string().max(200).nullable().optional()
|
|
155
|
+
});
|
|
156
|
+
var importSchema = z.object({
|
|
157
|
+
include: z.array(z.string().max(50)).max(10).optional().default([]),
|
|
158
|
+
knowledge: z.array(importKnowledgeEntrySchema).max(MAX_IMPORT_ITEMS).optional(),
|
|
159
|
+
plans: z.array(z.record(z.unknown())).max(MAX_IMPORT_ITEMS).optional()
|
|
160
|
+
});
|
|
143
161
|
|
|
144
162
|
// ../../packages/core/dist/db/schema/index.js
|
|
145
163
|
var schema_exports = {};
|
|
@@ -2538,12 +2556,16 @@ var OllamaEmbeddingClient = class {
|
|
|
2538
2556
|
dimensions;
|
|
2539
2557
|
maxRetries;
|
|
2540
2558
|
maxInputChars;
|
|
2559
|
+
requestTimeoutMs;
|
|
2560
|
+
healthTimeoutMs;
|
|
2541
2561
|
constructor(config) {
|
|
2542
2562
|
this.host = config?.host ?? (process.env.OLLAMA_HOST ?? DEFAULT_OLLAMA_HOST);
|
|
2543
2563
|
this.model = config?.model ?? (process.env.OLLAMA_MODEL ?? DEFAULT_EMBEDDING_MODEL);
|
|
2544
2564
|
this.dimensions = config?.dimensions ?? (Number(process.env.EMBEDDING_DIMENSIONS) || DEFAULT_EMBEDDING_DIMENSIONS);
|
|
2545
2565
|
this.maxRetries = config?.maxRetries ?? 3;
|
|
2546
2566
|
this.maxInputChars = config?.maxInputChars ?? 2e3;
|
|
2567
|
+
this.requestTimeoutMs = config?.requestTimeoutMs ?? 3e4;
|
|
2568
|
+
this.healthTimeoutMs = config?.healthTimeoutMs ?? 1e4;
|
|
2547
2569
|
}
|
|
2548
2570
|
truncateText(text2, maxChars) {
|
|
2549
2571
|
if (text2.length <= maxChars)
|
|
@@ -2590,7 +2612,7 @@ var OllamaEmbeddingClient = class {
|
|
|
2590
2612
|
}
|
|
2591
2613
|
async isHealthy() {
|
|
2592
2614
|
try {
|
|
2593
|
-
const response = await fetch(`${this.host}/api/tags
|
|
2615
|
+
const response = await fetch(`${this.host}/api/tags`, { signal: AbortSignal.timeout(this.healthTimeoutMs) });
|
|
2594
2616
|
return response.ok;
|
|
2595
2617
|
} catch {
|
|
2596
2618
|
return false;
|
|
@@ -2598,7 +2620,7 @@ var OllamaEmbeddingClient = class {
|
|
|
2598
2620
|
}
|
|
2599
2621
|
async isModelAvailable() {
|
|
2600
2622
|
try {
|
|
2601
|
-
const response = await fetch(`${this.host}/api/tags
|
|
2623
|
+
const response = await fetch(`${this.host}/api/tags`, { signal: AbortSignal.timeout(this.healthTimeoutMs) });
|
|
2602
2624
|
if (!response.ok)
|
|
2603
2625
|
return false;
|
|
2604
2626
|
const data = await response.json();
|
|
@@ -2608,20 +2630,43 @@ var OllamaEmbeddingClient = class {
|
|
|
2608
2630
|
}
|
|
2609
2631
|
}
|
|
2610
2632
|
async pullModel() {
|
|
2611
|
-
const
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2633
|
+
const controller = new AbortController();
|
|
2634
|
+
const connectTimer = setTimeout(() => controller.abort(), 3e4);
|
|
2635
|
+
let response;
|
|
2636
|
+
try {
|
|
2637
|
+
response = await fetch(`${this.host}/api/pull`, {
|
|
2638
|
+
method: "POST",
|
|
2639
|
+
headers: { "Content-Type": "application/json" },
|
|
2640
|
+
body: JSON.stringify({ name: this.model }),
|
|
2641
|
+
signal: controller.signal
|
|
2642
|
+
});
|
|
2643
|
+
} finally {
|
|
2644
|
+
clearTimeout(connectTimer);
|
|
2645
|
+
}
|
|
2616
2646
|
if (!response.ok) {
|
|
2617
2647
|
throw new Error(`Failed to pull model ${this.model}: ${response.statusText}`);
|
|
2618
2648
|
}
|
|
2619
2649
|
const reader = response.body?.getReader();
|
|
2620
2650
|
if (reader) {
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2651
|
+
const IDLE_MS = 12e4;
|
|
2652
|
+
try {
|
|
2653
|
+
while (true) {
|
|
2654
|
+
let timer;
|
|
2655
|
+
const idle = new Promise((_, reject) => {
|
|
2656
|
+
timer = setTimeout(() => reject(new Error(`Model pull stalled (no data for ${IDLE_MS / 1e3}s)`)), IDLE_MS);
|
|
2657
|
+
});
|
|
2658
|
+
try {
|
|
2659
|
+
const { done } = await Promise.race([reader.read(), idle]);
|
|
2660
|
+
if (done)
|
|
2661
|
+
break;
|
|
2662
|
+
} finally {
|
|
2663
|
+
clearTimeout(timer);
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
} catch (err) {
|
|
2667
|
+
await reader.cancel().catch(() => {
|
|
2668
|
+
});
|
|
2669
|
+
throw err;
|
|
2625
2670
|
}
|
|
2626
2671
|
}
|
|
2627
2672
|
}
|
|
@@ -2653,7 +2698,7 @@ var OllamaEmbeddingClient = class {
|
|
|
2653
2698
|
let lastError;
|
|
2654
2699
|
for (let attempt = 0; attempt < this.maxRetries; attempt++) {
|
|
2655
2700
|
try {
|
|
2656
|
-
return await fetch(url, init);
|
|
2701
|
+
return await fetch(url, { ...init, signal: init.signal ?? AbortSignal.timeout(this.requestTimeoutMs) });
|
|
2657
2702
|
} catch (error) {
|
|
2658
2703
|
lastError = error instanceof Error ? error : new Error(String(error));
|
|
2659
2704
|
if (attempt < this.maxRetries - 1) {
|
|
@@ -4232,7 +4277,7 @@ function createServer(sdk) {
|
|
|
4232
4277
|
},
|
|
4233
4278
|
WRITE,
|
|
4234
4279
|
async (params) => {
|
|
4235
|
-
const result = sdk.updatePlan(params.planId, { status:
|
|
4280
|
+
const result = sdk.updatePlan(params.planId, { status: KnowledgeStatus.ARCHIVED });
|
|
4236
4281
|
if (!result) return { content: [{ type: "text", text: JSON.stringify({ error: "not_found", type: "plan", id: params.planId }) }] };
|
|
4237
4282
|
return { content: [{ type: "text", text: JSON.stringify({ archived: true, id: result.id, status: result.status }, null, 2) }] };
|
|
4238
4283
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cognistore/mcp-server",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "MCP server for CogniStore — integrates with Claude Code and GitHub Copilot",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"build:deps": "pnpm --filter @cognistore/shared build && pnpm --filter @cognistore/core build && pnpm --filter @cognistore/embeddings build && pnpm --filter @cognistore/sdk build",
|
|
36
36
|
"dev": "tsx src/index.ts",
|
|
37
37
|
"clean": "rm -rf dist",
|
|
38
|
-
"test": "if find . -name '*.test.ts' -o -name '*.spec.ts' | grep -q .; then npx playwright test; else echo 'No tests found, skipping'; fi"
|
|
38
|
+
"test": "if find . -name '*.test.ts' -o -name '*.spec.ts' | grep -q .; then npx playwright test; else echo 'No tests found, skipping'; fi",
|
|
39
|
+
"type-check": "tsc --noEmit"
|
|
39
40
|
}
|
|
40
41
|
}
|