@nbiish/cognitive-tools-mcp 0.9.15 → 0.9.17

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 (3) hide show
  1. package/README.md +53 -73
  2. package/build/index.js +103 -214
  3. package/package.json +1 -2
package/README.md CHANGED
@@ -46,12 +46,12 @@ Both packages are maintained in parallel and receive the same updates. You can u
46
46
 
47
47
  ## Features
48
48
 
49
- Provides five cognitive tools for AI agents:
50
- - `think`: Internal workspace for structured analysis and planning
51
- - `chain_of_thought`: Sequential reasoning steps for problem-solving
52
- - `reflection`: Self-critique and improvement of reasoning
53
- - `plan_and_solve`: High-level strategy development
54
- - `chain_of_draft`: Concise, iterative reasoning steps
49
+ Provides a suite of cognitive tools for AI agents, enabling structured reasoning and iterative refinement (v1.2.1 Simplified Set):
50
+ - `assess_cuc_n_mode`: **Mandatory** initial assessment of task complexity (CUC-N) to select cognitive mode (`think` or `quick_think`).
51
+ - `think`: **Mandatory** central hub for comprehensive analysis, planning, verification, and self-correction.
52
+ - `quick_think`: Lightweight cognitive checkpoint for simple, low CUC-N steps or trivial confirmations.
53
+ - `chain_of_thought`: Guides internal generation and logging of detailed, step-by-step reasoning (CoT).
54
+ - `chain_of_draft`: Signals internal generation/refinement and logging of concise drafts (CoD) for efficiency.
55
55
 
56
56
  ## Installation
57
57
 
@@ -95,49 +95,36 @@ Or:
95
95
 
96
96
  ## Tool Descriptions
97
97
 
98
- ### Think Tool
99
- - **Purpose**: MANDATORY core cognitive step for structured deliberation. Use this internal workspace for analysis, planning, verification, risk assessment, and self-correction before ANY action and after using other cognitive tools.
100
- - **Input**: `thought` (string) - Your detailed internal monologue and reasoning. Structure clearly with sections like Analysis, Plan, Verification, Risk Assessment, and Self-Correction.
101
- - **Response Format**:
102
- ```json
103
- {
104
- "content": [{
105
- "type": "text",
106
- "text": "Returns the complete thought content you provided for explicit grounding in the next step"
107
- }]
108
- }
109
- ```
110
-
111
- ### Chain of Thought Tool
112
- - **Purpose**: Generate explicit, sequential reasoning steps for problem-solving
113
- - **Input**:
114
- - `generated_cot_text` (string) - The full, step-by-step Chain of Thought text you generated internally
115
- - `problem_statement` (string) - The original problem statement this CoT addresses
116
- - **Response Format**: Returns the complete CoT text for mandatory analysis in the next step
117
-
118
- ### Reflection Tool
119
- - **Purpose**: Self-critique and improvement of reasoning or plans
120
- - **Input**:
121
- - `generated_critique_text` (string) - The full critique text you generated internally
122
- - `input_reasoning_or_plan` (string) - The original text that was critiqued
123
- - **Response Format**: Returns the complete critique text for mandatory analysis in the next step
124
-
125
- ### Plan and Solve Tool
126
- - **Purpose**: High-level strategy development for complex objectives
127
- - **Input**:
128
- - `generated_plan_text` (string) - The full, structured plan text you generated internally
129
- - `task_objective` (string) - The original high-level task objective this plan addresses
130
- - **Response Format**: Returns the complete plan text for mandatory analysis in the next step
131
-
132
- ### Chain of Draft Tool
133
- - **Purpose**: Concise, iterative reasoning steps for rapid exploration
134
- - **Input**: `problem_statement` (string) - Problem suitable for concise, iterative reasoning
135
- - **Response Format**: Returns a confirmation message; the drafts you generated internally must be analyzed in the next step
136
-
137
- ### Mandatory Pre-Deliberation Assessment
138
- - **Purpose**: Must be called BEFORE initiating significant cognitive processes (`think`) or complex action sequences. Evaluates CUC-N, recommends strategy, commits to next thought mode.
139
- - **Input**: `assessment_and_choice` (string) - Your assessment including Situation Description, CUC-N Ratings, Recommended Strategy, and Selected Mode
140
- - **Response Format**: Returns confirmation with the selected mode
98
+ *(Note: For detailed usage, workflow, and mandatory rules, always refer to [`latest.md`](latest.md))*
99
+
100
+ ### `assess_cuc_n_mode`
101
+ - **Purpose**: **Mandatory Pre-Deliberation Assessment.** Evaluates task Complexity, Uncertainty, Consequence, Novelty (CUC-N) to determine required cognitive depth and initial strategy.
102
+ - **Input**: `assessment_and_choice` (string) - Your structured assessment including Situation Description, CUC-N Ratings, Rationale, Recommended Strategy, and Explicit Mode Selection (`Selected Mode: think` or `Selected Mode: quick_think`).
103
+ - **Follow-up**: Mandatory `think` or `quick_think` (based on selection).
104
+
105
+ ### `think`
106
+ - **Purpose**: **MANDATORY Central Hub for Comprehensive Analysis and Planning.** Called after assessment, `chain_of_thought`/`chain_of_draft` results, or external action results. Use for analysis, planning, reflection, synthesis, confidence assessment.
107
+ - **Input**: `thought` (string) - Your detailed internal monologue covering key cognitive aspects (Analysis, Plan, Verification, Risk, Learning).
108
+ - **Follow-up**: Execute the immediate next action defined in the `## Plan/Decision:` section.
109
+
110
+ ### `quick_think`
111
+ - **Purpose**: Cognitive Checkpoint for streamlined processing and simple confirmations where detailed analysis via `think` is unnecessary. Use ONLY when appropriate (Low CUC-N, trivial steps).
112
+ - **Input**: `brief_thought` (string) - Your concise thought or confirmation.
113
+ - **Follow-up**: Execute the simple next step.
114
+
115
+ ### `chain_of_thought`
116
+ - **Purpose**: Guides *internal generation* and logging of detailed, step-by-step reasoning draft (CoT).
117
+ - **Workflow**: Internally generate CoT -> Call tool.
118
+ - **Input**:
119
+ - `generated_cot_text` (string) - The full CoT draft you generated internally.
120
+ - `problem_statement` (string) - The original problem this CoT addresses.
121
+ - **Follow-up**: Mandatory `think` or `quick_think`.
122
+
123
+ ### `chain_of_draft`
124
+ - **Purpose**: Signals internal generation/refinement and logging of **efficient, concise drafts (CoD)** using note-like steps, symbols, etc.
125
+ - **Workflow**: Internally generate/refine CoD draft(s) -> Call tool.
126
+ - **Input**: `draft_description` (string) - Brief but specific description of the CoD draft(s) generated/refined internally.
127
+ - **Follow-up**: Mandatory `think` or `quick_think`.
141
128
 
