@cognivia/mcp 0.2.0 → 0.3.0

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/package.json +2 -2
  2. package/server.mjs +33 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cognivia/mcp",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Model Context Protocol server for Cognivia. Gives any AI agent learning diagnostics (error type, memory state, session report) as callable tools.",
5
5
  "type": "module",
6
6
  "bin": { "cognivia-mcp": "server.mjs" },
@@ -10,7 +10,7 @@
10
10
  "homepage": "https://cognivia-platform.vercel.app/intelligence",
11
11
  "repository": { "type": "git", "url": "git+https://github.com/Manik-Maurya/cognivia-platform.git", "directory": "packages/mcp" },
12
12
  "engines": { "node": ">=18" },
13
- "dependencies": { "@cognivia/core": "^0.2.0" },
13
+ "dependencies": { "@cognivia/core": "^0.3.0" },
14
14
  "publishConfig": { "access": "public" },
15
15
  "license": "MIT",
16
16
  "author": "Manik Maurya"
package/server.mjs CHANGED
@@ -4,9 +4,9 @@
4
4
  // JSON-RPC 2.0 over stdio, which every MCP client speaks.
5
5
  //
6
6
  // Tools:
7
- // diagnose_error(subject, question, answer, correct, latencyMs, confidence)
8
- // get_memory_state(attempts[])
9
- // generate_report(attempts[])
7
+ // diagnose_error(subject|concept, correct|outcome, latencyMs|latency, confidence)
8
+ // get_memory_state(learner_ref) real stored state (live key), or attempts[] (local)
9
+ // generate_report(learner_ref) render stored state (live key), or attempts[] (local)
10
10
  // set_item_misconceptions(items[]) (live key; sharpens diagnose on your items)
11
11
  // set_concept_prerequisites(prerequisites[]) (live key; enables prerequisite_gap)
12
12
  //
