@nbiish/cognitive-tools-mcp 0.9.8 → 0.9.10

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 (4) hide show
  1. package/LICENSE +437 -52
  2. package/README.md +74 -10
  3. package/build/index.js +128 -67
  4. package/package.json +2 -2
package/README.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @nbiish/gikendaasowin-aabajichiganan-mcp
2
2
 
3
+ ```bibtex
4
+ @misc{gikendaasowin-aabajichiganan-mcp2025,
5
+ author/creator/steward = {ᓂᐲᔥ ᐙᐸᓂᒥᑮ-ᑭᓇᐙᐸᑭᓯ (Nbiish Waabanimikii-Kinawaabakizi), also known legally as JUSTIN PAUL KENWABIKISE, professionally documented as Nbiish-Justin Paul Kenwabikise, Anishinaabek Dodem (Anishinaabe Clan): Animikii (Thunder), descendant of Chief ᑭᓇᐙᐸᑭᓯ (Kinwaabakizi) of the Beaver Island Band and enrolled member of the sovereign Grand Traverse Band of Ottawa and Chippewa Indians},
6
+ title/description = {gikendaasowin-aabajichiganan-mcp},
7
+ type_of_work = {Indigenous digital creation/software incorporating traditional knowledge and cultural expressions},
8
+ year = {2025},
9
+ publisher/source/event = {GitHub repository under tribal sovereignty protections},
10
+ howpublished = {\url{https://github.com/nbiish/gikendaasowin-aabajichiganan-mcp}},
11
+ 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 and 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.}
12
+ }
13
+ ```
14
+
15
+ Copyright © 2025 ᓂᐲᔥ ᐙᐸᓂᒥᑮ-ᑭᓇᐙᐸᑭᓯ (Nbiish Waabanimikii-Kinawaabakizi), also known legally as JUSTIN PAUL KENWABIKISE, professionally documented as Nbiish-Justin Paul Kenwabikise, Anishinaabek Dodem (Anishinaabe Clan): Animikii (Thunder), a descendant of Chief ᑭᓇᐙᐸᑭᓯ (Kinwaabakizi) of the Beaver Island Band, and an enrolled member of the sovereign Grand Traverse Band of Ottawa and Chippewa Indians. This work embodies Traditional Knowledge and Traditional Cultural Expressions. All rights reserved.
16
+
17
+ This project is licensed under the [COMPREHENSIVE RESTRICTED USE LICENSE FOR INDIGENOUS CREATIONS WITH TRIBAL SOVEREIGNTY, DATA SOVEREIGNTY, AND WEALTH RECLAMATION PROTECTIONS](LICENSE).
18
+
3
19
  <div align="center">
4
20
  <hr width="50%">
5
21
 
@@ -142,6 +158,62 @@ npm start
142
158
  ./scripts/publish-both-packages.sh # Publishes both package versions automatically
143
159
  ```
144
160
 
161
+ ## Publishing Both Packages
162
+
163
+ This project maintains two npm packages that must be kept in sync:
164
+ - `@nbiish/gikendaasowin-aabajichiganan-mcp`
165
+ - `@nbiish/cognitive-tools-mcp`
166
+
167
+ ### Prerequisites
168
+ - Node.js >=14.0.0
169
+ - npm
170
+ - jq (for version management)
171
+
172
+ ### Publishing Process
173
+
174
+ The `scripts/publish-both-packages.sh` script handles publishing both packages. It includes several safety features:
175
+
176
+ 1. Version Synchronization Check
177
+ - Automatically verifies both packages have matching versions
178
+ - Prevents publishing if versions don't match
179
+
180
+ 2. Error Recovery
181
+ - Automatic cleanup of temporary files
182
+ - Restores original package.json on failure
183
+
184
+ 3. Version Management
185
+ - Optional automatic version bumping
186
+ - Ensures both packages maintain the same version
187
+
188
+ ### Usage
189
+
190
+ Basic publishing:
191
+ ```bash
192
+ npm run publish-both
193
+ ```
194
+
195
+ Publishing with version bump:
196
+ ```bash
197
+ ./scripts/publish-both-packages.sh -b
198
+ ```
199
+
200
+ The script will:
201
+ 1. Check for required dependencies
202
+ 2. Verify version synchronization
203
+ 3. Optionally bump versions (with -b flag)
204
+ 4. Prompt for NPM OTP code
205
+ 5. Build the project
206
+ 6. Publish both packages
207
+ 7. Clean up temporary files
208
+
209
+ ### Error Handling
210
+
211
+ The script includes robust error handling:
212
+ - Checks for required tools (jq)
213
+ - Validates version synchronization
214
+ - Automatic cleanup on failure
215
+ - Preserves original files
216
+
145
217
  ## Test Examples
146
218
 
147
219
  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.
@@ -215,26 +287,18 @@ Example Response:
215
287
  }
216
288
  ```