142
129
  ## Development
143
130
 
@@ -218,6 +205,8 @@ The script includes robust error handling:
218
205
 
219
206
  Here are some example test cases that demonstrate the cognitive tools using culturally appropriate Anishinaabe concepts. These examples are provided with respect and acknowledgment of Anishinaabe teachings.
220
207
 
208
+ *(Note: These examples show tool invocation structure. The actual content for inputs like `thought`, `generated_cot_text`, etc., must be generated internally by the agent based on the specific task, following the workflows described in `latest.md`.)*
209
+
221
210
  ### Using the MCP Inspector
222
211
 
223
212
  1. Start the MCP Inspector:
@@ -227,62 +216,53 @@ npm run inspector
227
216
 
228
217
  2. Connect to the server and try these example tool calls:
229
218
 
230
- #### Think Tool Example
219
+ #### `assess_cuc_n_mode` Example
231
220
  ```json
232
221
  {
233
- "toolName": "think",
222
+ "toolName": "assess_cuc_n_mode",
234
223
  "arguments": {
235
- "thought": "Analyzing the Seven Grandfather Teachings (Nibwaakaawin - Wisdom, Zaagi'idiwin - Love, Minaadendamowin - Respect, Aakode'ewin - Bravery, Gwayakwaadiziwin - Honesty, Dabaadendiziwin - Humility, Debwewin - Truth) and their application in modern problem-solving:\n\n1. How does Nibwaakaawin guide decision-making?\n2. How can Zaagi'idiwin inform our approach to community?\n3. How does Minaadendamowin shape our relationship with knowledge?"
224
+ "assessment_and_choice": "1) Situation Description: User wants to understand the Anishinaabe concept of Mino-Bimaadiziwin (Living the Good Life).\\n2) CUC-N Ratings: Complexity: Medium (Involves cultural concepts), Uncertainty: Medium (Requires accessing and synthesizing knowledge), Consequence: Medium (Accuracy is important), Novelty: Low (Explaining concepts is common).\\n3) Rationale: Requires careful explanation of interconnected teachings.\\n4) Recommended Initial Strategy: Use chain_of_thought to break down the concept.\\n5) Explicit Mode Selection: Selected Mode: think"
236
225
  }
237
226
  }
238
227
  ```
239
228
 
240
- Example Response:
229
+ #### `think` Tool Example
241
230
  ```json
242
231
  {
243
- "content": [{
244
- "type": "text",
245
- "text": "Analyzing the Seven Grandfather Teachings..."
246
- }]
247
- }
248
- ```
249
-
250
- #### Chain of Thought Example
251
- ```json
252
- {
253
- "toolName": "chain_of_thought",
232
+ "toolName": "think",
254
233
  "arguments": {
255
- "problem_statement": "Understanding the seasonal cycle of maple sugar harvesting (ziigwaage - spring sugar making):\n1. Observe weather patterns and temperature changes\n2. Identify appropriate maple trees\n3. Prepare tools and equipment respectfully\n4. Follow proper protocols for tree tapping\n5. Collect sap with gratitude\n6. Process sap into sugar while sharing teachings"
234
+ "thought": "## Observe:\\nReceived task to explain Mino-Bimaadiziwin. Assessment chose 'think' mode.\\n## Orient:\\nMino-Bimaadiziwin is central to Anishinaabe philosophy, encompassing balance, health, and connection.\\n## Decide:\\nPlan to use chain_of_thought to structure the explanation.\\n## Reason:\\nA step-by-step approach will clarify the components (spiritual, mental, emotional, physical well-being).\\n## Act:\\nInternally generate CoT for Mino-Bimaadiziwin.\\n## Verification:\\nReview generated CoT for accuracy and completeness before calling the tool.\\n## Risk & Contingency:\\nRisk: Misrepresenting cultural concepts (Medium). Contingency: Rely on established knowledge, cross-reference if unsure, state limitations.\\n## Learning & Adaptation:\\nReinforce the need for careful handling of cultural knowledge."
256
235
  }
257
236
  }
258
237
  ```
259
238
 
260
- #### Reflection Example
239
+ #### `quick_think` Example
261
240
  ```json
262
241
  {
263
- "toolName": "reflection",
242
+ "toolName": "quick_think",
264
243
  "arguments": {
265
- "input_reasoning_or_plan": "Reflecting on our relationship with Nibi (water):\n- Understanding water as first medicine\n- Considering our role as water protectors\n- Learning from the teachings of water\n- Examining how we honor water in daily life\n- Planning actions to protect water sources"
244
+ "brief_thought": "Observed successful completion of file read. Task is simple confirmation, no deep analysis needed. Proceeding to next step."
266
245
  }
267
246
  }
268
247
  ```
269
248
 
