@cognistore/mcp-server 0.9.13 → 0.9.14
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 +85 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1510,10 +1510,13 @@ var KnowledgeSDK = class {
|
|
|
1510
1510
|
};
|
|
1511
1511
|
|
|
1512
1512
|
// src/server.ts
|
|
1513
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
1513
|
+
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
1514
1514
|
import { z as z2 } from "zod";
|
|
1515
1515
|
var knowledgeTypeValues = ["decision", "pattern", "fix", "constraint", "gotcha"];
|
|
1516
1516
|
var knowledgeStatusValues = ["draft", "active", "completed", "archived"];
|
|
1517
|
+
var READ_ONLY = { readOnlyHint: true, destructiveHint: false };
|
|
1518
|
+
var WRITE = { readOnlyHint: false, destructiveHint: false };
|
|
1519
|
+
var DESTRUCTIVE = { readOnlyHint: false, destructiveHint: true };
|
|
1517
1520
|
function createServer(sdk) {
|
|
1518
1521
|
const server = new McpServer({
|
|
1519
1522
|
name: "cognistore",
|
|
@@ -1532,6 +1535,7 @@ function createServer(sdk) {
|
|
|
1532
1535
|
confidenceScore: z2.number().min(0).max(1).optional().describe("Confidence score 0-1"),
|
|
1533
1536
|
agentId: z2.string().optional().describe("ID of the agent that created this")
|
|
1534
1537
|
},
|
|
1538
|
+
WRITE,
|
|
1535
1539
|
async (params) => {
|
|
1536
1540
|
const result = await sdk.addKnowledge({
|
|
1537
1541
|
title: params.title,
|
|
@@ -1557,6 +1561,7 @@ function createServer(sdk) {
|
|
|
1557
1561
|
limit: z2.number().optional().describe("Max results (default: 10)"),
|
|
1558
1562
|
threshold: z2.number().optional().describe("Min similarity 0-1 (default: 0.3)")
|
|
1559
1563
|
},
|
|
1564
|
+
READ_ONLY,
|
|
1560
1565
|
async (params) => {
|
|
1561
1566
|
const results = await sdk.getKnowledge(params.query, {
|
|
1562
1567
|
tags: params.tags,
|
|
@@ -1581,6 +1586,7 @@ function createServer(sdk) {
|
|
|
1581
1586
|
source: z2.string().optional().describe("New source"),
|
|
1582
1587
|
confidenceScore: z2.number().min(0).max(1).optional().describe("New confidence score")
|
|
1583
1588
|
},
|
|
1589
|
+
WRITE,
|
|
1584
1590
|
async (params) => {
|
|
1585
1591
|
const { id, ...updates } = params;
|
|
1586
1592
|
const result = await sdk.updateKnowledge(id, {
|
|
@@ -1602,6 +1608,7 @@ function createServer(sdk) {
|
|
|
1602
1608
|
{
|
|
1603
1609
|
id: z2.string().describe("UUID of the knowledge entry to delete")
|
|
1604
1610
|
},
|
|
1611
|
+
DESTRUCTIVE,
|
|
1605
1612
|
async (params) => {
|
|
1606
1613
|
const deleted = await sdk.deleteKnowledge(params.id);
|
|
1607
1614
|
return {
|
|
@@ -1613,6 +1620,7 @@ function createServer(sdk) {
|
|
|
1613
1620
|
"listTags",
|
|
1614
1621
|
"List all unique tags across all knowledge entries.",
|
|
1615
1622
|
{},
|
|
1623
|
+
READ_ONLY,
|
|
1616
1624
|
async () => {
|
|
1617
1625
|
const tags = await sdk.listTags();
|
|
1618
1626
|
return { content: [{ type: "text", text: JSON.stringify(tags) }] };
|
|
@@ -1622,6 +1630,7 @@ function createServer(sdk) {
|
|
|
1622
1630
|
"healthCheck",
|
|
1623
1631
|
"Check health of the knowledge base infrastructure (database, Ollama).",
|
|
1624
1632
|
{},
|
|
1633
|
+
READ_ONLY,
|
|
1625
1634
|
async () => {
|
|
1626
1635
|
const health = await sdk.healthCheck();
|
|
1627
1636
|
return { content: [{ type: "text", text: JSON.stringify(health, null, 2) }] };
|
|
@@ -1642,6 +1651,7 @@ function createServer(sdk) {
|
|
|
1642
1651
|
priority: z2.enum(["low", "medium", "high"]).optional()
|
|
1643
1652
|
})).optional().describe("Initial tasks for the plan todo list")
|
|
1644
1653
|
},
|
|
1654
|
+
WRITE,
|
|
1645
1655
|
async (params) => {
|
|
1646
1656
|
const result = await sdk.createPlan({
|
|
1647
1657
|
title: params.title,
|
|
@@ -1667,6 +1677,7 @@ function createServer(sdk) {
|
|
|
1667
1677
|
status: z2.enum(knowledgeStatusValues).optional().describe("New status"),
|
|
1668
1678
|
source: z2.string().optional().describe("New source")
|
|
1669
1679
|
},
|
|
1680
|
+
WRITE,
|
|
1670
1681
|
async (params) => {
|
|
1671
1682
|
const { planId, ...updates } = params;
|
|
1672
1683
|
const result = sdk.updatePlan(planId, updates);
|
|
@@ -1682,6 +1693,7 @@ function createServer(sdk) {
|
|
|
1682
1693
|
knowledgeId: z2.string().describe("UUID of the knowledge entry to link"),
|
|
1683
1694
|
relationType: z2.enum(["input", "output"]).describe('"input" = consulted during planning, "output" = created/updated during execution')
|
|
1684
1695
|
},
|
|
1696
|
+
WRITE,
|
|
1685
1697
|
async (params) => {
|
|
1686
1698
|
sdk.addPlanRelation(params.planId, params.knowledgeId, params.relationType);
|
|
1687
1699
|
return { content: [{ type: "text", text: JSON.stringify({ success: true, ...params }) }] };
|
|
@@ -1696,6 +1708,7 @@ function createServer(sdk) {
|
|
|
1696
1708
|
priority: z2.enum(["low", "medium", "high"]).optional().describe("Priority (default: medium)"),
|
|
1697
1709
|
notes: z2.string().optional().describe("Optional notes")
|
|
1698
1710
|
},
|
|
1711
|
+
WRITE,
|
|
1699
1712
|
async (params) => {
|
|
1700
1713
|
const task = sdk.createPlanTask(params);
|
|
1701
1714
|
return { content: [{ type: "text", text: JSON.stringify(task, null, 2) }] };
|
|
@@ -1711,6 +1724,7 @@ function createServer(sdk) {
|
|
|
1711
1724
|
priority: z2.enum(["low", "medium", "high"]).optional().describe("New priority"),
|
|
1712
1725
|
notes: z2.string().nullable().optional().describe("Notes about progress or blockers")
|
|
1713
1726
|
},
|
|
1727
|
+
WRITE,
|
|
1714
1728
|
async (params) => {
|
|
1715
1729
|
const { taskId, ...updates } = params;
|
|
1716
1730
|
const task = sdk.updatePlanTask(taskId, updates);
|
|
@@ -1724,11 +1738,81 @@ function createServer(sdk) {
|
|
|
1724
1738
|
{
|
|
1725
1739
|
planId: z2.string().describe("UUID of the plan")
|
|
1726
1740
|
},
|
|
1741
|
+
READ_ONLY,
|
|
1727
1742
|
async (params) => {
|
|
1728
1743
|
const tasks = sdk.listPlanTasks(params.planId);
|
|
1729
1744
|
return { content: [{ type: "text", text: JSON.stringify(tasks, null, 2) }] };
|
|
1730
1745
|
}
|
|
1731
1746
|
);
|
|
1747
|
+
server.resource(
|
|
1748
|
+
"knowledge-context",
|
|
1749
|
+
new ResourceTemplate("cognistore://context/{scope}", { list: void 0 }),
|
|
1750
|
+
{ description: "Workspace-scoped knowledge base context with recent entries and active plans" },
|
|
1751
|
+
async (uri, variables) => {
|
|
1752
|
+
const scope = variables.scope || "global";
|
|
1753
|
+
const scopeFilter = scope === "global" ? void 0 : `workspace:${scope}`;
|
|
1754
|
+
let knowledgeSection = "";
|
|
1755
|
+
try {
|
|
1756
|
+
const results = await sdk.getKnowledge("*", {
|
|
1757
|
+
scope: scopeFilter,
|
|
1758
|
+
limit: 10,
|
|
1759
|
+
threshold: 0
|
|
1760
|
+
});
|
|
1761
|
+
if (results.length > 0) {
|
|
1762
|
+
knowledgeSection = "## Recent Knowledge\n\n" + results.map(
|
|
1763
|
+
(r) => `- **${r.entry.title}** (${r.entry.type}, ${r.entry.scope})
|
|
1764
|
+
${r.entry.content.slice(0, 200)}${r.entry.content.length > 200 ? "..." : ""}`
|
|
1765
|
+
).join("\n\n");
|
|
1766
|
+
} else {
|
|
1767
|
+
knowledgeSection = "## Recent Knowledge\n\nNo entries found for this scope.";
|
|
1768
|
+
}
|
|
1769
|
+
} catch {
|
|
1770
|
+
knowledgeSection = "## Recent Knowledge\n\nUnable to fetch entries.";
|
|
1771
|
+
}
|
|
1772
|
+
let plansSection = "";
|
|
1773
|
+
try {
|
|
1774
|
+
const plans = sdk.listPlans(10, "active");
|
|
1775
|
+
const scopedPlans = scopeFilter ? plans.filter((p) => p.scope === scopeFilter || p.scope === "global") : plans;
|
|
1776
|
+
if (scopedPlans.length > 0) {
|
|
1777
|
+
const planEntries = scopedPlans.map((p) => {
|
|
1778
|
+
const tasks = sdk.listPlanTasks(p.id);
|
|
1779
|
+
const completed = tasks.filter((t) => t.status === "completed").length;
|
|
1780
|
+
return `- **${p.title}** (${p.status}, ${completed}/${tasks.length} tasks done)
|
|
1781
|
+
${p.content.slice(0, 150)}${p.content.length > 150 ? "..." : ""}`;
|
|
1782
|
+
});
|
|
1783
|
+
plansSection = "## Active Plans\n\n" + planEntries.join("\n\n");
|
|
1784
|
+
} else {
|
|
1785
|
+
plansSection = "## Active Plans\n\nNo active plans for this scope.";
|
|
1786
|
+
}
|
|
1787
|
+
} catch {
|
|
1788
|
+
plansSection = "## Active Plans\n\nUnable to fetch plans.";
|
|
1789
|
+
}
|
|
1790
|
+
let tagsSection = "";
|
|
1791
|
+
try {
|
|
1792
|
+
const tags = await sdk.listTags();
|
|
1793
|
+
if (tags.length > 0) {
|
|
1794
|
+
tagsSection = `## Tags
|
|
1795
|
+
|
|
1796
|
+
${tags.slice(0, 20).join(", ")}`;
|
|
1797
|
+
}
|
|
1798
|
+
} catch {
|
|
1799
|
+
}
|
|
1800
|
+
const content = `# CogniStore Context \u2014 ${scope}
|
|
1801
|
+
|
|
1802
|
+
${knowledgeSection}
|
|
1803
|
+
|
|
1804
|
+
${plansSection}
|
|
1805
|
+
|
|
1806
|
+
${tagsSection}`.trim();
|
|
1807
|
+
return {
|
|
1808
|
+
contents: [{
|
|
1809
|
+
uri: uri.href,
|
|
1810
|
+
text: content,
|
|
1811
|
+
mimeType: "text/markdown"
|
|
1812
|
+
}]
|
|
1813
|
+
};
|
|
1814
|
+
}
|
|
1815
|
+
);
|
|
1732
1816
|
return server;
|
|
1733
1817
|
}
|
|
1734
1818
|
|