217
289
 
218
- ## Copyright
219
-
220
- Copyright © 2025 ᓂᐲᔥ ᐙᐸᓂᒥᑮ-ᑭᓇᐙᐸᑭᓯ (Nbiish Waabanimikii-Kinawaabakizi), also known legally as JUSTIN PAUL KENWABIKISE, professionally documented as Nbiish-Justin Paul Kenwabikise, Anishinaabek Dodem (Anishinaabe Clan): Animikii (Thunder), a descendant of Chief ᑭᓇᐙᐸᑭᓯ (Kinwaabakizi) of the Beaver Island Band, and an enrolled member of the sovereign Grand Traverse Band of Ottawa and Chippewa Indians. All rights reserved.
221
-
222
- ## License
223
-
224
- This work is licensed under the [COMPREHENSIVE RESTRICTED USE LICENSE FOR INDIGENOUS CREATIONS WITH TRIBAL SOVEREIGNTY, DATA SOVEREIGNTY, AND WEALTH RECLAMATION PROTECTIONS](https://github.com/nbiish/license-for-all-works/blob/main/LICENSE).
225
-
226
290
  ## Citation
227
291
 
228
292
  Please cite this project using the following BibTeX entry:
229
293
 
230
294
  ```bibtex
231
295
  @misc{gikendaasowin-aabajichiganan-mcp2025,
232
- 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},
296
+ author/creator/steward = {ᓂᐲᔥ ᐙᐸᓂᒥᑮ-ᑭᓇᐙᐸᑭᓯ (Nbiish Waabanimikii-Kinawaabakizi), also known legally as JUSTIN PAUL KENWABIKISE, professionally documented as Nbiish-Justin Paul Kenwabikise, Anishinaabek Dodem (Anishinaabe Clan): Animikii (Thunder), descendant of Chief ᑭᓇᐙᐸᑭᓯ (Kinwaabakizi) of the Beaver Island Band and enrolled member of the sovereign Grand Traverse Band of Ottawa and Chippewa Indians},
233
297
  title/description = {gikendaasowin-aabajichiganan-mcp},
234
298
  type_of_work = {Indigenous digital creation/software incorporating traditional knowledge and cultural expressions},
235
299
  year = {2025},
236
300
  publisher/source/event = {GitHub repository under tribal sovereignty protections},
237
301
  howpublished = {\url{https://github.com/nbiish/gikendaasowin-aabajichiganan-mcp}},
238
- 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.}
302
+ 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 and 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.}
239
303
  }
240
304
  ```
package/build/index.js CHANGED
@@ -89,7 +89,7 @@ function logToolError(toolName, error) {
89
89
  * Workflow: Call BEFORE starting complex tasks or significantly changing strategy.
90
90
  * Output: Confirms assessment and selected mode (`think` or `quick_think`). Result MUST inform the subsequent cognitive flow.
91
91
  */
92
- 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. Selects 'think' (default) or 'quick_think' (only for verified Low CUC-N).", {
92
+ 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
93
  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').")
94
94
  }, async ({ assessment_and_choice }) => {
95
95
  const toolName = 'assess_cuc_n_mode';
@@ -127,29 +127,56 @@ server.tool("assess_cuc_n_mode", "**Mandatory Pre-Deliberation Assessment.** Eva
127
127
  });
128
128
  /**
129
129
  * Tool: think
130
- * Purpose: The **CENTRAL HUB** for the cognitive loop. Mandatory after assessment, other cognitive tools, internal drafts, or external action results.
131
- * Workflow: Analyze previous step -> Plan immediate next step -> Verify -> Assess Risk -> Self-Correct.
130
+ * Purpose: The **CENTRAL HUB** for the cognitive loop, incorporating OODReAct principles (Observe-Orient-Decide-Reason-Act).
131
+ * Workflow: Combines observation, orientation, decision-making, reasoning, and action for enhanced problem-solving.
132
132
  * Output: Returns the structured thought text itself, grounding the AI's reasoning process in the context.
133
133
  */
134
- server.tool("think", "**MANDATORY Central Hub for Analysis, Planning, and Refinement.** Called after assessment, other cognitive tools (`plan_and_solve`, `chain_of_thought`, etc.), internal drafts (`chain_of_draft`), or external action results. Analyzes previous step's outcome/draft, plans the *immediate* next action (cognitive or planning external action), verifies plan, assesses risk/challenges, looks ahead, and self-corrects. Follow the MANDATORY structure in the `thought` parameter.", {
135
- thought: z.string().describe("Your **detailed** internal monologue following the MANDATORY structure: ## Analysis: (Critically evaluate last result/draft/observation. What worked? What didn't? What are the implications?), ## Plan: (Define the *single, immediate* next action and its specific purpose. Is it calling another cognitive tool, generating a draft, planning an external action, or concluding?), ## Verification: (How will you confirm the next step is correct or successful?), ## Anticipated Challenges & Contingency: (What could go wrong with the next step? How will you handle it?), ## Risk Assessment: (Briefly assess risk of the planned step - Low/Medium/High), ## Lookahead: (How does this step fit into the overall goal?), ## Self-Correction & Learning: (Any adjustments needed based on the analysis? What was learned?).")
134
+ 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.", {
135
+ 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")
136
136
  }, async ({ thought }) => {
137
137
  const toolName = 'think';
138
138
  logToolCall(toolName);
139
139
  try {
140
140
  if (!thought || typeof thought !== 'string' || thought.trim().length === 0) {
141
- throw new Error('Invalid thought: Must be a non-empty string containing the structured analysis and plan.');
141
+ throw new Error('Invalid thought: Must be a non-empty string containing substantive reasoning.');
142
142
  }
143
- // Basic structural check (case-insensitive) - Warning, not strict failure
144
- const requiredSections = ["## Analysis:", "## Plan:", "## Verification:", "## Anticipated Challenges & Contingency:", "## Risk Assessment:", "## Lookahead:", "## Self-Correction & Learning:"];
145
- const missingSections = requiredSections.filter(section => !thought.toLowerCase().includes(section.toLowerCase()));
143
+ // Define required sections (more flexible now)
144
+ const requiredSections = [
145
+ ["## Analysis:", "## Observe:", "## Observation:"], // Accept various observation formats
146
+ ["## Orient:", "## Orientation:"], // Optional but recognized
147
+ ["## Plan:", "## Decide:", "## Decision:"], // Decision-related sections
148
+ ["## Reason:", "## Reasoning:", "## Analysis:"], // Reasoning-related sections
149
+ ["## Act:", "## Action:", "## Execution:"], // Action-related sections
150
+ ["## Verification:"],
151
+ ["## Risk & Contingency:", "## Risks:", "## Challenges:"],
152
+ ["## Learning & Adaptation:", "## Self-Correction:", "## Learning:"]
153
+ ];
154
+ // Check if each required section group has at least one match
155
+ const missingSections = requiredSections.filter(sectionGroup => !sectionGroup.some(section => thought.includes(section)));
156
+ // Build validation report
157
+ let validationReport = [];
146
158
  if (missingSections.length > 0) {
147
- console.warn(`[${new Date().toISOString()}] [MCP Server] Warning: '${toolName}' input might be missing sections: ${missingSections.join(', ')}. Ensure full structure is followed for optimal reasoning.`);
159
+ 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.");
148
160
  }
149
- logToolResult(toolName, true, `Thought logged (length: ${thought.length})`);
150
- // Returns the same thought text received. This grounds the reasoning in the context.
151
- // The AI uses this output implicitly as the starting point for its *next* internal step or external action.
152
- return { content: [{ type: "text", text: thought }] };
161
+ // Log validation results
162
+ if (validationReport.length > 0) {
163
+ console.warn(`[${new Date().toISOString()}] [CognitiveToolsServer] Think Tool Validation Report:\n${validationReport.join("\n")}`);
164
+ }
165
+ // Enhanced logging with simplified format detection
166
+ const format = thought.includes("## Observe:") ? "OODReAct-style" : "Traditional";
167
+ logToolResult(toolName, true, `Thought logged (Style: ${format}, Length: ${thought.length})`);
168
+ // Return thought with metadata
169
+ return {
170
+ content: [{
171
+ type: "text",
172
+ text: thought
173
+ }],
174
+ metadata: {
175
+ format,
176
+ validationReport,
177
+ timestamp: new Date().toISOString()
178
+ }
179
+ };
153
180
  }
154
181
  catch (error) {
155
182
  return logToolError(toolName, error);
@@ -157,12 +184,12 @@ server.tool("think", "**MANDATORY Central Hub for Analysis, Planning, and Refine
157
184
  });
158
185
  /**
159
186
  * Tool: quick_think
160
- * Purpose: A lightweight cognitive checkpoint for **strictly Low CUC-N situations** or trivial confirmations.
161
- * Workflow: Use ONLY when `assess_cuc_n_mode` explicitly selected 'quick_think'. Use sparingly.
187
+ * Purpose: A lightweight cognitive checkpoint for streamlined processing and simple confirmations.
188
+ * Workflow: Use when full structured analysis via `think` is not necessary.
162
189
  * Output: Logs the brief thought.
163
190
  */
164
- server.tool("quick_think", "Cognitive Checkpoint ONLY for situations explicitly assessed as strictly Low CUC-N (via `assess_cuc_n_mode`) or for trivial confirmations/acknowledgements where detailed analysis via `think` is unnecessary. Use SPARINGLY.", {
165
- brief_thought: z.string().describe("Your **concise** thought or confirmation for this simple, low CUC-N step. Briefly state the observation/action and confirm it's trivial.")
191
+ 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.", {
192
+ 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.")
166
193
  }, async ({ brief_thought }) => {
167
194
  const toolName = 'quick_think';
168
195
  logToolCall(toolName);
@@ -181,10 +208,10 @@ server.tool("quick_think", "Cognitive Checkpoint ONLY for situations explicitly
181
208
  /**
182
209
  * Tool: gauge_confidence
183
210
  * Purpose: Meta-Cognitive Checkpoint to explicitly state confidence in a preceding analysis, plan, or draft.
184
- * Workflow: Generate assessment -> Call this tool with assessment text -> MANDATORY `think` step follows to analyze the confidence level.
185
- * Output: Confirms confidence gauging and level. Emphasizes need for `think` analysis, especially if not High.
211
+ * Workflow: Generate assessment -> Call this tool with assessment text -> Follow with either `think` or `quick_think`.
212
+ * Output: Confirms confidence gauging and level.
186
213
  */
187
- 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. Output MUST be analyzed in the mandatory `think` step immediately following.", {
214
+ 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.", {
188
215
  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.")
189
216
  }, async ({ assessment_and_confidence }) => {
190
217
  const toolName = 'gauge_confidence';
@@ -210,54 +237,62 @@ server.tool("gauge_confidence", "Meta-Cognitive Checkpoint. Guides *internal sta
210
237
  }
211
238
  });
212
239
  /**
213
- * Tool: plan_and_solve
214
- * Purpose: Guides the *internal generation* of a structured plan draft.
215
- * Workflow: Internally generate plan -> Call this tool *with* the plan text -> MANDATORY `think` step follows to analyze/refine the plan.
216
- * Output: Returns the provided plan text for grounding and analysis.
240
+ * Tool: chain_of_thought
241
+ * Purpose: Guides *internal generation* of detailed, step-by-step reasoning draft (CoT).
242
+ * Workflow: Generate CoT -> Call this tool with CoT text -> Follow with either `think` or `quick_think`.
243
+ * Output: Returns the CoT text for analysis.
217
244
  */
218
- 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. MANDATORY: Use the next `think` step to critically evaluate this plan's feasibility, refine it, and confirm the *first actionable step*.", {
219
- generated_plan_text: z.string().describe("The **full, structured plan draft** you generated internally, including goals, steps, potential external tool needs, assumptions, and risks."),
220
- task_objective: z.string().describe("The original high-level task objective this plan addresses.")
221
- }, async ({ generated_plan_text, task_objective }) => {
222
- const toolName = 'plan_and_solve';
223
- logToolCall(toolName, `Objective: ${task_objective.substring(0, 80)}...`);
245
+ 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.", {
246
+ generated_cot_text: z.string().describe("The **full, step-by-step Chain of Thought draft** you generated internally to solve or analyze the problem."),
247
+ problem_statement: z.string().describe("The original problem statement or question this CoT addresses.")
248
+ }, async ({ generated_cot_text, problem_statement }) => {
249
+ const toolName = 'chain_of_thought';
250
+ logToolCall(toolName);
224
251
  try {
225
- if (!generated_plan_text || typeof generated_plan_text !== 'string' || generated_plan_text.trim().length === 0) {
226
- throw new Error('Invalid generated_plan_text: Must be a non-empty string containing the plan.');
252
+ if (!generated_cot_text || typeof generated_cot_text !== 'string' || !problem_statement || typeof problem_statement !== 'string') {
253
+ throw new Error('Both generated_cot_text and problem_statement must be non-empty strings.');
227
254
  }
228
- if (!task_objective || typeof task_objective !== 'string' || task_objective.trim().length === 0) {
229
- throw new Error('Invalid task_objective: Must provide the original objective.');
255
+ // Validate CoT format - should have clear steps
256
+ if (!generated_cot_text.match(/step|phase|:\s|^\d+[\.\)]/im)) {
257
+ throw new Error('Invalid CoT format: Must contain clear reasoning steps (numbered, labeled as steps/phases, or with clear delineation).');
230
258
  }
231
- logToolResult(toolName, true, `Returned plan draft for analysis (length: ${generated_plan_text.length})`);
232
- // Returns the actual plan text received. The AI must analyze this in the next 'think' step.
233
- return { content: [{ type: "text", text: generated_plan_text }] };
259
+ const resultText = `Chain of Thought Completed. Problem: "${problem_statement.substring(0, 100)}..."\nReasoning Steps Logged. MANDATORY: Analyze this reasoning chain in your next 'think' step to extract insights, identify potential flaws/gaps, and plan concrete next actions.`;
260
+ logToolResult(toolName, true, `Problem: ${problem_statement.substring(0, 50)}...`);
261
+ console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Details:\nProblem: ${problem_statement}\nReasoning:\n${generated_cot_text}`);
262
+ return { content: [{ type: "text", text: resultText }] };
234
263
  }
235
264
  catch (error) {
236
265
  return logToolError(toolName, error);
237
266
  }
238
267
  });
239
268
  /**
240
- * Tool: chain_of_thought
241
- * Purpose: Guides the *internal generation* of a detailed, step-by-step reasoning draft (CoT).
242
- * Workflow: Internally generate CoT -> Call this tool *with* the CoT text -> MANDATORY `think` step follows to analyze the reasoning.
243
- * Output: Returns the provided CoT text for grounding and analysis.
269
+ * Tool: plan_and_solve
270
+ * Purpose: Guides *internal generation* of a structured plan draft.
271
+ * Workflow: Generate plan -> Call this tool with plan text -> Follow with either `think` or `quick_think`.
272
+ * Output: Returns the plan text for analysis.
244
273
  */
245
- 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. MANDATORY: Use the next `think` step to analyze this reasoning, extract insights, identify flaws/gaps, and plan the next concrete action based on the CoT.", {
246
- generated_cot_text: z.string().describe("The **full, step-by-step Chain of Thought draft** you generated internally to solve or analyze the problem."),
247
- problem_statement: z.string().describe("The original problem statement or question this CoT addresses.")
248
- }, async ({ generated_cot_text, problem_statement }) => {
249
- const toolName = 'chain_of_thought';
250
- logToolCall(toolName, `Problem: ${problem_statement.substring(0, 80)}...`);
274
+ 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.", {
275
+ generated_plan_text: z.string().describe("The **full, structured plan draft** you generated internally, including goals, steps, potential external tool needs, assumptions, and risks."),
276
+ task_objective: z.string().describe("The original high-level task objective this plan addresses.")
277
+ }, async ({ generated_plan_text, task_objective }) => {
278
+ const toolName = 'plan_and_solve';
279
+ logToolCall(toolName);
251
280
  try {
252
- if (!generated_cot_text || typeof generated_cot_text !== 'string' || generated_cot_text.trim().length === 0) {
253
- throw new Error('Invalid generated_cot_text: Must be a non-empty string containing the CoT.');
281
+ if (!generated_plan_text || typeof generated_plan_text !== 'string' || !task_objective || typeof task_objective !== 'string') {
282
+ throw new Error('Both generated_plan_text and task_objective must be non-empty strings.');
283
+ }
284
+ // Validate plan format - should have clear sections and structure
285
+ if (!generated_plan_text.match(/phase|step|goal|objective|:\s|^\d+[\.\)]/im)) {
286
+ throw new Error('Invalid plan format: Must contain clear sections (phases, steps, goals) with proper structure.');
254
287
  }
255
- if (!problem_statement || typeof problem_statement !== 'string' || problem_statement.trim().length === 0) {
256
- throw new Error('Invalid problem_statement: Must provide the original problem.');
288
+ // Validate plan includes risk consideration
289
+ if (!generated_plan_text.toLowerCase().includes('risk') && !generated_plan_text.toLowerCase().includes('challenge')) {
290
+ throw new Error('Invalid plan format: Must include risk/challenge assessment.');
257
291
  }
258
- logToolResult(toolName, true, `Returned CoT draft for analysis (length: ${generated_cot_text.length})`);
259
- // Returns the actual CoT text received. The AI must analyze this in the next 'think' step.
260
- return { content: [{ type: "text", text: generated_cot_text }] };
292
+ const resultText = `Plan Generation Completed. Task: "${task_objective.substring(0, 100)}..."\nPlan Structure Logged. MANDATORY: Analyze this plan in your next 'think' step to verify feasibility, refine if needed, and confirm the first concrete action step.`;
293
+ logToolResult(toolName, true, `Task: ${task_objective.substring(0, 50)}...`);
294
+ console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Details:\nTask: ${task_objective}\nPlan:\n${generated_plan_text}`);
295
+ return { content: [{ type: "text", text: resultText }] };
261
296
  }
262
297
  catch (error) {
263
298
  return logToolError(toolName, error);
@@ -265,12 +300,17 @@ server.tool("chain_of_thought", "Guides *internal generation* of **detailed, ste
265
300
  });
266
301
  /**
267
302
  * Tool: chain_of_draft
268
- * Purpose: Signals that internal drafts (code, text, plan fragments) have been generated or refined.
269
- * Workflow: Internally generate/refine draft(s) -> Call this tool -> MANDATORY `think` step follows to analyze the draft(s).
270
- * Output: Confirms readiness for analysis.
303
+ * Purpose: Signals that internal drafts have been generated/refined using Chain of Draft (CoD) principles.
304
+ * Workflow: Internally generate/refine concise draft(s) -> Call this tool -> Follow with either `think` or `quick_think`.
305
+ * Best Practices from Research:
306
+ * - Keep each draft step short (< 5 words) like human notes
307
+ * - Use equations, symbols, or brief phrases instead of sentences
308
+ * - Focus on essential information only
309
+ * - End with #### followed by final answer/conclusion
310
+ * Output: Returns markdown-formatted response with CoD guidance and next tool recommendation.
271
311
  */
272
- server.tool("chain_of_draft", "Signals that one or more **internal drafts** (e.g., code snippets, documentation sections, refined plan steps) have been generated or refined and are ready for analysis. Call this tool *after* generating/refining draft(s) internally. Response confirms readiness. MANDATORY: Analyze these draft(s) in your next `think` step.", {
273
- draft_description: z.string().describe("Brief but specific description of the draft(s) generated/refined internally (e.g., 'Initial Python function for API call', 'Refined error handling in plan step 3', 'Drafted README introduction').")
312
+ 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.", {
313
+ 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').")
274
314
  }, async ({ draft_description }) => {
275
315
  const toolName = 'chain_of_draft';
276
316
  logToolCall(toolName, `Description: ${draft_description}`);
@@ -278,7 +318,27 @@ server.tool("chain_of_draft", "Signals that one or more **internal drafts** (e.g
278
318
  if (!draft_description || typeof draft_description !== 'string' || draft_description.trim().length === 0) {
279
319
  throw new Error('Invalid draft_description: Must provide a description.');
280
320
  }
281
- const resultText = `Internal draft(s) ready for analysis: \"${draft_description}\". MANDATORY: Analyze these draft(s) now using the structured format in your next 'think' step. Evaluate correctness, completeness, and alignment with goals.`;
321
+ // Format response in markdown with CoD guidance and next tool recommendation
322
+ const resultText = `### Chain of Draft Signal Received
323
+ #### Draft Description
324
+ ${draft_description}
325
+
326
+ #### Chain of Draft (CoD) Reminders
327
+ - Keep steps concise (< 5 words)
328
+ - Use equations/symbols when possible
329
+ - Focus on essential information
330
+ - End drafts with #### + conclusion
331
+
332
+ #### Next Steps
333
+ 1. MANDATORY: Use \`think\` tool to analyze this draft:
334
+ - Evaluate correctness and completeness
335
+ - Check alignment with goals
336
+ - Plan concrete next actions
337
+ 2. Consider using \`reflection\` tool if deeper critique needed
338
+ 3. Use \`synthesize_prior_reasoning\` if context consolidation helpful
339
+
340
+ #### Status
341
+ Draft(s) ready for analysis. Proceed with mandatory \`think\` step.`;
282
342
  logToolResult(toolName, true);
283
343
  return { content: [{ type: "text", text: resultText }] };
284
344
  }
@@ -288,11 +348,12 @@ server.tool("chain_of_draft", "Signals that one or more **internal drafts** (e.g
288
348
  });
289
349
  /**
290
350
  * Tool: reflection
291
- * Purpose: Guides the *internal generation* of a critical self-evaluation (critique) of a prior step, draft, or outcome.
292
- * Workflow: Internally generate critique -> Call this tool *with* the critique text -> MANDATORY `think` step follows to act on the critique.
293
- * Output: Returns the provided critique text for grounding and analysis.
351
+ * Purpose: Guides *internal generation* of a critical self-evaluation (critique) on a prior step, draft, plan, or outcome.
352
+ * Call this tool *with* the **generated critique text** you created internally.
353
+ * Returns the critique text.
354
+ * Follow with either `think` or `quick_think` to process the critique.
294
355
  */
295
- 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. MANDATORY: Use the next `think` step to analyze this critique and plan specific corrective actions or refinements based on it.", {
356
+ 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.", {
296
357
  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."),
297
358
  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').")
298
359
  }, async ({ generated_critique_text, input_subject_description }) => {
@@ -316,10 +377,10 @@ server.tool("reflection", "Guides *internal generation* of a critical self-evalu
316
377
  /**
317
378
  * Tool: synthesize_prior_reasoning
318
379
  * Purpose: Context Management Tool. Guides the *internal generation* of a structured summary of preceding context.
319
- * Workflow: Internally generate summary -> Call this tool *with* the summary text -> MANDATORY `think` step follows to use the summary.
380
+ * Workflow: Internally generate summary -> Call this tool *with* the summary text -> Follow with either `think` or `quick_think`.
320
381
  * Output: Returns the provided summary text for grounding and analysis.
321
382
  */
322
- 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. MANDATORY: Use the next `think` step to leverage this summary and inform the next action.", {
383
+ 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.", {
323
384
  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)."),
324
385
  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').")
325
386
  }, async ({ generated_summary_text, context_to_summarize_description }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nbiish/cognitive-tools-mcp",
3
- "version": "0.9.8",
3
+ "version": "0.9.10",
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",
@@ -53,4 +53,4 @@
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  }
56
- }
56
+ }