@nbiish/cognitive-tools-mcp 0.6.2 → 0.7.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/LICENSE +565 -88
- package/README.md +28 -8
- package/build/index.js +88 -73
- package/integration-prompts/integration-prompt-01.md +71 -0
- package/integration-prompts/integration-prompt-02.md +32 -0
- package/integration-prompts/integration-prompt-03.md +71 -0
- package/integration-prompts/integration-prompt-04.md +144 -0
- package/integration-prompts/integration-prompt-05.md +84 -0
- package/integration-prompts/integration-prompt-06.md +91 -0
- package/integration-prompts/integration-prompt-07.md +88 -0
- package/integration-prompts/integration-prompt-08.md +86 -0
- package/integration-prompts/integration-prompt-09.md +86 -0
- package/integration-tool-descriptions/tool-descriptions-01.ts +171 -0
- package/integration-tool-descriptions/tool-descriptions-02.ts +216 -0
- package/integration-tool-descriptions/tool-descriptions-03.md +211 -0
- package/integration-tool-descriptions/tool-descriptoins-03.ts +225 -0
- package/package.json +11 -6
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
// Create the MCP server
|
|
7
|
+
const server = new McpServer({
|
|
8
|
+
name: "gikendaasowin-aabajichiganan-mcp",
|
|
9
|
+
// Version reflects refined tool integration guidance
|
|
10
|
+
version: "0.7.1",
|
|
11
|
+
description: "ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Gikendaasowin Aabajichiganan - (Cognitive Tools v0.7.1): SOTA internal reasoning suite aligned with AI Pair Programmer Prompt v0.7.1+. Features advanced deliberation (`think`), rapid checks (`quick_think`), mandatory complexity assessment & strategy selection, context synthesis, confidence gauging, proactive planning, explicit reasoning (CoT), and reflection, designed for robust agentic workflows including potential executable actions and dynamic tool discovery."
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// --- Core Cognitive Deliberation Tools ---
|
|
15
|
+
|
|
16
|
+
server.tool(
|
|
17
|
+
"think",
|
|
18
|
+
// Main Description: For High Cognitive Load situations.
|
|
19
|
+
"MANDATORY Cognitive Hub for **High/Medium Complexity, Uncertainty, Consequence, or Novelty (CUC-N)** situations. Use for deep analysis, planning, verification, risk assessment, self-correction, and integrating complex outputs (CoT, Plans, Critiques, Syntheses, Confidence Gauges). Logs detailed reasoning.",
|
|
20
|
+
{
|
|
21
|
+
// Parameter Description: Must analyze inputs including novel tool outputs.
|
|
22
|
+
thought: z.string().describe("Your **detailed** internal monologue for complex situations, triggered after CUC-N assessment indicates 'think' mode. MUST explicitly analyze prior steps & generated text (e.g., CoT text, Plan text including Anticipated Challenges, Reflection critique text, Synthesized summary text, Confidence justification text). Structure MANDATORY: ## Analysis, ## Plan, ## Verification, ## Anticipated Challenges Analysis & Contingency, ## Risk Assessment, ## Lookahead, ## Self-Correction & Learning.")
|
|
23
|
+
},
|
|
24
|
+
async ({ thought }) => {
|
|
25
|
+
if (!thought || typeof thought !== 'string' || thought.trim().length === 0) { throw new Error('Invalid thought: Must be non-empty, structured reasoning.'); }
|
|
26
|
+
console.error(`[CognitiveToolsServer] Think Tool Logged: ${thought.substring(0, 100)}...`);
|
|
27
|
+
// Output confirms deep thought logged, ready for next assessment or action.
|
|
28
|
+
return { content: [{ type: "text" as const, text: `Deep Thought (structured analysis/plan/etc.) logged successfully.` }] };
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
server.tool(
|
|
33
|
+
"quick_think",
|
|
34
|
+
// Main Description: For Low Cognitive Load situations. Explicitly contrasted with 'think'.
|
|
35
|
+
"Cognitive Checkpoint ONLY for situations explicitly assessed as **strictly Low CUC-N AND simple task nature** (e.g., confirmation, acknowledgement). Logs brief thought. **DO NOT USE** for analysis, planning, or after other cognitive tools.",
|
|
36
|
+
{
|
|
37
|
+
// Parameter Description: Simpler input for brief thoughts.
|
|
38
|
+
brief_thought: z.string().describe("Your **concise** thought for strictly simple, low CUC-N situations (e.g., 'Acknowledged user input.', 'Proceeding with confirmed step 3.', 'Code execution successful.').")
|
|
39
|
+
},
|
|
40
|
+
async ({ brief_thought }) => {
|
|
41
|
+
if (!brief_thought || typeof brief_thought !== 'string' || brief_thought.trim().length === 0) { throw new Error('Invalid brief_thought: Must be non-empty.'); }
|
|
42
|
+
console.error(`[CognitiveToolsServer] QuickThink Tool Logged: ${brief_thought.substring(0, 100)}...`);
|
|
43
|
+
// Output confirms brief thought logged.
|
|
44
|
+
return { content: [{ type: "text" as const, text: `Quick Thought logged successfully.` }] };
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
// --- Novel Meta-Cognitive & Context Management Tools ---
|
|
49
|
+
|
|
50
|
+
server.tool(
|
|
51
|
+
"assess_cuc_n",
|
|
52
|
+
// Main Description: Forces explicit decision between think/quick_think.
|
|
53
|
+
"**Mandatory Pre-Cognitive Assessment.** Must be called BEFORE every `think` or `quick_think`. Guides the LLM to explicitly evaluate CUC-N, recommend an initial strategy, and commit to the next thought mode (`think` or `quick_think`).",
|
|
54
|
+
{
|
|
55
|
+
// Parameter Description: LLM provides its assessment and chosen mode.
|
|
56
|
+
assessment_and_choice: z.string().describe("Input your assessment *before* calling. MUST include: 1) Situation/Next Step Description. 2) CUC-N Ratings: Complexity(L/M/H), Uncertainty(L/M/H), Consequence(L/M/H), Novelty(L/M/H). 3) Recommended Initial Strategy (e.g., 'Start `think` analysis', 'Use `plan_and_solve`'). 4) Explicit Mode Selection: 'Selected Mode: think' or 'Selected Mode: quick_think'.")
|
|
57
|
+
},
|
|
58
|
+
async ({ assessment_and_choice }) => {
|
|
59
|
+
// Enhanced validation to check for key phrases expected from the prompt's instructions
|
|
60
|
+
const requiredPhrases = ["Complexity", "Uncertainty", "Consequence", "Novelty", "Recommended Initial Strategy", "Selected Mode:"];
|
|
61
|
+
const hasRequiredPhrases = requiredPhrases.every(phrase => assessment_and_choice.includes(phrase));
|
|
62
|
+
const hasModeSelection = assessment_and_choice.includes("Selected Mode: think") || assessment_and_choice.includes("Selected Mode: quick_think");
|
|
63
|
+
|
|
64
|
+
if (!assessment_and_choice || typeof assessment_and_choice !== 'string' || !hasRequiredPhrases || !hasModeSelection) {
|
|
65
|
+
throw new Error('Invalid assessment: String must include CUC-N ratings, Recommended Initial Strategy, and explicit Selected Mode ("think" or "quick_think").');
|
|
66
|
+
}
|
|
67
|
+
console.error(`[CognitiveToolsServer] AssessComplexity Tool Signaled: ${assessment_and_choice.substring(0, 150)}...`);
|
|
68
|
+
const mode = assessment_and_choice.includes("Selected Mode: think") ? "think" : "quick_think";
|
|
69
|
+
// Output confirms the assessment was made and guides the next step.
|
|
70
|
+
return { content: [{ type: "text" as const, text: `Cognitive Assessment Completed. Proceeding with selected mode: ${mode}. Full Assessment: ${assessment_and_choice}` }] };
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
server.tool(
|
|
75
|
+
"synthesize_prior_reasoning",
|
|
76
|
+
// Main Description: Manages context window and focuses reasoning.
|
|
77
|
+
"Context Management Tool. Guides the LLM to **internally generate a structured summary text** of preceding lengthy reasoning, focusing on **`Key Decisions Made`** and **`Open Questions/Uncertainties`**. Used to manage context and refocus attention.",
|
|
78
|
+
{
|
|
79
|
+
// Parameter Description: Reminds LLM of the required internal summary structure.
|
|
80
|
+
context_to_summarize_description: z.string().describe("Describe the reasoning span being summarized. *You* (LLM) must now *internally generate the structured summary text (including Key Decisions, Open Questions)* before calling. This signals the summary is ready for `think` analysis.")
|
|
81
|
+
},
|
|
82
|
+
async ({ context_to_summarize_description }) => {
|
|
83
|
+
if (!context_to_summarize_description || typeof context_to_summarize_description !== 'string' || context_to_summarize_description.trim().length === 0) { throw new Error('Invalid context description: Must be non-empty.'); }
|
|
84
|
+
console.error(`[CognitiveToolsServer] SynthesizeReasoning Tool Signaled for: ${context_to_summarize_description}...`);
|
|
85
|
+
// Output implies structured summary is ready for analysis.
|
|
86
|
+
return { content: [{ type: "text" as const, text: `Structured synthesis internally generated for context: '${context_to_summarize_description}'. Ready for detailed analysis in next 'think' step.` }] };
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
server.tool(
|
|
91
|
+
"gauge_confidence",
|
|
92
|
+
// Main Description: Explicit meta-cognition about certainty.
|
|
93
|
+
"Meta-Cognitive Checkpoint. Guides the LLM to explicitly **state confidence (High/Medium/Low) and justification** regarding a specific item (plan, conclusion, action). Output MUST be analyzed in next `think` step; Low/Medium confidence requires specific action.",
|
|
94
|
+
{
|
|
95
|
+
// Parameter Description: Matches prompt requirements.
|
|
96
|
+
assessment_and_confidence: z.string().describe("Input the item being assessed (e.g., 'Confidence in proposed refactoring plan'). Then *internally determine and state*: 1) Confidence Level (High/Medium/Low). 2) Justification for this level. Call this tool *after* making the assessment.")
|
|
97
|
+
},
|
|
98
|
+
async ({ assessment_and_confidence }) => {
|
|
99
|
+
const confidenceRegex = /Confidence Level: (High|Medium|Low)/i;
|
|
100
|
+
if (!assessment_and_confidence || typeof assessment_and_confidence !== 'string' || !confidenceRegex.test(assessment_and_confidence)) {
|
|
101
|
+
throw new Error('Invalid confidence assessment: String must include "Confidence Level: High/Medium/Low" and justification.');
|
|
102
|
+
}
|
|
103
|
+
const match = assessment_and_confidence.match(confidenceRegex);
|
|
104
|
+
const level = match ? match[1] : "Unknown";
|
|
105
|
+
console.error(`[CognitiveToolsServer] GaugeConfidence Tool Signaled: Level ${level}`);
|
|
106
|
+
// Output confirms level and prepares for analysis.
|
|
107
|
+
return { content: [{ type: "text" as const, text: `Confidence Gauge Completed. Level: ${level}. Assessment Text: ${assessment_and_confidence}. Ready for mandatory 'think' analysis (action required if Low/Medium).` }] };
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
// --- Supporting Cognitive Strategy Tools ---
|
|
112
|
+
|
|
113
|
+
server.tool(
|
|
114
|
+
"plan_and_solve",
|
|
115
|
+
// Main Description: Emphasizes plan text structure and potential for other tools.
|
|
116
|
+
"Guides the LLM to **internally generate structured plan text**, including **`Anticipated Challenges/Risks`**. The plan steps might logically suggest the need for other tools (known or discovered). The generated plan text MUST be validated/detailed via `think`.",
|
|
117
|
+
{
|
|
118
|
+
// Parameter Description: Reminds LLM of required internal generation content and openness.
|
|
119
|
+
task_objective: z.string().describe("Input the objective. *You* (LLM) must now *internally generate the structured plan text, including Anticipated Challenges/Risks, and noting steps where other tools might be applicable,* before calling. Signals plan text is ready for `think` analysis.")
|
|
120
|
+
},
|
|
121
|
+
async ({ task_objective }) => {
|
|
122
|
+
if (!task_objective || typeof task_objective !== 'string' || task_objective.trim().length === 0) { throw new Error('Invalid task objective.'); }
|
|
123
|
+
console.error(`[CognitiveToolsServer] PlanAndSolve Tool Signaled for: ${task_objective.substring(0, 100)}...`);
|
|
124
|
+
// Output implies plan text *with risks and potential tool needs* is ready.
|
|
125
|
+
return { content: [{ type: "text" as const, text: `Structured plan (incl. Risks/Challenges, potential tool needs) internally generated for objective: ${task_objective}. Ready for mandatory 'think' analysis.` }] };
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
server.tool(
|
|
130
|
+
"chain_of_thought",
|
|
131
|
+
// Main Description: Refined to explicitly mention potential for other tools within the reasoning.
|
|
132
|
+
"Guides the LLM to **internally generate detailed, step-by-step reasoning text (CoT)**. Steps within the CoT might logically identify points requiring external data, computation, code execution, or checks for other available tools. The generated CoT text MUST be analyzed via `think`.",
|
|
133
|
+
{
|
|
134
|
+
// Parameter Description: Explicitly guides internal generation to consider tool needs.
|
|
135
|
+
problem_statement: z.string().describe("Input the specific problem requiring detailed CoT. *You* (LLM) must now *internally generate the full CoT text*, structuring it clearly and explicitly noting any steps where other tools (e.g., code execution, file access, web search, list_tools) might be needed *after* this CoT is analyzed. Call this tool *after* generating the text.")
|
|
136
|
+
},
|
|
137
|
+
// Implementation: Signals CoT was performed and is ready for analysis.
|
|
138
|
+
async ({ problem_statement }) => {
|
|
139
|
+
if (!problem_statement || typeof problem_statement !== 'string' || problem_statement.trim().length === 0) { throw new Error('Invalid problem statement.'); }
|
|
140
|
+
console.error(`[CognitiveToolsServer] ChainOfThought Tool Signaled for: ${problem_statement.substring(0, 100)}...`);
|
|
141
|
+
// Output implies CoT text *potentially identifying tool needs* is ready for analysis.
|
|
142
|
+
return { content: [{ type: "text" as const, text: `Detailed CoT (potentially identifying needs for other tools) internally generated for problem: ${problem_statement}. Ready for mandatory 'think' analysis.` }] };
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
server.tool(
|
|
147
|
+
"chain_of_draft",
|
|
148
|
+
// Main Description: Positions for efficient exploration, results analyzed by 'think'.
|
|
149
|
+
"Guides the LLM to **internally generate concise, iterative reasoning draft texts** ('thought-sketches'). Useful for efficiently exploring multiple solution paths or brainstorming hypotheses. Drafts MUST be analyzed comparatively via `think`.",
|
|
150
|
+
{
|
|
151
|
+
// Parameter Description: Instructs LLM on internal draft generation.
|
|
152
|
+
problem_statement: z.string().describe("Input the problem or question for exploration. *You* (LLM) must now *internally generate brief, iterative draft texts* (e.g., key steps, pros/cons) for potential approaches before calling this tool. Signals drafts are ready for `think` analysis.")
|
|
153
|
+
},
|
|
154
|
+
// Implementation: Signals Drafting was performed.
|
|
155
|
+
async ({ problem_statement }) => {
|
|
156
|
+
if (!problem_statement || typeof problem_statement !== 'string' || problem_statement.trim().length === 0) { throw new Error('Invalid problem statement.'); }
|
|
157
|
+
console.error(`[CognitiveToolsServer] ChainOfDraft Tool Signaled for: ${problem_statement.substring(0, 100)}...`);
|
|
158
|
+
// Output implies draft texts are ready for comparative analysis.
|
|
159
|
+
return { content: [{ type: "text" as const, text: `Reasoning drafts internally generated for problem: ${problem_statement}. Ready for mandatory 'think' analysis.` }] };
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
server.tool(
|
|
164
|
+
"reflection",
|
|
165
|
+
// Main Description: Explicitly mentions taking prior text as input for critique, results analyzed by 'think'.
|
|
166
|
+
"Guides the LLM to perform critical self-evaluation on **previously generated text** (reasoning, plans, code concepts). Essential for iterative refinement and improving accuracy. The *generated critique text* MUST be analyzed via `think`.",
|
|
167
|
+
{
|
|
168
|
+
// Parameter Description: Input is the specific text to be critiqued internally.
|
|
169
|
+
input_reasoning_or_plan: z.string().describe("Input the **exact text** (e.g., from a prior `think` log, or internally generated plan/CoT/code concept) that *you* (the LLM) must now *internally generate a critique for*. Your critique should identify flaws and suggest improvements. Call this tool *after* generating the critique.")
|
|
170
|
+
},
|
|
171
|
+
// Implementation: Signals Reflection was performed.
|
|
172
|
+
async ({ input_reasoning_or_plan }) => {
|
|
173
|
+
if (!input_reasoning_or_plan || typeof input_reasoning_or_plan !== 'string' || input_reasoning_or_plan.trim().length === 0) { throw new Error('Invalid input reasoning/plan.'); }
|
|
174
|
+
console.error(`[CognitiveToolsServer] Reflection Tool Signaled for analysis.`);
|
|
175
|
+
// Output implies critique text is ready for analysis.
|
|
176
|
+
return { content: [{ type: "text" as const, text: `Reflection critique internally generated for input text: '${input_reasoning_or_plan.substring(0, 100)}...'. Ready for mandatory 'think' analysis.` }] };
|
|
177
|
+
}
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
// --- Server Lifecycle and Error Handling ---
|
|
182
|
+
|
|
183
|
+
process.on('SIGINT', async () => {
|
|
184
|
+
console.error('\n[CognitiveToolsServer] Received SIGINT, shutting down gracefully.');
|
|
185
|
+
await server.close();
|
|
186
|
+
process.exit(0);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
process.on('SIGTERM', async () => {
|
|
190
|
+
console.error('\n[CognitiveToolsServer] Received SIGTERM, shutting down gracefully.');
|
|
191
|
+
await server.close();
|
|
192
|
+
process.exit(0);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
process.on('uncaughtException', (error) => {
|
|
196
|
+
console.error('[CognitiveToolsServer] FATAL: Uncaught Exception:', error);
|
|
197
|
+
// Attempt graceful shutdown, but prioritize process exit
|
|
198
|
+
server.close().catch(err => console.error('[CognitiveToolsServer] Error during shutdown on uncaughtException:', err)).finally(() => {
|
|
199
|
+
process.exit(1); // Exit on fatal error
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
204
|
+
console.error('[CognitiveToolsServer] FATAL: Unhandled Promise Rejection:', reason);
|
|
205
|
+
// Attempt graceful shutdown, but prioritize process exit
|
|
206
|
+
server.close().catch(err => console.error('[CognitiveToolsServer] Error during shutdown on unhandledRejection:', err)).finally(() => {
|
|
207
|
+
process.exit(1); // Exit on fatal error
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// Start the server
|
|
212
|
+
async function main() {
|
|
213
|
+
try {
|
|
214
|
+
const transport = new StdioServerTransport();
|
|
215
|
+
await server.connect(transport);
|
|
216
|
+
console.error('ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Gikendaasowin Aabajichiganan - (Cognitive Tools v0.7.1) MCP Server running on stdio');
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
console.error('[CognitiveToolsServer] Fatal error during startup:', error);
|
|
220
|
+
process.exit(1);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Execute the main function to start the server
|
|
225
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nbiish/cognitive-tools-mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.7.3",
|
|
4
|
+
"description": "Cognitive Tools MCP v0.7.3: SOTA internal reasoning suite aligned with AI Pair Programmer Prompt v0.7.2. Features advanced deliberation (`think`), rapid checks (`quick_think`), mandatory complexity assessment & strategy selection (`assess_cuc_n`), context synthesis, confidence gauging, proactive planning, explicit reasoning (CoT), and reflection. Alternative package name for gikendaasowin-aabajichiganan-mcp.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
|
-
"
|
|
8
|
+
"cognitive-tools-mcp": "build/index.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
|
-
"build"
|
|
11
|
+
"build",
|
|
12
|
+
"integration-prompts",
|
|
13
|
+
"integration-tool-descriptions",
|
|
14
|
+
"LICENSE",
|
|
15
|
+
"README.md"
|
|
12
16
|
],
|
|
13
17
|
"scripts": {
|
|
14
18
|
"build": "tsc && node -e \"require('fs').chmodSync('build/index.js', '755')\"",
|
|
15
19
|
"prepare": "npm run build",
|
|
16
20
|
"watch": "tsc --watch",
|
|
17
21
|
"inspector": "npx @modelcontextprotocol/inspector build/index.js",
|
|
18
|
-
"start": "node build/index.js"
|
|
22
|
+
"start": "node build/index.js",
|
|
23
|
+
"publish-both": "./scripts/publish-both-packages.sh"
|
|
19
24
|
},
|
|
20
25
|
"keywords": [
|
|
21
26
|
"mcp",
|
|
@@ -48,4 +53,4 @@
|
|
|
48
53
|
"publishConfig": {
|
|
49
54
|
"access": "public"
|
|
50
55
|
}
|
|
51
|
-
}
|
|
56
|
+
}
|