@@ -26,26 +26,27 @@ const err = (id, code, message) => send({ jsonrpc: "2.0", id, error: { code, mes
26
26
  const TOOLS = [
27
27
  {
28
28
  name: "diagnose_error",
29
- description: "Diagnose one answered item: the error type, memory state, and next review, each grounded in memory science.",
29
+ description: "Diagnose one answered item: the error type, memory state, and next review, each grounded in memory science. Accepts correct (bool) OR outcome ('correct'/'wrong'); latencyMs OR latency; subject OR concept.",
30
30
  inputSchema: {
31
31
  type: "object",
32
32
  properties: {
33
- subject: { type: "string" }, question: { type: "string" }, answer: { type: "string" },
34
- correct: { type: "boolean" }, latencyMs: { type: "number" },
33
+ subject: { type: "string" }, concept: { type: "string" },
34
+ question: { type: "string" }, answer: { type: "string" },
35
+ correct: { type: "boolean" }, outcome: { type: "string" },
36
+ latencyMs: { type: "number" }, latency: { type: "number" },
35
37
  confidence: { type: "number", description: "1-5 (or 0-100)" },
36
38
  },
37
- required: ["correct"],
38
39
  },
39
40
  },
40
41
  {
41
42
  name: "get_memory_state",
42
- description: "Compute the Learning Genome and per-item memory state for a set of attempts from any learning or quiz app.",
43
- inputSchema: { type: "object", properties: { attempts: { type: "array" } }, required: ["attempts"] },
43
+ description: "A learner's memory state. Pass learner_ref to READ their real stored state (needs a live COGNIVIA_API_KEY): per-concept decay, retrieval, and next review. Or pass attempts[] to compute a Learning Genome locally, no key needed.",
44
+ inputSchema: { type: "object", properties: { learner_ref: { type: "string" }, attempts: { type: "array" } } },
44
45
  },
45
46
  {
46
47
  name: "generate_report",
47
- description: "Build a full Cognivia Session Report (Learning Genome, per-item diagnosis, recommendation) from a set of attempts.",
48
- inputSchema: { type: "object", properties: { attempts: { type: "array" } }, required: ["attempts"] },
48
+ description: "A readable Cognivia report. Pass learner_ref to render their stored memory state as a Cognitive Passport (needs a live key). Or pass attempts[] to build a Session Report locally.",
49
+ inputSchema: { type: "object", properties: { learner_ref: { type: "string" }, attempts: { type: "array" } } },
49
50
  },
50
51
  {
51
52
  name: "set_item_misconceptions",
@@ -85,15 +86,25 @@ async function callTool(name, a = {}) {
85
86
  // When COGNIVIA_API_KEY is set, prefer the hosted /v1 API; else compute locally.
86
87
  const remote = client.hasKey();
87
88
  if (name === "diagnose_error") {
88
- if (remote) { try { return textResult(await client.diagnoseRemote(a)); } catch (e) { /* fall back */ } }
89
- const tag = core.classify(!!a.correct, a.confidence);
89
+ // Accept the friendly aliases the Developers page shows.
90
+ const b = { ...a };
91
+ if (b.correct === undefined && b.outcome !== undefined) b.correct = /^(correct|right|true|1|yes)$/i.test(String(b.outcome));
92
+ if (b.latencyMs === undefined && b.latency !== undefined) b.latencyMs = b.latency;
93
+ if (b.subject === undefined && b.concept !== undefined) b.subject = b.concept;
94
+ if (remote) { try { return textResult(await client.diagnoseRemote(b)); } catch (e) { /* fall back */ } }
95
+ const tag = core.classify(!!b.correct, b.confidence);
90
96
  return textResult({
91
97
  errorType: tag.code, label: tag.label,
92
- memoryState: core.memoryState(a), diagnosis: core.diagnosis(a),
93
- nextReview: core.reviewFor(tag, a.confidence),
98
+ memoryState: core.memoryState(b), diagnosis: core.diagnosis(b),
99
+ nextReview: core.reviewFor(tag, b.confidence),
94
100
  });
95
101
  }
96
102
  if (name === "get_memory_state") {
103
+ // learner_ref → real stored state (remote); attempts[] → local compute.
104
+ if (a.learner_ref) {
105
+ if (!remote) throw new Error("get_memory_state(learner_ref) needs COGNIVIA_API_KEY (a live key). Pass attempts[] to compute locally.");
106
+ return textResult(await client.memoryStateRemote(a.learner_ref));
107
+ }
97
108
  const atts = a.attempts || [];
98
109
  return textResult({
99
110
  genome: core.computeGenome(atts),
@@ -101,6 +112,12 @@ async function callTool(name, a = {}) {
101
112
  });
102
113
  }
103
114
  if (name === "generate_report") {
115
+ // learner_ref → render their stored memory state (remote); attempts[] → local Session Report.
116
+ if (a.learner_ref) {
117
+ if (!remote) throw new Error("generate_report(learner_ref) needs COGNIVIA_API_KEY (a live key). Pass attempts[] to build locally.");
118
+ const st = await client.memoryStateRemote(a.learner_ref);
119
+ return textResult(st, client.renderMemoryState(st));
120
+ }
104
121
  if (remote) { try { const rep = await client.reportRemote(a.attempts || []); return textResult(rep, core.renderText(rep)); } catch (e) { /* fall back */ } }
105
122
  const rep = core.buildReport(a.attempts || [], { idPrefix: "CGV-MCP" });
106
123
  return textResult(rep, core.renderText(rep));
@@ -129,7 +146,7 @@ rl.on("line", async (line) => {
129
146
  ok(id, {
130
147
  protocolVersion: "2024-11-05",
131
148
  capabilities: { tools: {} },
132
- serverInfo: { name: "cognivia", version: "0.2.0" },
149
+ serverInfo: { name: "cognivia", version: "0.3.0" },
133
150
  });
134
151
  } else if (method === "tools/list") {
135
152
  ok(id, { tools: TOOLS });