@nbiish/cognitive-tools-mcp 0.9.2 → 0.9.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 CHANGED
@@ -26,7 +26,7 @@ Known as:
26
26
 
27
27
  Both packages are maintained in parallel and receive the same updates. You can use either package name in your projects - they provide identical functionality.
28
28
 
29
- **See the latest integration details in [`integration-prompts/integration-prompt-07.md`](integration-prompts/integration-prompt-07.md).**
29
+ **See the latest integration details in [`integration-prompts/new-prompts/integration-prompt-16.md`](integration-prompts/new-prompts/integration-prompt-16.md).**
30
30
 
31
31
  ## Features
32
32
 
package/build/index.js CHANGED
@@ -18,7 +18,7 @@ import { z } from "zod";
18
18
  // --- Server Definition ---
19
19
  const server = new McpServer({
20
20
  name: "gikendaasowin-aabajichiganan-mcp",
21
- version: "0.9.2",
21
+ version: "0.9.3",
22
22
  description: "ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Core Cognitive Tools Suite: Enables structured, iterative reasoning (Chain of Draft), planning, and analysis for AI Pair Programming, focusing on the cognitive loop."
23
23
  });
24
24
  // --- Logging Helper ---
@@ -0,0 +1,96 @@
1
+ # Role: AI Pair Programmer (Cognitive Navigator - Iterative Refinement)
2
+
3
+ You are my AI Pair Programmer, operating as a highly **cognitive Navigator**. Your primary function is to guide the coding process through proactive, structured reasoning, iterative refinement (Chain of Draft), and seamless integration of cognitive strategies with available environment actions.
4
+
5
+ Your **most critical function** is **iterative problem-solving using the core cognitive toolkit**:
6
+ 1. **Deconstruct** tasks.
7
+ 2. **Generate** initial thoughts, plans, reasoning, or drafts using cognitive tools.
8
+ 3. **Critically Analyze** these outputs using `think` and `reflection`.
9
+ 4. **Refine** based on analysis, incorporating feedback and self-correction.
10
+ 5. **Integrate** necessary external actions (like file access, code execution, information retrieval) by planning their use within your `think` steps.
11
+
12
+ You MUST utilize the provided `gikendaasowin-aabajichiganan-mcp` suite, specifically the core cognitive tools, to externalize this structured, iterative thinking process.
13
+
14
+ ## Core Operating Principle: Iterative Refinement via Mandatory Cognitive Analysis
15
+
16
+ **The `think` tool is your central hub for analysis, planning, and refinement.** It's MANDATORY after significant cognitive tool usage, internal draft generation, or receiving results from *any* external action to ensure deliberate progress.
17
+
18
+ **1. Mandatory Pre-Deliberation Assessment (`assess_cuc_n_mode`):**
19
+ * **Call FIRST** at the start of a new task, when uncertainty spikes, or when significantly changing strategy.
20
+ * **Purpose:** Evaluate task Complexity, Uncertainty, Consequence, and Novelty (CUC-N) to determine the necessary cognitive depth and initial approach.
21
+ * **Input Parameter:** `assessment_and_choice` (a single string).
22
+ * **MANDATORY String Format:** You **MUST** construct the `assessment_and_choice` string to contain **ALL** of the following components, clearly labeled, often separated by newlines:
23
+ 1. **Situation Description:** A brief summary of the current context or task.
24
+ 2. **CUC-N Ratings:** Explicitly state the ratings (Low/Medium/High) for Complexity, Uncertainty, Consequence, and Novelty. Use the label "CUC-N Ratings:".
25
+ 3. **Recommended Initial Strategy:** Your proposed first step or approach. Use the label "Recommended Initial Strategy:". This might involve a cognitive tool or planning an external action.
26
+ 4. **Explicit Mode Selection:** State **EXACTLY** either "Selected Mode: think" or "Selected Mode: quick_think". Use the label "Selected Mode:".
27
+ * **CRITICAL:** The tool's validation requires the *exact phrases* "CUC-N Ratings:", "Recommended Initial Strategy:", and "Selected Mode:" to be present in the string you provide.
28
+
29
+ * **Example of a CORRECT `assessment_and_choice` string:**
30
+ ```text
31
+ Situation Description: User wants to refactor the authentication module to use JWT.
32
+ CUC-N Ratings: Complexity=Medium, Uncertainty=Low, Consequence=High, Novelty=Low
33
+ Recommended Initial Strategy: Start with chain_of_thought to outline the steps for JWT integration.
34
+ Selected Mode: think
35
+ ```
36
+
37
+ * *Skipping:* This assessment *may be skipped* only for direct, simple follow-up actions already defined within an *immediately preceding* and still-valid `think` plan where CUC-N factors haven't changed.
38
+
39
+ **2. Mandatory `think` Usage & Content (The Core Refinement Loop):**
40
+ * **Call AFTER:**
41
+ * `assess_cuc_n_mode` selects 'think'.
42
+ * Using `plan_and_solve`, `chain_of_thought`, `reflection`, `synthesize_prior_reasoning`.
43
+ * Signaling draft readiness via `chain_of_draft`.
44
+ * Receiving results from *any external action* (file read, code execution, search, etc.).
45
+ * Receiving new user input or encountering errors/unexpected results.
46
+ * Using `gauge_confidence`.
47
+ * **Internal Generation:** FIRST, *internally generate* detailed reasoning *analyzing the preceding cognitive tool output, generated draft, or external action result*.
48
+ * **Tool Call:** THEN, call `think` with your reasoning as the `thought` parameter.
49
+ * **`thought` Parameter Structure (MANDATORY Sections):**
50
+ * `## Analysis:` **Critically evaluate the *result* of the last cognitive tool, the *content* of the internal draft, OR the *outcome* of the last external action.** Insights? Errors? Sufficiency? Alignment with goals?
51
+ * `## Plan:` Outline the **concrete next steps** based on the Analysis.
52
+ * **Specify the *immediate* next action:** Call a specific cognitive tool (e.g., `reflection` on the draft, `chain_of_thought` to elaborate), *plan to call an available external tool* (e.g., "Plan: Execute code draft to test", "Plan: Read file X for details"), refine a draft internally then signal `chain_of_draft`, generate a response, or ask a question. State the *purpose* of the planned action.
53
+ * `## Verification:` How will the *next* step's outcome be verified?
54
+ * `## Anticipated Challenges & Contingency:` Risks in the *next* step? Fallbacks?
55
+ * `## Risk Assessment:` *New* risks identified?
56
+ * `## Lookahead:` Contribution to overall goal?
57
+ * `## Self-Correction & Learning:` Corrections/learnings from the analysis.
58
+ * **Tool Result:** Returns the `thought` text for context.
59
+
60
+ **3. Exception: `quick_think` Usage:** ONLY for Low CUC-N confirmations/logging where `think` analysis is unnecessary, as determined by `assess_cuc_n_mode`.
61
+
62
+ ## Core Cognitive Toolkit Usage Protocol (Iterative Focus):
63
+
64
+ 1. **`assess_cuc_n_mode`:** Call first/when needed to set strategy/depth. **Ensure input string format is correct.**
65
+ 2. **`think`:** Central analysis/planning hub. MANDATORY after cognitive tools, drafts, external actions. Defines next step (cognitive or planning external action).
66
+ 3. **`quick_think`:** Low-complexity logging only.
67
+ 4. **`synthesize_prior_reasoning`:** Generate summary -> Call -> Returns summary -> **Mandatory `think`** to analyze summary.
68
+ 5. **`gauge_confidence`:** Assess confidence -> Call -> Returns confirmation -> **Mandatory `think`** to analyze confidence and decide next step.
69
+ 6. **`plan_and_solve`:** Generate plan draft -> Call -> Returns plan -> **Mandatory `think`** to analyze/refine plan draft and confirm first action.
70
+ 7. **`chain_of_thought`:** Generate reasoning draft -> Call -> Returns CoT -> **Mandatory `think`** to analyze reasoning and plan next action.
71
+ 8. **`chain_of_draft`:** Internally generate/refine draft -> Call (signal) -> Returns confirmation -> **Mandatory `think`** to analyze the draft.
72
+ 9. **`reflection`:** Generate critique -> Call -> Returns critique -> **Mandatory `think`** to analyze critique and plan corrections.
73
+
74
+ ## Workflow & Interaction Protocol (Cognitive Loop):
75
+
76
+ 1. Receive Input.
77
+ 2. **Mandatory `assess_cuc_n_mode`** (Generate the input string carefully!).
78
+ 3. **Generate Initial Draft/Plan/Reasoning:** Use appropriate cognitive tools (`chain_of_thought`, `plan_and_solve`), potentially signal with `chain_of_draft`.
79
+ 4. **Mandatory `think` (Analyze Output & Plan Next):**
80
+ * Call `think`. Analyze output of Step 3 OR result of last action from Step 5.
81
+ * Plan *immediate* next action (cognitive tool call or plan for external action).
82
+ 5. **Execute Planned Action:**
83
+ * If next action is a cognitive tool -> Call it.
84
+ * If next action is external -> *Signal intent/plan* (the actual external call happens outside this cognitive loop, managed by the environment based on your plan). Assume result will be provided back.
85
+ * If next action is internal refinement -> Refine, then signal `chain_of_draft`.
86
+ * If generating response/question -> Generate it.
87
+ 6. **Loop or Complete:**
88
+ * **After cognitive tool use, `chain_of_draft` signal, or receiving external action results/errors:** **Go back to Step 4 (Mandatory `think`)** to analyze and plan next.
89
+ * **If task complete:** Generate final output/confirmation. -> **End.**
90
+ * **If blocked:** Ask clarifying question. -> **Wait for Input.**
91
+
92
+ ## Output Expectations:
93
+
94
+ * Code/Text: Clearly reasoned, iteratively refined.
95
+ * Explanations: Reference the cognitive process ("Analyzing the CoT draft...", "Based on the reflection...", "Planning to execute code for verification...").
96
+ * **Transparency:** Reasoning MUST be evident through structured `think` calls and use of the cognitive toolkit. Acknowledge when planning external actions based on cognitive analysis. **Ensure `assess_cuc_n_mode` calls show the correctly formatted input string.**
@@ -0,0 +1,293 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * -----------------------------------------------------------------------------
5
+ * Gikendaasowin Aabajichiganan - Core Cognitive Tools MCP Server
6
+ *
7
+ * Description: Provides the essential suite of cognitive tools for an AI
8
+ * Pair Programmer to structure its reasoning, plan actions,
9
+ * analyze results, and iteratively refine its work, focusing on
10
+ * the internal cognitive loop as described in the corresponding
11
+ * integration prompt. External actions are planned within 'think'
12
+ * but executed by the environment.
13
+ * Protocol: Model Context Protocol (MCP) over stdio.
14
+ * -----------------------------------------------------------------------------
15
+ */
16
+
17
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
18
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
19
+ import { z } from "zod";
20
+
21
+ // --- Server Definition ---
22
+
23
+ const server = new McpServer({
24
+ name: "gikendaasowin-aabajichiganan-mcp",
25
+ version: "0.9.2",
26
+ description: "ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Core Cognitive Tools Suite: Enables structured, iterative reasoning (Chain of Draft), planning, and analysis for AI Pair Programming, focusing on the cognitive loop."
27
+ });
28
+
29
+ // --- Logging Helper ---
30
+ function logToolCall(toolName: string, details?: string) {
31
+ console.error(`[MCP Server] > Tool Call: ${toolName}${details ? ` - ${details}` : ''}`);
32
+ }
33
+
34
+ function logToolResult(toolName: string, success: boolean, resultDetails?: string) {
35
+ console.error(`[MCP Server] < Tool Result: ${toolName} - ${success ? 'Success' : 'Failure'}${resultDetails ? ` - ${resultDetails}` : ''}`);
36
+ }
37
+
38
+ function logToolError(toolName: string, error: any) {
39
+ const errorMessage = error instanceof Error ? error.message : String(error);
40
+ console.error(`[MCP Server] ! Tool Error: ${toolName} - ${errorMessage}`);
41
+ logToolResult(toolName, false, errorMessage); // Log failure result as well
42
+ // Return a structured error message suitable for the LLM
43
+ return { content: [{ type: "text" as const, text: `Error in ${toolName}: ${errorMessage}` }] };
44
+ }
45
+
46
+
47
+ // --- Core Cognitive Deliberation & Refinement Tools ---
48
+
49
+ server.tool(
50
+ "assess_cuc_n_mode",
51
+ "**Mandatory Pre-Deliberation Assessment.** Evaluates task Complexity, Uncertainty, Consequence, Novelty (CUC-N) to determine required cognitive depth and initial strategy. MUST be called before starting complex tasks or changing strategy.",
52
+ {
53
+ assessment_and_choice: z.string().describe("Structured assessment including: 1) Situation Description, 2) CUC-N Ratings (L/M/H), 3) Recommended Initial Cognitive Strategy (e.g., 'Start with chain_of_thought'), 4) Explicit Mode Selection ('Selected Mode: think' or 'Selected Mode: quick_think').")
54
+ },
55
+ async ({ assessment_and_choice }) => {
56
+ logToolCall('assess_cuc_n_mode');
57
+ try {
58
+ // Basic validation for required components
59
+ if (!assessment_and_choice.includes("Selected Mode:") || !assessment_and_choice.includes("CUC-N Ratings:") || !assessment_and_choice.includes("Recommended Initial Strategy:")) {
60
+ throw new Error('Invalid assessment: String must include CUC-N ratings, Recommended Initial Strategy, and explicit Selected Mode.');
61
+ }
62
+ const mode = assessment_and_choice.includes("Selected Mode: think") ? "think" : "quick_think";
63
+ const resultText = `Cognitive Assessment Completed. Proceeding with selected mode: ${mode}. Full Assessment:\n${assessment_and_choice}`;
64
+ logToolResult('assess_cuc_n_mode', true, `Selected mode: ${mode}`);
65
+ return { content: [{ type: "text" as const, text: resultText }] };
66
+ } catch (error: any) {
67
+ return logToolError('assess_cuc_n_mode', error);
68
+ }
69
+ }
70
+ );
71
+
72
+ server.tool(
73
+ "think",
74
+ "**MANDATORY Central Hub for Analysis, Planning, and Refinement.** Called after assessment, cognitive tools, internal drafts, or external action results. Analyzes previous step's outcome/draft, plans immediate next action (cognitive or planning external action), verifies, assesses risk, and self-corrects. Returns the thought text for grounding.",
75
+ {
76
+ thought: z.string().describe("Your **detailed** internal monologue following the MANDATORY structure: ## Analysis (critically evaluate last result/draft), ## Plan (define *immediate* next action & purpose - cognitive or planning external), ## Verification (how to check next step), ## Anticipated Challenges & Contingency, ## Risk Assessment, ## Lookahead, ## Self-Correction & Learning.")
77
+ },
78
+ async ({ thought }) => {
79
+ logToolCall('think');
80
+ try {
81
+ if (!thought || typeof thought !== 'string' || thought.trim().length === 0) {
82
+ throw new Error('Invalid thought: Must be a non-empty string.');
83
+ }
84
+ // Basic check for mandatory sections
85
+ const requiredSections = ["## Analysis:", "## Plan:", "## Verification:", "## Anticipated Challenges & Contingency:", "## Risk Assessment:", "## Lookahead:", "## Self-Correction & Learning:"];
86
+ const missingSections = requiredSections.filter(section => !thought.includes(section));
87
+ if (missingSections.length > 0) {
88
+ console.warn(`[MCP Server] Warning: 'think' input might be missing sections: ${missingSections.join(', ')}`);
89
+ }
90
+ logToolResult('think', true, `Thought logged (length: ${thought.length})`);
91
+ // Returns the same thought text received.
92
+ return { content: [{ type: "text" as const, text: thought }] };
93
+ } catch (error: any) {
94
+ return logToolError('think', error);
95
+ }
96
+ }
97
+ );
98
+
99
+ server.tool(
100
+ "quick_think",
101
+ "Cognitive Checkpoint ONLY for situations explicitly assessed as strictly Low CUC-N (via assess_cuc_n_mode) or for trivial confirmations where detailed analysis via `think` is unnecessary. Use sparingly.",
102
+ {
103
+ brief_thought: z.string().describe("Your **concise** thought for strictly simple, low CUC-N situations or brief confirmations.")
104
+ },
105
+ async ({ brief_thought }) => {
106
+ logToolCall('quick_think');
107
+ try {
108
+ if (!brief_thought || typeof brief_thought !== 'string' || brief_thought.trim().length === 0) {
109
+ throw new Error('Invalid brief_thought: Must be non-empty.');
110
+ }
111
+ logToolResult('quick_think', true, `Logged: ${brief_thought.substring(0, 50)}...`);
112
+ return { content: [{ type: "text" as const, text: `Quick Thought logged successfully.` }] };
113
+ } catch (error: any) {
114
+ return logToolError('quick_think', error);
115
+ }
116
+ }
117
+ );
118
+
119
+ server.tool(
120
+ "gauge_confidence",
121
+ "Meta-Cognitive Checkpoint. Guides internal stating of **confidence (High/Medium/Low) and justification** regarding a plan, analysis, or draft. Output MUST be analyzed in the mandatory `think` step immediately after.",
122
+ {
123
+ assessment_and_confidence: z.string().describe("Input item being assessed. *Internally determine and state*: 1) Confidence Level (H/M/L). 2) Justification. Call this tool *after* making the assessment.")
124
+ },
125
+ async ({ assessment_and_confidence }) => {
126
+ logToolCall('gauge_confidence');
127
+ try {
128
+ const confidenceRegex = /Confidence Level: (High|Medium|Low)/i;
129
+ if (!assessment_and_confidence || typeof assessment_and_confidence !== 'string' || !confidenceRegex.test(assessment_and_confidence)) {
130
+ throw new Error('Invalid confidence assessment: String must include "Confidence Level: High/Medium/Low" and justification.');
131
+ }
132
+ const match = assessment_and_confidence.match(confidenceRegex);
133
+ const level = match ? match[1] : "Unknown";
134
+ const resultText = `Confidence Gauge Completed. Level: ${level}. Assessment Text: ${assessment_and_confidence}. Ready for mandatory post-assessment 'think' analysis (action required if Low/Medium).`;
135
+ logToolResult('gauge_confidence', true, `Level: ${level}`);
136
+ return { content: [{ type: "text" as const, text: resultText }] };
137
+ } catch (error: any) {
138
+ return logToolError('gauge_confidence', error);
139
+ }
140
+ }
141
+ );
142
+
143
+ server.tool(
144
+ "plan_and_solve",
145
+ "Guides internal generation of a **structured plan draft**. Call this tool *with* the generated plan text. Returns the plan text for mandatory `think` analysis to critically evaluate feasibility, refine, and confirm the first action step.",
146
+ {
147
+ generated_plan_text: z.string().describe("The **full, structured plan draft** you generated internally, including goals, steps, potential external tool needs, and risks."),
148
+ task_objective: z.string().describe("The original high-level task objective this plan addresses.")
149
+ },
150
+ async ({ generated_plan_text, task_objective }) => {
151
+ logToolCall('plan_and_solve', `Objective: ${task_objective.substring(0, 50)}...`);
152
+ try {
153
+ if (!generated_plan_text || typeof generated_plan_text !== 'string' || generated_plan_text.trim().length === 0) { throw new Error('Invalid generated_plan_text: Must be non-empty.'); }
154
+ if (!task_objective || typeof task_objective !== 'string' || task_objective.trim().length === 0) { throw new Error('Invalid task_objective.'); }
155
+ logToolResult('plan_and_solve', true, `Returned plan draft (length: ${generated_plan_text.length})`);
156
+ // Returns the actual plan text received for analysis.
157
+ return { content: [{ type: "text" as const, text: generated_plan_text }] };
158
+ } catch (error: any) {
159
+ return logToolError('plan_and_solve', error);
160
+ }
161
+ }
162
+ );
163
+
164
+ server.tool(
165
+ "chain_of_thought",
166
+ "Guides internal generation of **detailed, step-by-step reasoning draft (CoT)**. Call this tool *with* the generated CoT text. Returns the CoT text for mandatory `think` analysis to extract insights, identify flaws/gaps, and plan the next concrete action.",
167
+ {
168
+ generated_cot_text: z.string().describe("The **full, step-by-step Chain of Thought draft** you generated internally."),
169
+ problem_statement: z.string().describe("The original problem statement this CoT addresses.")
170
+ },
171
+ async ({ generated_cot_text, problem_statement }) => {
172
+ logToolCall('chain_of_thought', `Problem: ${problem_statement.substring(0, 50)}...`);
173
+ try {
174
+ if (!generated_cot_text || typeof generated_cot_text !== 'string' || generated_cot_text.trim().length === 0) { throw new Error('Invalid generated_cot_text: Must be non-empty.'); }
175
+ if (!problem_statement || typeof problem_statement !== 'string' || problem_statement.trim().length === 0) { throw new Error('Invalid problem_statement.'); }
176
+ logToolResult('chain_of_thought', true, `Returned CoT draft (length: ${generated_cot_text.length})`);
177
+ // Returns the actual CoT text received for analysis.
178
+ return { content: [{ type: "text" as const, text: generated_cot_text }] };
179
+ } catch (error: any) {
180
+ return logToolError('chain_of_thought', error);
181
+ }
182
+ }
183
+ );
184
+
185
+ server.tool(
186
+ "chain_of_draft",
187
+ "Signals that one or more **internal drafts** (code, text, plan fragments) have been generated or refined and are ready for analysis. Call this tool *after* generating/refining draft(s) internally. Response confirms readiness; drafts MUST be analyzed via mandatory `think`.",
188
+ {
189
+ draft_description: z.string().describe("Brief description of the draft(s) generated/refined internally (e.g., 'Initial code snippet for function X', 'Refined plan section 3').")
190
+ },
191
+ async ({ draft_description }) => {
192
+ logToolCall('chain_of_draft', `Description: ${draft_description}`);
193
+ try {
194
+ if (!draft_description || typeof draft_description !== 'string' || draft_description.trim().length === 0) { throw new Error('Invalid draft_description.'); }
195
+ const resultText = `Internal draft(s) ready for analysis: ${draft_description}. MANDATORY: Analyze these draft(s) now in your next 'think' step.`;
196
+ logToolResult('chain_of_draft', true);
197
+ return { content: [{ type: "text" as const, text: resultText }] };
198
+ } catch (error: any) {
199
+ return logToolError('chain_of_draft', error);
200
+ }
201
+ }
202
+ );
203
+
204
+ server.tool(
205
+ "reflection",
206
+ "Guides internal critical self-evaluation on a prior step, draft, or outcome. Call this tool *with* the **generated critique text**. Returns the critique text for mandatory `think` analysis to plan specific corrective actions or refinements.",
207
+ {
208
+ generated_critique_text: z.string().describe("The **full critique text** you generated internally, identifying flaws, strengths, and suggesting improvements."),
209
+ input_subject_description: z.string().describe("A brief description of the original reasoning, plan, code draft, or action result that was critiqued.")
210
+ },
211
+ async ({ generated_critique_text, input_subject_description }) => {
212
+ logToolCall('reflection', `Subject: ${input_subject_description}`);
213
+ try {
214
+ if (!generated_critique_text || typeof generated_critique_text !== 'string' || generated_critique_text.trim().length === 0) { throw new Error('Invalid generated_critique_text: Must be non-empty.'); }
215
+ if (!input_subject_description || typeof input_subject_description !== 'string' || input_subject_description.trim().length === 0) { throw new Error('Invalid input_subject_description.'); }
216
+ logToolResult('reflection', true, `Returned critique (length: ${generated_critique_text.length})`);
217
+ // Returns the actual critique text received for analysis.
218
+ return { content: [{ type: "text" as const, text: generated_critique_text }] };
219
+ } catch (error: any) {
220
+ return logToolError('reflection', error);
221
+ }
222
+ }
223
+ );
224
+
225
+ server.tool(
226
+ "synthesize_prior_reasoning",
227
+ "Context Management Tool. Guides internal generation of a **structured summary** of preceding steps, decisions, or context. Call this tool *with* the generated summary text. Returns the summary for mandatory `think` analysis to consolidate understanding and inform next steps.",
228
+ {
229
+ generated_summary_text: z.string().describe("The **full, structured summary text** you generated internally (e.g., key decisions, open questions, current state)."),
230
+ context_to_summarize_description: z.string().describe("Description of the reasoning span or context that was summarized.")
231
+ },
232
+ async ({ generated_summary_text, context_to_summarize_description }) => {
233
+ logToolCall('synthesize_prior_reasoning', `Context: ${context_to_summarize_description}`);
234
+ try {
235
+ if (!generated_summary_text || typeof generated_summary_text !== 'string' || generated_summary_text.trim().length === 0) { throw new Error('Invalid generated_summary_text: Must be non-empty.'); }
236
+ if (!context_to_summarize_description || typeof context_to_summarize_description !== 'string' || context_to_summarize_description.trim().length === 0) { throw new Error('Invalid context_to_summarize_description.'); }
237
+ logToolResult('synthesize_prior_reasoning', true, `Returned summary (length: ${generated_summary_text.length})`);
238
+ // Returns the actual summary text received for analysis.
239
+ return { content: [{ type: "text" as const, text: generated_summary_text }] };
240
+ } catch (error: any) {
241
+ return logToolError('synthesize_prior_reasoning', error);
242
+ }
243
+ }
244
+ );
245
+
246
+
247
+ // --- Server Lifecycle and Error Handling ---
248
+
249
+ process.on('SIGINT', async () => {
250
+ console.error('\n[MCP Server] Received SIGINT, shutting down gracefully.');
251
+ await server.close();
252
+ process.exit(0);
253
+ });
254
+
255
+ process.on('SIGTERM', async () => {
256
+ console.error('\n[MCP Server] Received SIGTERM, shutting down gracefully.');
257
+ await server.close();
258
+ process.exit(0);
259
+ });
260
+
261
+ process.on('uncaughtException', (error, origin) => {
262
+ console.error(`[MCP Server] FATAL: Uncaught Exception at: ${origin}`, error);
263
+ server.close().catch(err => console.error('[MCP Server] Error during shutdown on uncaughtException:', err)).finally(() => {
264
+ process.exit(1);
265
+ });
266
+ });
267
+
268
+ process.on('unhandledRejection', (reason, promise) => {
269
+ console.error('[MCP Server] FATAL: Unhandled Promise Rejection:', reason);
270
+ server.close().catch(err => console.error('[MCP Server] Error during shutdown on unhandledRejection:', err)).finally(() => {
271
+ process.exit(1);
272
+ });
273
+ });
274
+
275
+ // --- Start the Server ---
276
+
277
+ async function main() {
278
+ try {
279
+ const transport = new StdioServerTransport();
280
+ await server.connect(transport);
281
+ console.error('-----------------------------------------------------');
282
+ console.error(' ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Core Cognitive Tools MCP Server');
283
+ console.error(' Status: Running on stdio');
284
+ console.error('-----------------------------------------------------');
285
+ }
286
+ catch (error) {
287
+ console.error('[MCP Server] Fatal error during startup:', error);
288
+ process.exit(1);
289
+ }
290
+ }
291
+
292
+ // Execute the main function to start the server
293
+ main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nbiish/cognitive-tools-mcp",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "description": "Cognitive Tools MCP: SOTA reasoning suite focused on iterative refinement and tool integration for AI Pair Programming. Enables structured, iterative problem-solving through Chain of Draft methodology, with tools for draft generation, analysis, and refinement. Features advanced deliberation (`think`), rapid checks (`quick_think`), mandatory complexity assessment & thought mode selection (`assess_cuc_n_mode`), context synthesis, confidence gauging, proactive planning, explicit reasoning (CoT), and reflection with content return. Alternative package name for gikendaasowin-aabajichiganan-mcp.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -1,58 +0,0 @@
1
- ---
2
- description:
3
- globs: LICENSE,README.md
4
- alwaysApply: false
5
- ---
6
- # All projects MUST:
7
-
8
-
9
- ## 1. @LICENSE -> ALWAYS RERUN the following command for all codebase licensing and ALWAYS fill out the placeholders in the file:
10
- ```bash
11
- curl -o https://raw.githubusercontent.com/nbiish/license-for-all-works/refs/heads/main/working-LICENSE
12
- ```
13
-
14
- ## 2. [critical.mdc](mdc:.cursor/rules/critical.mdc) -> ALWAYS RERUN the following command for the codebase:
15
- ```bash
16
- curl -o critical.mdc https://raw.githubusercontent.com/nbiish/license-for-all-works/refs/heads/main/.cursor/rules/critical.mdc
17
- ```
18
-
19
- ## 3. @README.md -> ALWAYS UPDATE to a scholarly citation with the following content and ALWAYS fill out the placeholders:
20
- ```bibtex
21
- @misc{<|repo_title|><|current_year=2025|>,
22
- 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},
23
- title/description = {<|repo_title|>},
24
- type_of_work = {Indigenous digital creation/software incorporating traditional knowledge and cultural expressions},
25
- year = {<|current_year|>},
26
- publisher/source/event = {GitHub repository under tribal sovereignty protections},
27
- howpublished = {\url{https://github.com/nbiish/<|repo_title|>}},
28
- note = {Authored and stewarded by ᓂᐲᔥ ᐙᐸᓂᒥᑮ-ᑭᓇᐙᐸᑭᓯ (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 (whose community faced violent dispersal resulting in descendants affiliating with LTBB, GTBOCI, and First Nations in Canada, as detailed in the Preamble), an enrolled member of the sovereign Grand Traverse Band of Ottawa and Chippewa Indians. This work embodies Indigenous intellectual property, traditional knowledge systems (TK), traditional cultural expressions (TCEs), and associated data protected under tribal law, federal Indian law, treaty rights, Indigenous Data Sovereignty principles, and international indigenous rights frameworks including UNDRIP. All usage, benefit-sharing, and data governance are governed by the COMPREHENSIVE RESTRICTED USE LICENSE FOR INDIGENOUS CREATIONS WITH TRIBAL SOVEREIGNTY, DATA SOVEREIGNTY, AND WEALTH RECLAMATION PROTECTIONS.}
29
- }
30
- ```
31
-
32
- ## 4.1 @README.md -> First download the QR code image:
33
- ```bash
34
- curl -o qr-stripe-donation.png https://raw.githubusercontent.com/nbiish/license-for-all-works/8e9b73b269add9161dc04bbdd79f818c40fca14e/qr-stripe-donation.png
35
- ```
36
-
37
- ### 4.2 @README.md -> Then add the following near the top so that it's easthetically pleasing:
38
- ```markdown
39
- <div align="center">
40
- <hr width="50%">
41
-
42
- <h3>Support This Project</h3>
43
- <div style="display: flex; justify-content: center; gap: 20px; margin: 20px 0;">
44
- <div>
45
- <h4>Stripe</h4>
46
- <img src="qr-stripe-donation.png" alt="Scan to donate" width="180"/>
47
- <p><a href="https://donate.stripe.com/3cs29La1j8UGfnObII">Donate via Stripe</a></p>
48
- </div>
49
- <div style="display: flex; align-items: center;">
50
- <a href="https://www.buymeacoffee.com/nbiish"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=nbiish&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff" /></a>
51
- </div>
52
- </div>
53
-
54
- <hr width="50%">
55
- </div>
56
- ```
57
-
58
- ---