270
- #### Plan and Solve Example
249
+ #### `chain_of_thought` Example
271
250
  ```json
272
251
  {
273
- "toolName": "plan_and_solve",
252
+ "toolName": "chain_of_thought",
274
253
  "arguments": {
275
- "task_objective": "Planning a community gathering that honors traditional protocols:\n1. Consult with Elders on proper procedures\n2. Select appropriate time based on seasonal calendar\n3. Arrange for traditional foods and medicines\n4. Prepare the gathering space with respect\n5. Ensure proper opening and closing ceremonies\n6. Include time for teaching and sharing"
254
+ "generated_cot_text": "Step 1: Define Mino-Bimaadiziwin - Living in balance and harmony.\\nStep 2: Explain the Four Hills of Life (infancy, youth, adulthood, elderhood) and their connection.\\nStep 3: Discuss the importance of the Seven Grandfather Teachings.\\nStep 4: Relate physical, mental, emotional, spiritual health.\\nStep 5: Emphasize connection to community, land, and spirit.",
255
+ "problem_statement": "Explain the Anishinaabe concept of Mino-Bimaadiziwin."
276
256
  }
277
257
  }
278
258
  ```
279
259
 
280
- #### Chain of Draft Example
260
+ #### `chain_of_draft` Example
281
261
  ```json
282
262
  {
283
263
  "toolName": "chain_of_draft",
284
264
  "arguments": {
285
- "problem_statement": "Learning basic Anishinaabemowin greetings:\n1. Boozhoo (Hello)\n2. Aaniin (Hello/Welcome)\n3. Miigwech (Thank you)\n4. Baamaapii (Until later/Goodbye)\n5. Practice proper pronunciation\n6. Understand cultural context of each greeting"
265
+ "draft_description": "Draft 1: Basic Anishinaabemowin greetings - Boozhoo, Aaniin. Draft 2: Added Miigwech, Baamaapii. Draft 3: Noted pronunciation focus needed."
286
266
  }
287
267
  }
288
268
  ```
package/build/index.js CHANGED
@@ -1,34 +1,33 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * -----------------------------------------------------------------------------
4
- * Gikendaasowin Aabajichiganan - Core Cognitive Tools MCP Server
4
+ * Gikendaasowin Aabajichiganan - Core Cognitive Tools MCP Server (Simplified Core, Relaxed Validation)
5
5
  *
6
- * Version: 0.9.12
7
- *
8
- * Description: Provides a suite of cognitive tools for an AI Pair Programmer,
6
+ * Description: Provides a streamlined suite of cognitive tools for an AI agent,
9
7
  * enabling structured reasoning, planning, analysis, and iterative
10
- * refinement (Chain of Thought, Chain of Draft, Reflection).
11
- * This server focuses on managing the AI's *internal cognitive loop*,
12
- * as described in the Anthropic research on the 'think' tool and
13
- * related cognitive patterns. External actions are planned within
14
- * the 'think' step but executed by the calling environment.
8
+ * refinement, focusing on Chain of Thought and Chain of Draft.
9
+ * This server focuses on managing the AI's *internal cognitive loop*.
10
+ * External actions are planned within the 'think' step but executed
11
+ * by the calling environment. Validation on input content structure
12
+ * is removed. Tool results are returned as formatted Markdown.
13
+ * Refined Chain of Draft guidance. Versioning removed.
15
14
  *
16
15
  * Key Principles:
17
- * 1. **Structured Deliberation:** Tools guide specific cognitive acts (planning,
18
- * reasoning, critique).
16
+ * 1. **Focused Deliberation:** Tools guide specific cognitive acts (assessing,
17
+ * thinking, reasoning via CoT, drafting via CoD).
19
18
  * 2. **Centralized Analysis (`think`):** The `think` tool is mandatory after
20
19
  * most cognitive actions or receiving external results, serving as the hub
21
- * for analysis, planning the *next immediate step*, verification, and
22
- * self-correction.
20
+ * for comprehensive analysis, planning, reflection, synthesis, and confidence
21
+ * assessment. Structure is guided by the prompt, not enforced by the server.
23
22
  * 3. **CUC-N Assessment:** Task characteristics determine the required depth
24
- * of cognition (full `think` vs. `quick_think`).
25
- * 4. **Internal Generation First:** Tools like `plan_and_solve`, `chain_of_thought`,
26
- * `reflection`, and `synthesize_prior_reasoning` are called *after* the AI
27
- * has internally generated the relevant text (plan, CoT, critique, summary).
28
- * The tool logs this generation and returns it, grounding the AI for the
29
- * mandatory `think` analysis step.
30
- * 5. **Iterative Refinement (Chain of Draft):** The `chain_of_draft` tool signals
31
- * internal draft creation/modification, prompting analysis via `think`.
23
+ * of cognition (`think` vs. `quick_think` for initial step and simple results).
24
+ * 4. **Internal Generation First:** `chain_of_thought` and `chain_of_draft`
25
+ * log internal artifacts generated by the LLM.
26
+ * 5. **Iterative Refinement (CoT & CoD):** The `chain_of_thought` and
27
+ * `chain_of_draft` tools signal internal reasoning/drafting, prompting
28
+ * analysis via `think` or `quick_think`.
29
+ * 6. **Traceability:** All tool inputs are logged for a complete record.
30
+ * 7. **Markdown Output:** Tool results are formatted as Markdown for LLM consumption.
32
31
  *
33
32
  * Protocol: Model Context Protocol (MCP) over stdio.
34
33
  * -----------------------------------------------------------------------------
@@ -36,13 +35,13 @@
36
35
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
37
36
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
38
37
  import { z } from "zod";
39
- export const version = "0.9.12";
40
38
  // --- Server Definition ---
41
- const server = new McpServer({
39
+ const serverInfo = {
42
40
  name: "gikendaasowin-aabajichiganan-mcp",
43
- version: version,
44
- description: "ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Core Cognitive Tools Suite v0.9.12: Enables structured, iterative reasoning (Chain of Thought/Draft), planning, and analysis for AI agents, focusing on the cognitive loop. MANDATORY `think` step integrates results."
45
- });
41
+ version: "0.9.16",
42
+ description: `ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Core Cognitive Tools Suite (Simplified, Relaxed Validation): Enables structured reasoning (CoT/CoD) and analysis for AI agents. Returns results as Markdown.`
43
+ };
44
+ const server = new McpServer(serverInfo);
46
45
  // --- Logging Helpers ---
