@cognistore/mcp-server 1.0.2 → 1.0.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.
Files changed (2) hide show
  1. package/dist/index.js +50 -74
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1601,88 +1601,64 @@ function createServer(sdk) {
1601
1601
  version: "1.0.0"
1602
1602
  });
1603
1603
  let lastSearchResultIds = [];
1604
- server.tool(
1605
- "addKnowledge",
1606
- "Store a knowledge entry. If you have an active plan, ALWAYS pass planId to auto-link as output.",
1607
- {
1608
- title: z2.string().describe("Short descriptive title"),
1609
- content: z2.string().describe("The knowledge content text"),
1610
- tags: z2.array(z2.string()).describe("Categorical tags for filtering"),
1611
- type: z2.enum(knowledgeTypeValues).describe("Type: decision, pattern, fix, constraint, or gotcha"),
1612
- scope: z2.string().describe('Scope: "global" or "workspace:<project-name>"'),
1613
- source: z2.string().describe("Source of the knowledge"),
1614
- confidenceScore: z2.number().min(0).max(1).optional().describe("Confidence score 0-1"),
1615
- agentId: z2.string().optional().describe("ID of the agent that created this"),
1616
- planId: z2.string().optional().describe("Plan ID to auto-link this knowledge as output. ALWAYS pass this if you have an active plan.")
1617
- },
1618
- WRITE,
1619
- async (params) => {
1620
- const result = await sdk.addKnowledge({
1621
- title: params.title,
1622
- content: params.content,
1623
- tags: params.tags,
1624
- type: params.type,
1625
- scope: params.scope,
1626
- source: params.source,
1627
- confidenceScore: params.confidenceScore,
1628
- agentId: params.agentId
1629
- });
1630
- let linked = false;
1631
- let linkWarning = "";
1632
- if (params.planId && result.type !== "system") {
1633
- try {
1634
- await sdk.addPlanRelation(params.planId, result.id, "output");
1635
- linked = true;
1636
- } catch (e) {
1637
- linkWarning = e instanceof Error ? e.message : "Unknown linking error";
1638
- }
1639
- }
1640
- const response = { entry: result };
1641
- if (params.planId) {
1642
- response.linked = linked;
1643
- response.planId = params.planId;
1644
- if (linkWarning) response.linkWarning = linkWarning;
1604
+ const knowledgeEntrySchema = z2.object({
1605
+ title: z2.string().describe("Short descriptive title"),
1606
+ content: z2.string().describe("The knowledge content text"),
1607
+ tags: z2.array(z2.string()).describe("Categorical tags for filtering"),
1608
+ type: z2.enum(knowledgeTypeValues).describe("Type: decision, pattern, fix, constraint, or gotcha"),
1609
+ scope: z2.string().describe('Scope: "global" or "workspace:<project-name>"'),
1610
+ source: z2.string().describe("Source of the knowledge"),
1611
+ confidenceScore: z2.number().min(0).max(1).optional().describe("Confidence score 0-1"),
1612
+ agentId: z2.string().optional().describe("ID of the agent that created this"),
1613
+ planId: z2.string().optional().describe("Plan ID to auto-link this knowledge as output. ALWAYS pass this if you have an active plan.")
1614
+ });
1615
+ async function createEntry(params) {
1616
+ const entry = await sdk.addKnowledge({
1617
+ title: params.title,
1618
+ content: params.content,
1619
+ tags: params.tags,
1620
+ type: params.type,
1621
+ scope: params.scope,
1622
+ source: params.source,
1623
+ confidenceScore: params.confidenceScore,
1624
+ agentId: params.agentId
1625
+ });
1626
+ let linked = false;
1627
+ let linkWarning = "";
1628
+ if (params.planId && entry.type !== "system") {
1629
+ try {
1630
+ await sdk.addPlanRelation(params.planId, entry.id, "output");
1631
+ linked = true;
1632
+ } catch (e) {
1633
+ linkWarning = e instanceof Error ? e.message : "Unknown linking error";
1645
1634
  }
1646
- return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
1647
1635
  }
1648
- );
1636
+ const result = { entry };
1637
+ if (params.planId) {
1638
+ result.linked = linked;
1639
+ result.planId = params.planId;
1640
+ if (linkWarning) result.linkWarning = linkWarning;
1641
+ }
1642
+ return result;
1643
+ }
1649
1644
  server.tool(
1650
- "addKnowledgeBatch",
1651
- "Create multiple knowledge entries at once. Pass planId per entry for output linking. Reduces tool calls.",
1645
+ "addKnowledge",
1646
+ "Store one or multiple knowledge entries. Pass a single object or an array. If you have an active plan, ALWAYS pass planId to auto-link as output.",
1652
1647
  {
1653
- entries: z2.array(z2.object({
1654
- title: z2.string(),
1655
- content: z2.string(),
1656
- tags: z2.array(z2.string()),
1657
- type: z2.enum(knowledgeTypeValues),
1658
- scope: z2.string(),
1659
- source: z2.string(),
1660
- planId: z2.string().optional()
1661
- })).describe("Array of knowledge entries to create")
1648
+ entries: z2.union([
1649
+ knowledgeEntrySchema,
1650
+ z2.array(knowledgeEntrySchema)
1651
+ ]).describe("A single knowledge entry object, or an array of entries")
1662
1652
  },
1663
1653
  WRITE,
1664
1654
  async (params) => {
1655
+ const items = Array.isArray(params.entries) ? params.entries : [params.entries];
1665
1656
  const results = [];
1666
- for (const e of params.entries) {
1667
- const entry = await sdk.addKnowledge({
1668
- title: e.title,
1669
- content: e.content,
1670
- tags: e.tags,
1671
- type: e.type,
1672
- scope: e.scope,
1673
- source: e.source
1674
- });
1675
- let linked = false;
1676
- let linkWarning = "";
1677
- if (e.planId && entry.type !== "system") {
1678
- try {
1679
- await sdk.addPlanRelation(e.planId, entry.id, "output");
1680
- linked = true;
1681
- } catch (err) {
1682
- linkWarning = err instanceof Error ? err.message : "Unknown linking error";
1683
- }
1684
- }
1685
- results.push({ entry, linked, ...e.planId ? { planId: e.planId } : {}, ...linkWarning ? { linkWarning } : {} });
1657
+ for (const item of items) {
1658
+ results.push(await createEntry(item));
1659
+ }
1660
+ if (results.length === 1) {
1661
+ return { content: [{ type: "text", text: JSON.stringify(results[0], null, 2) }] };
1686
1662
  }
1687
1663
  return { content: [{ type: "text", text: JSON.stringify({ created: results.length, entries: results }, null, 2) }] };
1688
1664
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cognistore/mcp-server",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "MCP server for CogniStore — integrates with Claude Code and GitHub Copilot",