@nbiish/cognitive-tools-mcp 8.5.1 → 8.6.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/README.md +39 -12
- package/build/index.js +231 -244
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -24,21 +24,48 @@
|
|
|
24
24
|
|
|
25
25
|
## ᐴ GASHKITOONAN ᔔ [CAPABILITIES] ◈──◆──◇──◆──◈
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
# ᐊᓂᔑᓈᐯ Cyberpunk Cognitive Deliberation MCP Server
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
> **Interactive Multi-Phase Cognitive Processing MCP Server** - Forces LLMs through 3-input deliberation phases for comprehensive 6-stage cognitive enhancement. Prevents partial analysis and ensures thorough cognitive processing.
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
## 🧠 Revolutionary Interactive Cognitive Framework
|
|
32
32
|
|
|
33
|
-
**
|
|
34
|
-
1. **Stage 1**: Scientific Investigation (Entry Point)
|
|
35
|
-
2. **Stage 2**: Initial OOReD Analysis
|
|
33
|
+
This MCP server implements an **interactive session-based deliberation process** that forces LLMs through multiple required inputs to ensure comprehensive cognitive analysis. Unlike traditional single-call tools, this system **prevents partial analysis** by requiring LLMs to engage in iterative deliberation.
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
### 🎯 Interactive Session Flow
|
|
36
|
+
|
|
37
|
+
**CRITICAL:** This tool follows a mandatory 3-input deliberation process:
|
|
38
|
+
|
|
39
|
+
1. **Initial Input** → Stages 1-2 processing → Request second input
|
|
40
|
+
2. **Second Input** → Stages 3-6 processing → Request third input
|
|
41
|
+
3. **Third Input** → Final formatting → Return comprehensive result
|
|
42
|
+
|
|
43
|
+
### 🚀 Key Features
|
|
44
|
+
|
|
45
|
+
- **Forces Iterative Thinking:** Prevents LLMs from stopping after partial deliberation
|
|
46
|
+
- **Session-Based Processing:** Maintains context across multiple inputs
|
|
47
|
+
- **Comprehensive 6-Stage Framework:** Scientific Investigation + OOReD Analysis + Critical Thinking + Reviews + Final Action
|
|
48
|
+
- **Tool Usage Tracking:** Returns actionable tool recommendations with usage counts
|
|
49
|
+
- **Low-Context Model Friendly:** Optimal for models requiring guided interaction
|
|
50
|
+
- **Advanced Prompting Integration:** CoT, ToT, Self-Consistency, Meta-Prompting, Role-Based strategies
|
|
51
|
+
|
|
52
|
+
### ⚡ INTERNAL 6-STAGE PROCESSING
|
|
53
|
+
|
|
54
|
+
**NEW v8.6.0**: The MCP server now automatically processes all stages internally in a single tool call:
|
|
55
|
+
|
|
56
|
+
**All Stages Processed Internally:**
|
|
57
|
+
1. **Stage 1**: Scientific Investigation (Chain-of-Thought + Role-Based)
|
|
58
|
+
2. **Stage 2**: Initial OOReD Analysis (Tree-of-Thoughts + Meta-Prompting)
|
|
59
|
+
3. **Stage 3**: Critical Thinking & Pre-Action Planning (Self-Consistency + Meta-Prompting)
|
|
60
|
+
4. **Stage 4**: Scientific Review & Validation (Chain-of-Thought + Self-Consistency)
|
|
61
|
+
5. **Stage 5**: OOReD Review & Refinement (Tree-of-Thoughts + Role-Based)
|
|
62
|
+
6. **Stage 6**: Final Action & Recommendations (All strategies integrated)
|
|
63
|
+
|
|
64
|
+
**Benefits:**
|
|
65
|
+
- ✅ Single tool call processes all stages
|
|
66
|
+
- ✅ Comprehensive cognitive analysis
|
|
67
|
+
- ✅ Advanced prompting strategies integrated
|
|
68
|
+
- ✅ No manual phase progression required
|
|
42
69
|
|
|
43
70
|
<div align="center">
|
|
44
71
|
◈──◆──◇───────────────────────────◇──◆──◈
|
|
@@ -226,7 +253,7 @@ This project is licensed under the Comprehensive Restricted Use License for Indi
|
|
|
226
253
|
```bibtex
|
|
227
254
|
@misc{gikendaasowin-aabajichiganan-mcp2025,
|
|
228
255
|
author/creator/steward = {ᓂᐲᔥ ᐙᐸᓂᒥᑮ-ᑭᓇᐙᐸᑭᓯ (Nbiish Waabanimikii-Kinawaabakizi), also known legally as JUSTIN PAUL KENWABIKISE, professionally documented as Nbiish-Justin Paul Kenwabikise, Anishinaabek Dodem (Anishinaabe Clan): Animikii (Thunder), descendant of Chief ᑭᓇᐙᐸᑭᓯ (Kinwaabakizi) of the Beaver Island Band and enrolled member of the sovereign Grand Traverse Band of Ottawa and Chippewa Indians},
|
|
229
|
-
title/description = {
|
|
256
|
+
title/description = {Enhanced Cognitive Processing MCP Server - Automatically processes all 6 cognitive stages internally with advanced prompting strategies},
|
|
230
257
|
type_of_work = {Indigenous digital creation/software incorporating traditional knowledge and cultural expressions},
|
|
231
258
|
year = {2025},
|
|
232
259
|
publisher/source/event = {GitHub repository under tribal sovereignty protections},
|
package/build/index.js
CHANGED
|
@@ -25,45 +25,10 @@ import { z } from "zod";
|
|
|
25
25
|
// --- Server Definition ---
|
|
26
26
|
const serverInfo = {
|
|
27
27
|
name: "gikendaasowin-aabajichiganan-mcp",
|
|
28
|
-
version: "8.
|
|
29
|
-
description: "
|
|
28
|
+
version: "8.6.2",
|
|
29
|
+
description: "Interactive Multi-Phase Cognitive Processing MCP Server - Forces LLMs through 3-input deliberation phases for comprehensive 6-stage cognitive enhancement. Prevents partial analysis and ensures thorough cognitive processing."
|
|
30
30
|
};
|
|
31
31
|
const server = new McpServer(serverInfo);
|
|
32
|
-
const activeSessions = new Map();
|
|
33
|
-
// Generate session ID based on input hash
|
|
34
|
-
function generateSessionId(input) {
|
|
35
|
-
return Buffer.from(input).toString('base64').slice(0, 12);
|
|
36
|
-
}
|
|
37
|
-
// Validate and enforce mandatory two-phase progression
|
|
38
|
-
function validateMandatoryProgression(input, phase, previous_results) {
|
|
39
|
-
const sessionId = generateSessionId(input);
|
|
40
|
-
const phaseNum = parseInt(phase.replace('phase', ''));
|
|
41
|
-
if (phaseNum === 1) {
|
|
42
|
-
// Starting new session - always allowed
|
|
43
|
-
const session = {
|
|
44
|
-
sessionId,
|
|
45
|
-
currentPhase: 1,
|
|
46
|
-
originalInput: input,
|
|
47
|
-
phaseResults: [],
|
|
48
|
-
toolUsageCount: 0,
|
|
49
|
-
startTime: Date.now()
|
|
50
|
-
};
|
|
51
|
-
activeSessions.set(sessionId, session);
|
|
52
|
-
return { sessionId, isValid: true, currentPhase: 1 };
|
|
53
|
-
}
|
|
54
|
-
const existingSession = activeSessions.get(sessionId);
|
|
55
|
-
if (!existingSession) {
|
|
56
|
-
throw new Error(`MANDATORY PROGRESSION VIOLATION: Phase ${phase} attempted without starting from Phase 1. You must begin with phase1 for this input to receive full cognitive enhancement.`);
|
|
57
|
-
}
|
|
58
|
-
const expectedPhase = existingSession.currentPhase + 1;
|
|
59
|
-
if (phaseNum !== expectedPhase) {
|
|
60
|
-
throw new Error(`MANDATORY PROGRESSION VIOLATION: Expected phase${expectedPhase}, but received ${phase}. Sequential progression required: phase1 → phase2`);
|
|
61
|
-
}
|
|
62
|
-
if (!previous_results) {
|
|
63
|
-
throw new Error(`Phase ${phase} requires previous_results parameter containing all accumulated results from phase 1.`);
|
|
64
|
-
}
|
|
65
|
-
return { sessionId, isValid: true, currentPhase: phaseNum };
|
|
66
|
-
}
|
|
67
32
|
// --- Logging Helpers (Internal - No changes needed as per user comments) ---
|
|
68
33
|
/**
|
|
69
34
|
* Logs an incoming tool call to stderr.
|
|
@@ -1271,236 +1236,258 @@ function assessLogicalCoherence(stage1Result, stage3Result) {
|
|
|
1271
1236
|
function assessMethodologicalRigor(stage1Result) {
|
|
1272
1237
|
return "High rigor - systematic approach with appropriate controls";
|
|
1273
1238
|
}
|
|
1274
|
-
//
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
*
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1239
|
+
// In-memory session storage (replace with persistent storage in production)
|
|
1240
|
+
const activeSessions = new Map();
|
|
1241
|
+
// Clean up old sessions (older than 1 hour)
|
|
1242
|
+
setInterval(() => {
|
|
1243
|
+
const oneHourAgo = Date.now() - (60 * 60 * 1000);
|
|
1244
|
+
for (const [sessionId, session] of activeSessions.entries()) {
|
|
1245
|
+
if (session.createdAt < oneHourAgo) {
|
|
1246
|
+
activeSessions.delete(sessionId);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
}, 10 * 60 * 1000); // Check every 10 minutes
|
|
1250
|
+
function generateSessionId() {
|
|
1251
|
+
return `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
1252
|
+
}
|
|
1253
|
+
// --- Interactive Session Handlers ---
|
|
1254
|
+
async function handlePhase1(session, userInput) {
|
|
1255
|
+
// Process Stages 1-2 (Scientific Investigation + Initial OOReD)
|
|
1256
|
+
const stage1 = await performScientificInvestigation(userInput, session.mode, session.context);
|
|
1257
|
+
const stage2 = await performInitialOOReD(userInput, session.mode, session.context, stage1);
|
|
1258
|
+
const stage1_2_results = `## STAGE 1: SCIENTIFIC INVESTIGATION
|
|
1259
|
+
${stage1}
|
|
1260
|
+
|
|
1261
|
+
## STAGE 2: INITIAL OBSERVE-ORIENT-REASON-DECIDE
|
|
1262
|
+
${stage2}`;
|
|
1263
|
+
session.stage1_2_results = stage1_2_results;
|
|
1264
|
+
session.phase = "awaiting_input_2";
|
|
1265
|
+
session.toolUsageCount += countToolsInStage(stage1) + countToolsInStage(stage2);
|
|
1266
|
+
activeSessions.set(session.sessionId, session);
|
|
1267
|
+
const promptForNextInput = `# 🧠 COGNITIVE ENHANCEMENT: Phase 1 Complete (Stages 1-2)
|
|
1268
|
+
|
|
1269
|
+
${stage1_2_results}
|
|
1270
|
+
|
|
1271
|
+
---
|
|
1272
|
+
|
|
1273
|
+
**⚠️ CONTINUE DELIBERATION REQUIRED ⚠️**
|
|
1274
|
+
|
|
1275
|
+
The cognitive framework requires your **SECOND INPUT** to complete stages 3-6. Please call this deliberation tool again with:
|
|
1276
|
+
|
|
1277
|
+
- **Your refined perspective** based on the analysis above
|
|
1278
|
+
- **Additional context** you want to incorporate
|
|
1279
|
+
- **Specific focus areas** for deeper investigation
|
|
1280
|
+
|
|
1281
|
+
**Required parameters for continuation:**
|
|
1282
|
+
\`\`\`json
|
|
1283
|
+
{
|
|
1284
|
+
"input": "[Your second input based on the analysis above]",
|
|
1285
|
+
"session_id": "${session.sessionId}"
|
|
1286
|
+
}
|
|
1287
|
+
\`\`\`
|
|
1288
|
+
|
|
1289
|
+
**Progress:** 2 of 6 stages complete | **Continuing session:** \`${session.sessionId}\``;
|
|
1290
|
+
logToolResult('deliberate', true, `Phase 1 complete, awaiting second input for session ${session.sessionId}`);
|
|
1291
|
+
return {
|
|
1292
|
+
content: [{
|
|
1293
|
+
type: "text",
|
|
1294
|
+
text: promptForNextInput
|
|
1295
|
+
}]
|
|
1296
|
+
};
|
|
1297
|
+
}
|
|
1298
|
+
async function handlePhase2(session, userInput) {
|
|
1299
|
+
if (!session.stage1_2_results) {
|
|
1300
|
+
throw new Error("Invalid session state: missing stage 1-2 results");
|
|
1301
|
+
}
|
|
1302
|
+
// Process Stages 3-6 using both original input and new refined input
|
|
1303
|
+
const combinedInput = `${session.originalInput}\n\n[REFINED INPUT FROM PHASE 1]\n${userInput}`;
|
|
1304
|
+
const combinedContext = session.context ? `${session.context}\n\n[CONTEXT FROM STAGES 1-2]\n${session.stage1_2_results}` : session.stage1_2_results;
|
|
1305
|
+
const stage3 = await performCriticalThinkingPreAct(combinedInput, session.mode, combinedContext, "", "");
|
|
1306
|
+
const stage4 = await performScientificReview(combinedInput, session.mode, combinedContext, "", stage3);
|
|
1307
|
+
const stage5 = await performOOReViewReview(combinedInput, session.mode, combinedContext, "", stage4);
|
|
1308
|
+
const stage6 = await performFinalAct(combinedInput, session.mode, combinedContext, stage3, stage5);
|
|
1309
|
+
const stage3_6_results = `## STAGE 3: CRITICAL THINKING & PRE-ACTION PLANNING
|
|
1310
|
+
${stage3}
|
|
1311
|
+
|
|
1312
|
+
## STAGE 4: SCIENTIFIC REVIEW & VALIDATION
|
|
1313
|
+
${stage4}
|
|
1314
|
+
|
|
1315
|
+
## STAGE 5: OOReD REVIEW & REFINEMENT
|
|
1316
|
+
${stage5}
|
|
1317
|
+
|
|
1318
|
+
## STAGE 6: FACT-BASED ACTION & FINAL RECOMMENDATIONS
|
|
1319
|
+
${stage6}`;
|
|
1320
|
+
session.stage3_6_results = stage3_6_results;
|
|
1321
|
+
session.phase = "awaiting_input_3";
|
|
1322
|
+
session.toolUsageCount += countToolsInStage(stage3) + countToolsInStage(stage4) + countToolsInStage(stage5) + countToolsInStage(stage6);
|
|
1323
|
+
activeSessions.set(session.sessionId, session);
|
|
1324
|
+
const promptForFinalInput = `# 🧠 COGNITIVE ENHANCEMENT: Phase 2 Complete (Stages 3-6)
|
|
1325
|
+
|
|
1326
|
+
${stage3_6_results}
|
|
1327
|
+
|
|
1328
|
+
---
|
|
1329
|
+
|
|
1330
|
+
**⚠️ FINAL CONFIRMATION REQUIRED ⚠️**
|
|
1331
|
+
|
|
1332
|
+
The 6-stage cognitive deliberation is complete. Please provide a **FINAL INPUT** to:
|
|
1333
|
+
|
|
1334
|
+
- **Confirm** the recommendations are suitable
|
|
1335
|
+
- **Refine** any specific aspects
|
|
1336
|
+
- **Add** final considerations
|
|
1337
|
+
- **Proceed** with implementation planning
|
|
1338
|
+
|
|
1339
|
+
**Required parameters for final output:**
|
|
1340
|
+
\`\`\`json
|
|
1341
|
+
{
|
|
1342
|
+
"input": "[Your final confirmation/refinement]",
|
|
1343
|
+
"session_id": "${session.sessionId}"
|
|
1344
|
+
}
|
|
1345
|
+
\`\`\`
|
|
1346
|
+
|
|
1347
|
+
**Progress:** 6 of 6 stages complete | **Final step:** \`${session.sessionId}\``;
|
|
1348
|
+
logToolResult('deliberate', true, `Phase 2 complete, awaiting final input for session ${session.sessionId}`);
|
|
1349
|
+
return {
|
|
1350
|
+
content: [{
|
|
1351
|
+
type: "text",
|
|
1352
|
+
text: promptForFinalInput
|
|
1353
|
+
}]
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1356
|
+
async function handlePhase3(session, userInput) {
|
|
1357
|
+
if (!session.stage1_2_results || !session.stage3_6_results) {
|
|
1358
|
+
throw new Error("Invalid session state: missing previous stage results");
|
|
1359
|
+
}
|
|
1360
|
+
// Final output with complete deliberation results
|
|
1361
|
+
const finalOutput = `# 🎯 ENHANCED COGNITIVE DELIBERATION - COMPLETE ANALYSIS
|
|
1362
|
+
|
|
1363
|
+
## COMPREHENSIVE 6-STAGE COGNITIVE FRAMEWORK RESULTS
|
|
1364
|
+
|
|
1365
|
+
${session.stage1_2_results}
|
|
1366
|
+
|
|
1367
|
+
${session.stage3_6_results}
|
|
1368
|
+
|
|
1369
|
+
---
|
|
1370
|
+
|
|
1371
|
+
## 🔧 IMPLEMENTATION ROADMAP
|
|
1372
|
+
|
|
1373
|
+
Based on the comprehensive analysis, proceed with these **prioritized actions**:
|
|
1374
|
+
|
|
1375
|
+
### Phase 1: Immediate Actions
|
|
1376
|
+
- **File Operations**: Use \`create_file\`, \`replace_string_in_file\`, \`read_file\` for implementation
|
|
1377
|
+
- **Research**: Leverage \`mcp_tavily-remote_tavily_search\`, \`vscode_websearchforcopilot_webSearch\` for validation
|
|
1378
|
+
- **Code Analysis**: Apply \`semantic_search\`, \`grep_search\`, \`list_code_usages\` for optimization
|
|
1379
|
+
|
|
1380
|
+
### Phase 2: Development Execution
|
|
1381
|
+
- **Terminal Operations**: Execute with \`run_in_terminal\`, \`create_and_run_task\`
|
|
1382
|
+
- **Quality Assurance**: Validate using \`get_errors\`, \`test_search\`
|
|
1383
|
+
- **Documentation**: Update with \`edit_notebook_file\`, \`create_directory\`
|
|
1384
|
+
|
|
1385
|
+
### Phase 3: Validation & Refinement
|
|
1386
|
+
- **Testing**: Comprehensive testing protocols
|
|
1387
|
+
- **Review**: Peer review and expert consultation
|
|
1388
|
+
- **Optimization**: Performance and efficiency improvements
|
|
1389
|
+
|
|
1390
|
+
---
|
|
1391
|
+
|
|
1392
|
+
**Final Confirmation:** ${userInput}
|
|
1393
|
+
|
|
1394
|
+
\`\`\`tool use before re-deliberation: ${session.toolUsageCount}\`\`\`
|
|
1395
|
+
|
|
1396
|
+
*Enhanced 6-Stage Cognitive Framework Complete | Processing Mode: ${session.mode} | Session: ${session.sessionId}*
|
|
1397
|
+
*Prompting Strategies Applied: CoT, ToT, Self-Consistency, Meta-Prompting, Role-Based*`;
|
|
1398
|
+
// Mark session as complete and schedule cleanup
|
|
1399
|
+
session.phase = "complete";
|
|
1400
|
+
activeSessions.set(session.sessionId, session);
|
|
1401
|
+
// Clean up completed session after 5 minutes
|
|
1402
|
+
setTimeout(() => {
|
|
1403
|
+
activeSessions.delete(session.sessionId);
|
|
1404
|
+
}, 5 * 60 * 1000);
|
|
1405
|
+
logToolResult('deliberate', true, `Complete deliberation session ${session.sessionId} with ${session.toolUsageCount} tool recommendations`);
|
|
1406
|
+
return {
|
|
1407
|
+
content: [{
|
|
1408
|
+
type: "text",
|
|
1409
|
+
text: finalOutput
|
|
1410
|
+
}]
|
|
1411
|
+
};
|
|
1412
|
+
}
|
|
1413
|
+
// --- MCP Tool Registration ---
|
|
1339
1414
|
/**
|
|
1340
|
-
*
|
|
1415
|
+
* CRITICAL: Interactive Multi-Input Cognitive Deliberation Tool
|
|
1341
1416
|
*
|
|
1342
|
-
*
|
|
1343
|
-
*
|
|
1344
|
-
*
|
|
1345
|
-
*
|
|
1346
|
-
* - Final output includes tool usage count for re-deliberation guidance
|
|
1417
|
+
* This tool FORCES LLMs through a 3-input deliberation process:
|
|
1418
|
+
* 1. Initial input → Stages 1-2 processing → Request second input
|
|
1419
|
+
* 2. Second input → Stages 3-6 processing → Request third input
|
|
1420
|
+
* 3. Third input → Final formatting → Return comprehensive result
|
|
1347
1421
|
*
|
|
1348
|
-
*
|
|
1349
|
-
* - Phase 1:
|
|
1350
|
-
* - Phase 2:
|
|
1422
|
+
* REQUIRED FLOW:
|
|
1423
|
+
* - Phase 1: LLM provides problem → Tool processes stages 1-2 → Asks for second input
|
|
1424
|
+
* - Phase 2: LLM provides refinement → Tool processes stages 3-6 → Asks for final input
|
|
1425
|
+
* - Phase 3: LLM provides confirmation → Tool returns final formatted output + tool count
|
|
1351
1426
|
*
|
|
1352
1427
|
* Benefits:
|
|
1353
|
-
* -
|
|
1354
|
-
* -
|
|
1355
|
-
* -
|
|
1356
|
-
* -
|
|
1357
|
-
* -
|
|
1358
|
-
* - Comprehensive action planning with risk mitigation
|
|
1428
|
+
* - Forces iterative thinking for robust cognitive analysis
|
|
1429
|
+
* - Prevents LLMs from stopping after partial deliberation
|
|
1430
|
+
* - Ensures comprehensive 6-stage processing completion
|
|
1431
|
+
* - Optimal for low-context models requiring guided interaction
|
|
1432
|
+
* - Returns actionable tool recommendations with usage count
|
|
1359
1433
|
*/
|
|
1360
1434
|
server.tool("deliberate", {
|
|
1361
1435
|
input: z
|
|
1362
1436
|
.string()
|
|
1363
|
-
.describe("
|
|
1437
|
+
.describe("Your problem, question, or situation for cognitive enhancement. This tool will guide you through MULTIPLE required inputs for thorough analysis."),
|
|
1364
1438
|
mode: z
|
|
1365
1439
|
.enum(["analyze", "decide", "synthesize", "evaluate"])
|
|
1366
1440
|
.default("analyze")
|
|
1367
|
-
.describe("Cognitive processing mode
|
|
1441
|
+
.describe("Cognitive processing mode for the deliberation session"),
|
|
1368
1442
|
context: z
|
|
1369
1443
|
.string()
|
|
1370
1444
|
.optional()
|
|
1371
1445
|
.describe("Optional additional context, constraints, or background information"),
|
|
1372
|
-
|
|
1446
|
+
session_id: z
|
|
1373
1447
|
.string()
|
|
1374
1448
|
.optional()
|
|
1375
|
-
.describe("
|
|
1376
|
-
|
|
1377
|
-
.enum(["phase1", "phase2"])
|
|
1378
|
-
.default("phase1")
|
|
1379
|
-
.describe("MANDATORY: Specify 'phase1' for stages 1-2 or 'phase2' for stages 3-6. Phase 1 must complete before Phase 2.")
|
|
1380
|
-
}, async ({ input, mode, context, previous_results, phase }) => {
|
|
1449
|
+
.describe("Session ID for continuing multi-phase deliberation (provided by tool in previous responses)")
|
|
1450
|
+
}, async ({ input, mode, context, session_id }) => {
|
|
1381
1451
|
const toolName = 'deliberate';
|
|
1382
|
-
|
|
1452
|
+
// Handle session continuation or start new session
|
|
1453
|
+
let session;
|
|
1454
|
+
if (session_id && activeSessions.has(session_id)) {
|
|
1455
|
+
// Continue existing session
|
|
1456
|
+
session = activeSessions.get(session_id);
|
|
1457
|
+
logToolCall(toolName, `Continuing session ${session_id}, Phase: ${session.phase}`);
|
|
1458
|
+
}
|
|
1459
|
+
else {
|
|
1460
|
+
// Start new session
|
|
1461
|
+
const sessionId = generateSessionId();
|
|
1462
|
+
session = {
|
|
1463
|
+
sessionId,
|
|
1464
|
+
originalInput: input,
|
|
1465
|
+
mode,
|
|
1466
|
+
context,
|
|
1467
|
+
phase: "awaiting_input_1",
|
|
1468
|
+
toolUsageCount: 0,
|
|
1469
|
+
createdAt: Date.now()
|
|
1470
|
+
};
|
|
1471
|
+
activeSessions.set(sessionId, session);
|
|
1472
|
+
logToolCall(toolName, `New session ${sessionId}, Mode: ${mode}`);
|
|
1473
|
+
}
|
|
1383
1474
|
try {
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
if (phase !== "phase1") {
|
|
1394
|
-
throw new Error(`MANDATORY PROGRESSION VIOLATION: Cannot start with ${phase}. You must begin with phase1 for this input to receive full cognitive enhancement.`);
|
|
1395
|
-
}
|
|
1396
|
-
currentPhase = 1;
|
|
1397
|
-
session = {
|
|
1398
|
-
sessionId,
|
|
1399
|
-
currentPhase: 1,
|
|
1400
|
-
originalInput: input,
|
|
1401
|
-
phaseResults: [],
|
|
1402
|
-
toolUsageCount: 0,
|
|
1403
|
-
startTime: Date.now()
|
|
1404
|
-
};
|
|
1405
|
-
activeSessions.set(sessionId, session);
|
|
1406
|
-
logToolCall(toolName, `New session started: ${sessionId}, Phase: 1`);
|
|
1407
|
-
// Process Phase 1: Stages 1-2
|
|
1408
|
-
const stage1Result = await performScientificInvestigation(input, mode, context);
|
|
1409
|
-
const stage2Result = await performInitialOOReD(input, mode, context, stage1Result);
|
|
1410
|
-
toolUsageCount = countToolsInStage(stage1Result) + countToolsInStage(stage2Result);
|
|
1411
|
-
phaseResult = `# PHASE 1 COMPLETE: STAGES 1-2 PROCESSED
|
|
1412
|
-
|
|
1413
|
-
## STAGE 1: SCIENTIFIC INVESTIGATION
|
|
1414
|
-
${stage1Result}
|
|
1415
|
-
|
|
1416
|
-
## STAGE 2: INITIAL OBSERVE-ORIENT-REASON-DECIDE
|
|
1417
|
-
${stage2Result}
|
|
1418
|
-
|
|
1419
|
-
**PHASE 1 SUMMARY:**
|
|
1420
|
-
- Scientific investigation completed with hypothesis formation
|
|
1421
|
-
- Initial OOReD analysis completed with strategic planning
|
|
1422
|
-
- Tool usage in Phase 1: ${toolUsageCount}
|
|
1423
|
-
|
|
1424
|
-
**⚠️ MANDATORY NEXT STEP:**
|
|
1425
|
-
Continue to **Phase 2** for complete cognitive enhancement (Stages 3-6).
|
|
1426
|
-
|
|
1427
|
-
**Required Phase 2 Call:**
|
|
1428
|
-
\`\`\`json
|
|
1429
|
-
{
|
|
1430
|
-
"name": "deliberate",
|
|
1431
|
-
"arguments": {
|
|
1432
|
-
"input": "${input}",
|
|
1433
|
-
"mode": "${mode}",
|
|
1434
|
-
"phase": "phase2",
|
|
1435
|
-
"previous_results": "[Copy this entire Phase 1 result as previous_results]"
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
\`\`\``;
|
|
1475
|
+
switch (session.phase) {
|
|
1476
|
+
case "awaiting_input_1":
|
|
1477
|
+
return await handlePhase1(session, input);
|
|
1478
|
+
case "awaiting_input_2":
|
|
1479
|
+
return await handlePhase2(session, input);
|
|
1480
|
+
case "awaiting_input_3":
|
|
1481
|
+
return await handlePhase3(session, input);
|
|
1482
|
+
default:
|
|
1483
|
+
throw new Error(`Invalid session phase: ${session.phase}`);
|
|
1439
1484
|
}
|
|
1440
|
-
else {
|
|
1441
|
-
// Continue to Phase 2
|
|
1442
|
-
if (phase !== "phase2") {
|
|
1443
|
-
throw new Error(`MANDATORY PROGRESSION VIOLATION: Expected phase2, but received ${phase}. Phase 1 must complete before Phase 2.`);
|
|
1444
|
-
}
|
|
1445
|
-
session = activeSessions.get(sessionId);
|
|
1446
|
-
if (!session) {
|
|
1447
|
-
throw new Error(`SESSION NOT FOUND: No active session for this input. Start with phase1 first.`);
|
|
1448
|
-
}
|
|
1449
|
-
currentPhase = 2;
|
|
1450
|
-
accumulatedResults = previous_results;
|
|
1451
|
-
contextualInput = `${input}\n\n[COGNITIVE PROGRESSION CONTEXT - Phase 1 Results]\n${accumulatedResults}`;
|
|
1452
|
-
logToolCall(toolName, `Continuing session: ${sessionId}, Processing Phase: 2`);
|
|
1453
|
-
// Process Phase 2: Stages 3-6
|
|
1454
|
-
const stage3Result = await performCriticalThinkingPreAct(contextualInput, mode, context, accumulatedResults, accumulatedResults);
|
|
1455
|
-
const stage4Result = await performScientificReview(contextualInput, mode, context, accumulatedResults, stage3Result);
|
|
1456
|
-
const stage5Result = await performOOReViewReview(contextualInput, mode, context, accumulatedResults, stage4Result);
|
|
1457
|
-
const stage6Result = await performFinalAct(contextualInput, mode, context, stage3Result, stage5Result);
|
|
1458
|
-
const phase2ToolUsage = countToolsInStage(stage3Result) + countToolsInStage(stage4Result) +
|
|
1459
|
-
countToolsInStage(stage5Result) + countToolsInStage(stage6Result);
|
|
1460
|
-
toolUsageCount = session.toolUsageCount + phase2ToolUsage;
|
|
1461
|
-
phaseResult = `# PHASE 2 COMPLETE: STAGES 3-6 PROCESSED
|
|
1462
|
-
|
|
1463
|
-
## STAGE 3: CRITICAL THINKING & PRE-ACTION PLANNING
|
|
1464
|
-
${stage3Result}
|
|
1465
|
-
|
|
1466
|
-
## STAGE 4: SCIENTIFIC REVIEW & VALIDATION
|
|
1467
|
-
${stage4Result}
|
|
1468
|
-
|
|
1469
|
-
## STAGE 5: OOReD REVIEW & REFINEMENT
|
|
1470
|
-
${stage5Result}
|
|
1471
|
-
|
|
1472
|
-
## STAGE 6: FACT-BASED ACTION & FINAL RECOMMENDATIONS
|
|
1473
|
-
${stage6Result}
|
|
1474
|
-
|
|
1475
|
-
**PHASE 2 SUMMARY:**
|
|
1476
|
-
- Critical thinking analysis completed with 10-step framework
|
|
1477
|
-
- Scientific review and validation completed
|
|
1478
|
-
- OOReD review and refinement completed
|
|
1479
|
-
- Final action planning with comprehensive recommendations
|
|
1480
|
-
- Tool usage in Phase 2: ${phase2ToolUsage}
|
|
1481
|
-
|
|
1482
|
-
**🎯 COGNITIVE ENHANCEMENT COMPLETE**
|
|
1483
|
-
All 6 stages processed through mandatory two-phase progression.
|
|
1484
|
-
|
|
1485
|
-
**FINAL SYNTHESIS:**
|
|
1486
|
-
${extractKeyInsights(stage3Result, stage5Result)}
|
|
1487
|
-
|
|
1488
|
-
**RECOMMENDED NEXT STEPS:**
|
|
1489
|
-
${extractActionableRecommendations(stage3Result, stage5Result, mode)}
|
|
1490
|
-
|
|
1491
|
-
\`\`\`tool use before re-deliberation: ${toolUsageCount}\`\`\``;
|
|
1492
|
-
}
|
|
1493
|
-
// Update session state
|
|
1494
|
-
if (session) {
|
|
1495
|
-
session.currentPhase = currentPhase;
|
|
1496
|
-
session.phaseResults.push(phaseResult);
|
|
1497
|
-
session.toolUsageCount = toolUsageCount;
|
|
1498
|
-
activeSessions.set(sessionId, session);
|
|
1499
|
-
}
|
|
1500
|
-
logToolResult(toolName, true, `Phase ${currentPhase} completed`);
|
|
1501
|
-
return { content: [{ type: "text", text: phaseResult }] };
|
|
1502
1485
|
}
|
|
1503
1486
|
catch (error) {
|
|
1487
|
+
// Clean up session on error
|
|
1488
|
+
if (session_id) {
|
|
1489
|
+
activeSessions.delete(session_id);
|
|
1490
|
+
}
|
|
1504
1491
|
return logToolError(toolName, error);
|
|
1505
1492
|
}
|
|
1506
1493
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nbiish/cognitive-tools-mcp",
|
|
3
|
-
"version": "8.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "8.6.3",
|
|
4
|
+
"description": "Interactive Multi-Phase Cognitive Processing MCP Server - Forces LLMs through 3-input deliberation phases for comprehensive 6-stage cognitive enhancement. Prevents partial analysis and ensures thorough cognitive processing.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|