@cognivia/mcp 0.1.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.
- package/README.md +1 -1
- package/package.json +2 -2
- package/server.mjs +72 -16
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @cognivia/mcp
|
|
2
2
|
|
|
3
3
|
A Model Context Protocol server that gives any AI agent Cognivia's learning
|
|
4
|
-
diagnostics as tools: `diagnose_error`, `get_memory_state`, `generate_report
|
|
4
|
+
diagnostics as tools: `diagnose_error`, `get_memory_state`, `generate_report`, and (with a live key) `set_item_misconceptions`, `set_concept_prerequisites` to sharpen diagnosis on your own content.
|
|
5
5
|
|
|
6
6
|
```jsonc
|
|
7
7
|
{ "mcpServers": { "cognivia": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cognivia/mcp",
|
|
3
|
-
"version": "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.
|
|
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,11 @@
|
|
|
4
4
|
// JSON-RPC 2.0 over stdio, which every MCP client speaks.
|
|
5
5
|
//
|
|
6
6
|
// Tools:
|
|
7
|
-
// diagnose_error(subject,
|
|
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
|
+
// set_item_misconceptions(items[]) (live key; sharpens diagnose on your items)
|
|
11
|
+
// set_concept_prerequisites(prerequisites[]) (live key; enables prerequisite_gap)
|
|
10
12
|
//
|
|
11
13
|
// All computed by @cognivia/core - the same engine behind the site, console, CLI.
|
|
12
14
|
//
|
|
@@ -24,26 +26,55 @@ const err = (id, code, message) => send({ jsonrpc: "2.0", id, error: { code, mes
|
|
|
24
26
|
const TOOLS = [
|
|
25
27
|
{
|
|
26
28
|
name: "diagnose_error",
|
|
27
|
-
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.",
|
|
28
30
|
inputSchema: {
|
|
29
31
|
type: "object",
|
|
30
32
|
properties: {
|
|
31
|
-
subject: { type: "string" },
|
|
32
|
-
|
|
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" },
|
|
33
37
|
confidence: { type: "number", description: "1-5 (or 0-100)" },
|
|
34
38
|
},
|
|
35
|
-
required: ["correct"],
|
|
36
39
|
},
|
|
37
40
|
},
|
|
38
41
|
{
|
|
39
42
|
name: "get_memory_state",
|
|
40
|
-
description: "
|
|
41
|
-
inputSchema: { type: "object", properties: {
|
|
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" } } },
|
|
42
45
|
},
|
|
43
46
|
{
|
|
44
47
|
name: "generate_report",
|
|
45
|
-
description: "
|
|
46
|
-
inputSchema: { type: "object", properties: {
|
|
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" } } },
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "set_item_misconceptions",
|
|
53
|
+
description: "Upload item -> misconception maps so diagnose names the misconception behind a wrong answer to YOUR own items. Requires COGNIVIA_API_KEY (a self-serve live key).",
|
|
54
|
+
inputSchema: {
|
|
55
|
+
type: "object",
|
|
56
|
+
properties: {
|
|
57
|
+
items: {
|
|
58
|
+
type: "array",
|
|
59
|
+
description: "[{ item_ref, distractors: { \"the wrong option\": \"the misconception it reveals\" } }]",
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
required: ["items"],
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "set_concept_prerequisites",
|
|
67
|
+
description: "Upload concept -> prerequisite maps so diagnose flags a prerequisite_gap when a learner is weak on a foundation you declared. Requires COGNIVIA_API_KEY (a self-serve live key).",
|
|
68
|
+
inputSchema: {
|
|
69
|
+
type: "object",
|
|
70
|
+
properties: {
|
|
71
|
+
prerequisites: {
|
|
72
|
+
type: "array",
|
|
73
|
+
description: "[{ concept, requires: [\"prerequisite concept\", ...] }]",
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
required: ["prerequisites"],
|
|
77
|
+
},
|
|
47
78
|
},
|
|
48
79
|
];
|
|
49
80
|
|
|
@@ -55,15 +86,25 @@ async function callTool(name, a = {}) {
|
|
|
55
86
|
// When COGNIVIA_API_KEY is set, prefer the hosted /v1 API; else compute locally.
|
|
56
87
|
const remote = client.hasKey();
|
|
57
88
|
if (name === "diagnose_error") {
|
|
58
|
-
|
|
59
|
-
const
|
|
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);
|
|
60
96
|
return textResult({
|
|
61
97
|
errorType: tag.code, label: tag.label,
|
|
62
|
-
memoryState: core.memoryState(
|
|
63
|
-
nextReview: core.reviewFor(tag,
|
|
98
|
+
memoryState: core.memoryState(b), diagnosis: core.diagnosis(b),
|
|
99
|
+
nextReview: core.reviewFor(tag, b.confidence),
|
|
64
100
|
});
|
|
65
101
|
}
|
|
66
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
|
+
}
|
|
67
108
|
const atts = a.attempts || [];
|
|
68
109
|
return textResult({
|
|
69
110
|
genome: core.computeGenome(atts),
|
|
@@ -71,10 +112,25 @@ async function callTool(name, a = {}) {
|
|
|
71
112
|
});
|
|
72
113
|
}
|
|
73
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
|
+
}
|
|
74
121
|
if (remote) { try { const rep = await client.reportRemote(a.attempts || []); return textResult(rep, core.renderText(rep)); } catch (e) { /* fall back */ } }
|
|
75
122
|
const rep = core.buildReport(a.attempts || [], { idPrefix: "CGV-MCP" });
|
|
76
123
|
return textResult(rep, core.renderText(rep));
|
|
77
124
|
}
|
|
125
|
+
// Content maps are remote-only writes to the partner's account (a live key).
|
|
126
|
+
if (name === "set_item_misconceptions") {
|
|
127
|
+
if (!remote) throw new Error("Set COGNIVIA_API_KEY (a self-serve live key) to upload content maps.");
|
|
128
|
+
return textResult(await client.setItemMisconceptions(a.items || []));
|
|
129
|
+
}
|
|
130
|
+
if (name === "set_concept_prerequisites") {
|
|
131
|
+
if (!remote) throw new Error("Set COGNIVIA_API_KEY (a self-serve live key) to upload content maps.");
|
|
132
|
+
return textResult(await client.setConceptPrerequisites(a.prerequisites || []));
|
|
133
|
+
}
|
|
78
134
|
throw new Error("unknown tool: " + name);
|
|
79
135
|
}
|
|
80
136
|
|
|
@@ -90,7 +146,7 @@ rl.on("line", async (line) => {
|
|
|
90
146
|
ok(id, {
|
|
91
147
|
protocolVersion: "2024-11-05",
|
|
92
148
|
capabilities: { tools: {} },
|
|
93
|
-
serverInfo: { name: "cognivia", version: "0.
|
|
149
|
+
serverInfo: { name: "cognivia", version: "0.3.0" },
|
|
94
150
|
});
|
|
95
151
|
} else if (method === "tools/list") {
|
|
96
152
|
ok(id, { tools: TOOLS });
|