47
46
  /**
48
47
  * Logs an incoming tool call to stderr.
@@ -74,11 +73,11 @@ function logToolError(toolName, error) {
74
73
  const errorMessage = error instanceof Error ? error.message : String(error);
75
74
  console.error(`[${timestamp}] [MCP Server] ! Tool Error: ${toolName} - ${errorMessage}`);
76
75
  logToolResult(toolName, false, errorMessage); // Log failure result as well
77
- // Return a structured error message suitable for the LLM
76
+ // Return a structured error message suitable for the LLM (still as plain text for clarity)
78
77
  return {
79
78
  content: [{
80
79
  type: "text",
81
- text: `Error executing tool '${toolName}': ${errorMessage}.`
80
+ text: `Error executing tool '${toolName}': ${errorMessage}. Please analyze this error.`
82
81
  }]
83
82
  };
84
83
  }
@@ -87,7 +86,7 @@ function logToolError(toolName, error) {
87
86
  * Tool: assess_cuc_n_mode
88
87
  * Purpose: Mandatory initial assessment of task characteristics to determine cognitive strategy.
89
88
  * Workflow: Call BEFORE starting complex tasks or significantly changing strategy.
90
- * Output: Confirms assessment and selected mode (`think` or `quick_think`). Result MUST inform the subsequent cognitive flow.
89
+ * Output: Returns the full assessment text formatted as Markdown.
91
90
  */
92
91
  server.tool("assess_cuc_n_mode", "**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. Based on assessment, use either `think` (for structured analysis) or `quick_think` (for streamlined processing) in the next step.", {
93
92
  assessment_and_choice: z.string().describe("Your structured assessment including: 1) Situation Description, 2) CUC-N Ratings (Low/Medium/High for each), 3) Rationale for ratings, 4) Recommended Initial Cognitive Strategy (e.g., 'Start with chain_of_thought then think'), 5) Explicit Mode Selection ('Selected Mode: think' or 'Selected Mode: quick_think').")
@@ -95,24 +94,20 @@ server.tool("assess_cuc_n_mode", "**Mandatory Pre-Deliberation Assessment.** Eva
95
94
  const toolName = 'assess_cuc_n_mode';
96
95
  logToolCall(toolName);
97
96
  try {
98
- // Enhanced validation using regex for robustness
97
+ // Basic Zod validation ensures it's a string. Content validation removed.
99
98
  const modeRegex = /Selected Mode: (think|quick_think)/i;
100
- const cucnRegex = /CUC-N Ratings:/i;
101
- const strategyRegex = /Recommended Initial Strategy:/i;
102
- if (!assessment_and_choice || typeof assessment_and_choice !== 'string') {
103
- throw new Error('Input must be a non-empty string.');
104
- }
105
- if (!cucnRegex.test(assessment_and_choice)) {
106
- throw new Error('Invalid assessment: String must include "CUC-N Ratings:".');
107
- }
108
99
  const modeMatch = assessment_and_choice.match(modeRegex);
109
- if (!modeMatch || !modeMatch[1]) {
110
- throw new Error('Invalid assessment: String must include explicit "Selected Mode: think" or "Selected Mode: quick_think".');
111
- }
112
- const selectedMode = modeMatch[1].toLowerCase();
113
- logToolResult(toolName, true, `Selected mode: ${selectedMode}`);
114
- console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Assessment Details:\n${assessment_and_choice}`);
115
- return { content: [{ type: "text", text: assessment_and_choice }] };
100
+ const selectedMode = modeMatch ? modeMatch[1].toLowerCase() : "unknown"; // Extract mode for logging
101
+ logToolResult(toolName, true, `Selected mode (extracted): ${selectedMode}`);
102
+ // Log full input for traceability
103
+ console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Input:\n${assessment_and_choice}`);
104
+ // Return the full assessment text formatted as Markdown
105
+ return {
106
+ content: [{
107
+ type: "text",
108
+ text: "```markdown\n" + assessment_and_choice + "\n```"
109
+ }]
110
+ };
116
111
  }
117
112
  catch (error) {
118
113
  return logToolError(toolName, error);
@@ -120,45 +115,33 @@ server.tool("assess_cuc_n_mode", "**Mandatory Pre-Deliberation Assessment.** Eva
120
115
  });
121
116
  /**
122
117
  * Tool: think
123
- * Purpose: The **CENTRAL HUB** for the cognitive loop, incorporating OODReAct principles (Observe-Orient-Decide-Reason-Act).
124
- * Workflow: Combines observation, orientation, decision-making, reasoning, and action for enhanced problem-solving.
125
- * Output: Returns the structured thought text itself, grounding the AI's reasoning process in the context.
118
+ * Purpose: The **CENTRAL, COMPREHENSIVE HUB** for the cognitive loop. Incorporates OODReAct principles.
119
+ * Workflow: Handles all complex analysis, planning, reflection, synthesis, and confidence assessment. Structure is guided by the prompt.
120
+ * Output: Returns the structured thought text itself, formatted as Markdown.
126
121
  */
127
- server.tool("think", "**MANDATORY Central Hub for Analysis and Planning.** Called after assessment (`assess_cuc_n_mode`), other cognitive tools (`plan_and_solve`, `chain_of_thought`, `chain_of_draft`, `reflection`, `synthesize_prior_reasoning`, `gauge_confidence`), internal drafts (`chain_of_draft`), or external action results. Incorporates OODReAct principles (Observe-Orient-Decide-Reason-Act) for enhanced problem-solving. Consider structuring your thought process to: 1) Observe new information and changes, 2) Orient by analyzing context and patterns, 3) Decide on potential actions, 4) Reason through implications and alternatives, and 5) Act by planning specific execution steps. Follow the MANDATORY structure in the `thought` parameter. For simpler follow-up steps, consider using `quick_think` instead.", {
128
- thought: z.string().describe("Your **detailed** internal monologue. While any clear, structured format is accepted, consider following OODReAct principles in your thinking:\n- Observe: What new information/signals are available?\n- Orient: How does this fit into the bigger picture?\n- Decide: What are the potential actions to take?\n- Reason: What are the implications and alternatives?\n- Act: How to execute the chosen action?\n\nRequired sections:\n## Analysis/Observation\n## Plan/Decision\n## Verification\n## Risk & Contingency\n## Learning & Adaptation")
122
+ server.tool("think", "**MANDATORY Central Hub for Comprehensive Analysis and Planning.** Called after assessment (`assess_cuc_n_mode`), after `chain_of_thought` or `chain_of_draft` results, or after external action results/errors. Incorporates OODReAct principles (Observe-Orient-Decide-Reason-Act) for enhanced problem-solving. This is where you perform ALL detailed analysis, planning (including multi-step strategies), reflection, synthesis, and confidence assessment. Structure your thought clearly using headings. For simpler follow-up steps, consider using `quick_think` instead.", {
123
+ thought: z.string().describe("Your **detailed** internal monologue covering Analysis/Observation, Plan/Decision, Verification, Risk & Contingency, and Learning & Adaptation. Use clear headings. OODReAct-style headers are recommended.")
129
124
  }, async ({ thought }) => {
130
125
  const toolName = 'think';
131
126
  logToolCall(toolName);
132
127
  try {
133
- if (!thought || typeof thought !== 'string' || thought.trim().length === 0) {
128
+ // Basic Zod validation ensures it's a non-empty string. Content validation removed.
129
+ if (thought.trim().length === 0) {
134
130
  throw new Error('Invalid thought: Must be a non-empty string containing substantive reasoning.');
135
131
  }
136
- // Define required sections (more flexible now)
137
- const requiredSections = [
138
- ["## Analysis:", "## Observe:", "## Observation:"],
139
- ["## Orient:", "## Orientation:"],
140
- ["## Plan:", "## Decide:", "## Decision:"],
141
- ["## Reason:", "## Reasoning:", "## Analysis:"],
142
- ["## Act:", "## Action:", "## Execution:"],
143
- ["## Verification:"],
144
- ["## Risk & Contingency:", "## Risks:", "## Challenges:"],
145
- ["## Learning & Adaptation:", "## Self-Correction:", "## Learning:"]
146
- ];
147
- const missingSections = requiredSections.filter(sectionGroup => !sectionGroup.some(section => thought.includes(section)));
148
- let validationReport = [];
149
- if (missingSections.length > 0) {
150
- validationReport.push("WARNING: Some recommended sections might be missing. Consider including observation, orientation, decision, reasoning, action, verification, risks, and learning components in your thought process.");
151
- }
152
- if (validationReport.length > 0) {
153
- console.warn(`[${new Date().toISOString()}] [CognitiveToolsServer] Think Tool Validation Report:\n${validationReport.join("\n")}`);
154
- }
155
- const format = thought.includes("## Observe:") ? "OODReAct-style" : "Traditional";
156
- logToolResult(toolName, true, `Thought logged (Style: ${format}, Length: ${thought.length})`);
132
+ logToolResult(toolName, true, `Thought logged (length: ${thought.length})`);
133
+ // Log full input for traceability
134
+ console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Input:\n${thought}`);
135
+ // Returns the same thought text received, formatted as Markdown.
157
136
  return {
158
- content: [{ type: "text", text: thought }]
137
+ content: [{
138
+ type: "text",
139
+ text: "```markdown\n" + thought + "\n```"
140
+ }]
159
141
  };
160
142
  }
161
143
  catch (error) {
144
+ // Use logToolError to format the error for the LLM
162
145
  return logToolError(toolName, error);
163
146
  }
164
147
  });
@@ -166,7 +149,7 @@ server.tool("think", "**MANDATORY Central Hub for Analysis and Planning.** Calle
166
149
  * Tool: quick_think
167
150
  * Purpose: A lightweight cognitive checkpoint for streamlined processing and simple confirmations.
168
151
  * Workflow: Use when full structured analysis via `think` is not necessary.
169
- * Output: Logs the brief thought.
152
+ * Output: Returns the brief thought text, formatted as Markdown.
170
153
  */
171
154
  server.tool("quick_think", "Cognitive Checkpoint for streamlined processing and simple confirmations where detailed analysis via `think` is unnecessary. Use when full structured deliberation would be excessive for the current step.", {
172
155
  brief_thought: z.string().describe("Your **concise** thought or confirmation for this step. Briefly state the observation/action and explain why detailed analysis isn't needed.")
@@ -174,40 +157,20 @@ server.tool("quick_think", "Cognitive Checkpoint for streamlined processing and
174
157
  const toolName = 'quick_think';
175
158
  logToolCall(toolName);
176
159
  try {
177
- if (!brief_thought || typeof brief_thought !== 'string' || brief_thought.trim().length === 0) {
160
+ // Basic Zod validation ensures it's a non-empty string. Content validation removed.
161
+ if (brief_thought.trim().length === 0) {
178
162
  throw new Error('Invalid brief_thought: Must be a non-empty string.');
179
163
  }
180
164
  logToolResult(toolName, true, `Logged: ${brief_thought.substring(0, 80)}...`);
181
- return { content: [{ type: "text", text: brief_thought }] };
182
- }
183
- catch (error) {
184
- return logToolError(toolName, error);
185
- }
186
- });
187
- /**
188
- * Tool: gauge_confidence
189
- * Purpose: Meta-Cognitive Checkpoint to explicitly state confidence in a preceding analysis, plan, or draft.
190
- * Workflow: Generate assessment -> Call this tool with assessment text -> Follow with either `think` or `quick_think`.
191
- * Output: Confirms confidence gauging and level.
192
- */
193
- server.tool("gauge_confidence", "Meta-Cognitive Checkpoint. Guides *internal stating* of **confidence (High/Medium/Low) and justification** regarding a specific plan, analysis, or draft you just formulated. Call this tool *with* the text containing your confidence assessment. Follow with either `think` (for detailed analysis) or `quick_think` (for straightforward confirmation) based on the confidence level and complexity.", {
194
- assessment_and_confidence: z.string().describe("The text containing the item being assessed AND your explicit internal assessment: 1) Confidence Level: (High/Medium/Low). 2) Justification for this level.")
195
- }, async ({ assessment_and_confidence }) => {
196
- const toolName = 'gauge_confidence';
197
- logToolCall(toolName);
198
- try {
199
- const confidenceRegex = /Confidence Level: (High|Medium|Low)/i;
200
- if (!assessment_and_confidence || typeof assessment_and_confidence !== 'string') {
201
- throw new Error('Input must be a non-empty string.');
202
- }
203
- const match = assessment_and_confidence.match(confidenceRegex);
204
- if (!match || !match[1]) {
205
- throw new Error('Invalid confidence assessment: String must include "Confidence Level: High/Medium/Low" and justification.');
206
- }
207
- const level = match[1];
208
- logToolResult(toolName, true, `Level: ${level}`);
209
- console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Confidence Details:\n${assessment_and_confidence}`);
210
- return { content: [{ type: "text", text: assessment_and_confidence }] };
165
+ // Log full input for traceability
166
+ console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Input:\n${brief_thought}`);
167
+ // Return the brief thought text, formatted as Markdown
168
+ return {
169
+ content: [{
170
+ type: "text",
171
+ text: "```markdown\n" + brief_thought + "\n```"
172
+ }]
173
+ };
211
174
  }
212
175
  catch (error) {
213
176
  return logToolError(toolName, error);
@@ -215,59 +178,34 @@ server.tool("gauge_confidence", "Meta-Cognitive Checkpoint. Guides *internal sta
215
178
  });
216
179
  /**
217
180
  * Tool: chain_of_thought
218
- * Purpose: Guides *internal generation* of detailed, step-by-step reasoning draft (CoT).
181
+ * Purpose: Guides *internal generation* and logging of detailed, step-by-step reasoning draft (CoT).
219
182
  * Workflow: Generate CoT -> Call this tool with CoT text -> Follow with either `think` or `quick_think`.
220
- * Output: Returns the CoT text for analysis.
183
+ * Output: Returns the CoT text formatted as Markdown.
221
184
  */
222
- server.tool("chain_of_thought", "Guides *internal generation* of **detailed, step-by-step reasoning draft (CoT)**. Call this tool *with* the generated CoT text you created internally. Returns the CoT text. Follow with either `think` (for complex reasoning chains requiring detailed analysis) or `quick_think` (for straightforward reasoning steps) to process the CoT and plan next actions.", {
185
+ server.tool("chain_of_thought", "Guides *internal generation* and logging of **detailed, step-by-step reasoning draft (CoT)**. Call this tool *with* the generated CoT text you created internally. Returns the CoT text formatted as Markdown. Follow with either `think` (for complex reasoning chains requiring detailed analysis) or `quick_think` (for straightforward reasoning steps) to process the CoT and plan next actions.", {
223
186
  generated_cot_text: z.string().describe("The **full, step-by-step Chain of Thought draft** you generated internally to solve or analyze the problem."),
224
187
  problem_statement: z.string().describe("The original problem statement or question this CoT addresses.")
225
188
  }, async ({ generated_cot_text, problem_statement }) => {
226
189
  const toolName = 'chain_of_thought';
227
190
  logToolCall(toolName);
228
191
  try {
229
- if (!generated_cot_text || typeof generated_cot_text !== 'string' || !problem_statement || typeof problem_statement !== 'string') {
230
- throw new Error('Both generated_cot_text and problem_statement must be non-empty strings.');
192
+ // Basic Zod validation ensures non-empty strings. Content validation removed.
193
+ if (generated_cot_text.trim().length === 0) {
194
+ throw new Error('Invalid generated_cot_text: Must be a non-empty string containing the CoT.');
231
195
  }
232
- if (!generated_cot_text.match(/step|phase|:\s|^\d+[\.\)]/im)) {
233
- throw new Error('Invalid CoT format: Must contain clear reasoning steps (numbered, labeled as steps/phases, or with clear delineation).');
196
+ if (problem_statement.trim().length === 0) {
197
+ throw new Error('Invalid problem_statement: Must provide the original problem.');
234
198
  }
235
199
  logToolResult(toolName, true, `Problem: ${problem_statement.substring(0, 50)}...`);
236
- console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Details:\nProblem: ${problem_statement}\nReasoning:\n${generated_cot_text}`);
237
- return { content: [{ type: "text", text: generated_cot_text }] };
238
- }
239
- catch (error) {
240
- return logToolError(toolName, error);
241
- }
242
- });
243
- /**
244
- * Tool: plan_and_solve
245
- * Purpose: Guides *internal generation* of a structured plan draft.
246
- * Workflow: Generate plan -> Call this tool with plan text -> Follow with either `think` or `quick_think`.
247
- * Output: Returns the plan text for analysis.
248
- */
249
- server.tool("plan_and_solve", "Guides *internal generation* of a **structured plan draft**. Call this tool *with* the generated plan text you created internally. Returns the plan text. Follow with either `think` (for complex plans requiring detailed analysis) or `quick_think` (for straightforward plans) to evaluate feasibility and confirm next steps.", {
250
- generated_plan_text: z.string().describe("The **full, structured plan draft** you generated internally, including goals, steps, potential external tool needs, assumptions, and risks."),
251
- task_objective: z.string().describe("The original high-level task objective this plan addresses.")
252
- }, async ({ generated_plan_text, task_objective }) => {
253
- const toolName = 'plan_and_solve';
254
- logToolCall(toolName);
255
- try {
256
- if (!generated_plan_text || typeof generated_plan_text !== 'string' || !task_objective || typeof task_objective !== 'string') {
257
- throw new Error("Missing or invalid required parameters: 'generated_plan_text' and 'task_objective' must be non-empty strings.");
258
- }
259
- // Basic structure check (optional, less strict)
260
- // if (!generated_plan_text.match(/phase|step|goal|objective|:\\s|^\\d+[\\.\\)]/im)) {
261
- // console.warn(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Warning: Plan structure might be basic. Consider using clear steps/phases.`);
262
- // }
263
- // Removed strict validation for risk/challenge
264
- // if (!generated_plan_text.toLowerCase().includes('risk') && !generated_plan_text.toLowerCase().includes('challenge')) {
265
- // throw new Error("Invalid plan format: Must include risk/challenge assessment.");
266
- // }
267
- logToolResult(toolName, true, `Task: ${task_objective.substring(0, 50)}...`);
268
- console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Details:\nTask: ${task_objective}\nPlan:\n${generated_plan_text}`);
269
- // Return the plan text directly (potentially formatted as markdown if needed, but currently just text)
270
- return { content: [{ type: "text", text: generated_plan_text }] };
200
+ // Log full input for traceability
201
+ console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Input:\nProblem: ${problem_statement}\nReasoning:\n${generated_cot_text}`);
202
+ // Return the CoT text, formatted as Markdown
203
+ return {
204
+ content: [{
205
+ type: "text",
206
+ text: "```markdown\n" + generated_cot_text + "\n```"
207
+ }]
208
+ };
271
209
  }
272
210
  catch (error) {
273
211
  return logToolError(toolName, error);
@@ -275,79 +213,30 @@ server.tool("plan_and_solve", "Guides *internal generation* of a **structured pl
275
213
  });
276
214
  /**
277
215
  * Tool: chain_of_draft
278
- * Purpose: Signals that internal drafts have been generated/refined using Chain of Draft (CoD) principles.
279
- * Workflow: Internally generate/refine concise draft(s) -> Call this tool -> Follow with either `think` or `quick_think`.
280
- * Best Practices from Research:
281
- * - Keep each draft step short (< 5 words) like human notes
282
- * - Use equations, symbols, or brief phrases instead of sentences
283
- * - Focus on essential information only
284
- * - End with #### followed by final answer/conclusion
285
- * Output: Returns markdown-formatted response with CoD guidance and next tool recommendation.
216
+ * Purpose: Signals that internal drafts have been generated/refined using Chain of Draft (CoD) principles for efficient, concise reasoning.
217
+ * Workflow: Internally generate/refine concise draft(s) following CoD guidelines -> Call this tool with a description -> Follow with either `think` or `quick_think`.
218
+ * Output: Returns the draft description formatted as Markdown.
286
219
  */
287
- server.tool("chain_of_draft", "Signals that one or more **internal drafts** have been generated/refined using Chain of Draft (CoD) principles. CoD is an efficient prompting technique that uses concise, note-like drafts instead of full sentences. Best practices:\n- Keep each step short (< 5 words)\n- Use equations/symbols when possible\n- Focus on essential information\n- End with #### followed by conclusion\n\nCall this tool *after* generating/refining draft(s) internally. Returns markdown-formatted response with next tool recommendation. Follow with either `think` (for complex drafts requiring detailed analysis) or `quick_think` (for straightforward drafts) to evaluate and plan next steps.", {
288
- draft_description: z.string().describe("Brief but specific description of the draft(s) generated/refined internally (e.g., 'Initial API function - params defined', 'Error handling v2', 'README structure').")
220
+ server.tool("chain_of_draft", "Signals that one or more **internal drafts** have been generated/refined using **Chain of Draft (CoD)** principles. CoD aims for **maximum efficiency** by mimicking human note-taking, focusing on minimal token usage while preserving reasoning quality. Use this *instead of* detailed Chain of Thought when speed and token economy are important, or when the reasoning involves calculations or symbolic manipulation.\n\n**How to Construct SOTA CoD Internally:**\n1. **Extreme Conciseness:** Each reasoning step or draft element should be extremely brief (e.g., often just 1-5 words, like a quick note). AVOID full sentences.\n2. **Symbols & Equations:** Prioritize mathematical notation (e.g., `x = 5*y`, `area = l*w`), code snippets (e.g., `user.id`, `config['key']`), or recognized symbols over descriptive text.\n3. **Essential Information Only:** Capture only the absolute minimum information needed to proceed. Omit explanations, justifications, or restatements of the problem unless strictly necessary for the next step.\n4. **Structure:** Can be a sequence of short phrases, key values, equations, or code elements, often line-by-line. Think 'scratchpad' not 'essay'.\n5. **Contrast with CoT:** Unlike CoT's verbose explanations, CoD focuses purely on the *result* or *key element* of each reasoning step.\n6. **Final Answer (Optional but Recommended):** If the CoD sequence leads directly to a final answer, clearly mark it at the end, often using `#### Final Answer: [answer]`.\n\nCall this tool *after* generating/refining draft(s) internally following these guidelines. Provide a brief description of the draft's purpose. Returns the description formatted as Markdown. Follow with either `think` (for complex drafts requiring detailed analysis) or `quick_think` (for straightforward drafts) to evaluate and plan next steps.", {
221
+ draft_description: z.string().describe("Brief but specific description of the CoD draft(s) generated/refined internally (e.g., 'Calculated intermediate values x, y', 'API call structure draft', 'Error handling logic sketch', 'Key parameters extracted').")
289
222
  }, async ({ draft_description }) => {
290
223
  const toolName = 'chain_of_draft';
291
224
  logToolCall(toolName, `Description: ${draft_description}`);
292
225
  try {
293
- if (!draft_description || typeof draft_description !== 'string' || draft_description.trim().length === 0) {
226
+ // Basic Zod validation ensures non-empty string. Content validation removed.
227
+ if (draft_description.trim().length === 0) {
294
228
  throw new Error('Invalid draft_description: Must provide a description.');
295
229
  }
296
230
  logToolResult(toolName, true);
297
- return { content: [{ type: "text", text: draft_description }] };
298
- }
299
- catch (error) {
300
- return logToolError(toolName, error);
301
- }
302
- });
303
- /**
304
- * Tool: reflection
305
- * Purpose: Guides *internal generation* of a critical self-evaluation (critique) on a prior step, draft, plan, or outcome.
306
- * Call this tool *with* the **generated critique text** you created internally.
307
- * Returns the critique text.
308
- * Follow with either `think` or `quick_think` to process the critique.
309
- */
310
- server.tool("reflection", "Guides *internal generation* of a critical self-evaluation (critique) on a prior step, draft, plan, or outcome. Call this tool *with* the **generated critique text** you created internally. Returns the critique text. Follow with either `think` (for complex critiques requiring detailed analysis) or `quick_think` (for straightforward critiques) to process the feedback and plan improvements.", {
311
- generated_critique_text: z.string().describe("The **full critique text** you generated internally, identifying specific flaws, strengths, assumptions, alternative approaches, and concrete suggestions for improvement."),
312
- input_subject_description: z.string().describe("A brief description of the original reasoning, plan, code draft, or action result that was critiqued (e.g., 'Critique of the plan generated via plan_and_solve', 'Reflection on the CoT for problem X').")
313
- }, async ({ generated_critique_text, input_subject_description }) => {
314
- const toolName = 'reflection';
315
- logToolCall(toolName, `Subject: ${input_subject_description}`);
316
- try {
317
- if (!generated_critique_text || typeof generated_critique_text !== 'string' || generated_critique_text.trim().length === 0) {
318
- throw new Error('Invalid generated_critique_text: Must be a non-empty string containing the critique.');
319
- }
320
- if (!input_subject_description || typeof input_subject_description !== 'string' || input_subject_description.trim().length === 0) {
321
- throw new Error('Invalid input_subject_description: Must describe what was critiqued.');
322
- }
323
- logToolResult(toolName, true, `Critique length: ${generated_critique_text.length}`);
324
- return { content: [{ type: "text", text: generated_critique_text }] };
325
- }
326
- catch (error) {
327
- return logToolError(toolName, error);
328
- }
329
- });
330
- /**
331
- * Tool: synthesize_prior_reasoning
332
- * Purpose: Context Management Tool. Guides the *internal generation* of a structured summary of preceding context.
333
- * Workflow: Internally generate summary -> Call this tool *with* the summary text -> Follow with either `think` or `quick_think`.
334
- * Output: Returns the provided summary text for grounding and analysis.
335
- */
336
- server.tool("synthesize_prior_reasoning", "Context Management Tool. Guides *internal generation* of a **structured summary** of preceding steps, decisions, key findings, or relevant context to consolidate understanding before proceeding. Call this tool *with* the generated summary text you created internally. Returns the summary. Follow with either `think` (for complex context requiring detailed analysis) or `quick_think` (for straightforward context) to leverage this summary and inform next actions.", {
337
- generated_summary_text: z.string().describe("The **full, structured summary text** you generated internally (e.g., key decisions made, open questions, current state of implementation, relevant facts gathered)."),
338
- context_to_summarize_description: z.string().describe("Description of the reasoning span or context that was summarized (e.g., 'Summary of the last 5 steps', 'Consolidated findings from tool results A and B').")
339
- }, async ({ generated_summary_text, context_to_summarize_description }) => {
340
- const toolName = 'synthesize_prior_reasoning';
341
- logToolCall(toolName, `Context: ${context_to_summarize_description}`);
342
- try {
343
- if (!generated_summary_text || typeof generated_summary_text !== 'string' || generated_summary_text.trim().length === 0) {
344
- throw new Error('Invalid generated_summary_text: Must be a non-empty string containing the summary.');
345
- }
346
- if (!context_to_summarize_description || typeof context_to_summarize_description !== 'string' || context_to_summarize_description.trim().length === 0) {
347
- throw new Error('Invalid context_to_summarize_description: Must describe what was summarized.');
348
- }
349
- logToolResult(toolName, true, `Summary length: ${generated_summary_text.length}`);
350
- return { content: [{ type: "text", text: generated_summary_text }] };
231
+ // Log full input for traceability
232
+ console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Input:\nDescription: ${draft_description}`);
233
+ // Return the draft description, formatted as Markdown
234
+ return {
235
+ content: [{
236
+ type: "text",
237
+ text: "```markdown\n" + draft_description + "\n```"
238
+ }]
239
+ };
351
240
  }
352
241
  catch (error) {
353
242
  return logToolError(toolName, error);
@@ -393,8 +282,8 @@ async function main() {
393
282
  await server.connect(transport);
394
283
  const border = '-----------------------------------------------------';
395
284
  console.error(border);
396
- console.error(` ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Core Cognitive Tools Suite v0.9.12: Enables structured, iterative reasoning (Chain of Thought/Draft), planning, and analysis for AI agents, focusing on the cognitive loop. MANDATORY \`think\` step integrates results.`);
397
- console.error(` Version: ${version}`);
285
+ console.error(` ${serverInfo.description}`);
286
+ // Version logging removed from startup message
398
287
  console.error(' Status: Running on stdio, awaiting MCP requests...');
399
288
  console.error(border);
400
289
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nbiish/cognitive-tools-mcp",
3
- "version": "0.9.15",
3
+ "version": "0.9.17",
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",
@@ -16,7 +16,6 @@
16
16
  ],
17
17
  "scripts": {
18
18
  "build": "tsc && node -e \"require('fs').chmodSync('build/index.js', '755')\"",
19
- "prepare": "npm run build",
20
19
  "watch": "tsc --watch",
21
20
  "inspector": "npx @modelcontextprotocol/inspector build/index.js",
22
21
  "start": "node build/index.js",