@nbiish/cognitive-tools-mcp 0.9.16 → 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.
- package/README.md +12 -90
- package/build/index.js +103 -214
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -46,16 +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 a suite of cognitive tools for AI agents, enabling structured reasoning and iterative refinement:
|
|
49
|
+
Provides a suite of cognitive tools for AI agents, enabling structured reasoning and iterative refinement (v1.2.1 Simplified Set):
|
|
50
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 analysis, planning, verification, and self-correction
|
|
51
|
+
- `think`: **Mandatory** central hub for comprehensive analysis, planning, verification, and self-correction.
|
|
52
52
|
- `quick_think`: Lightweight cognitive checkpoint for simple, low CUC-N steps or trivial confirmations.
|
|
53
|
-
- `
|
|
54
|
-
- `
|
|
55
|
-
- `plan_and_solve`: Guides internal generation of a structured, multi-step plan.
|
|
56
|
-
- `chain_of_draft`: Signals internal generation/refinement of concise drafts (CoD).
|
|
57
|
-
- `reflection`: Guides internal generation of a critical self-evaluation (critique).
|
|
58
|
-
- `synthesize_prior_reasoning`: Guides internal generation of a summary to consolidate context.
|
|
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.
|
|
59
55
|
|
|
60
56
|
## Installation
|
|
61
57
|
|
|
@@ -102,65 +98,34 @@ Or:
|
|
|
102
98
|
*(Note: For detailed usage, workflow, and mandatory rules, always refer to [`latest.md`](latest.md))*
|
|
103
99
|
|
|
104
100
|
### `assess_cuc_n_mode`
|
|
105
|
-
- **Purpose**: **Mandatory Pre-Deliberation Assessment.** Evaluates task Complexity, Uncertainty, Consequence, Novelty (CUC-N) to determine required cognitive depth and initial strategy.
|
|
101
|
+
- **Purpose**: **Mandatory Pre-Deliberation Assessment.** Evaluates task Complexity, Uncertainty, Consequence, Novelty (CUC-N) to determine required cognitive depth and initial strategy.
|
|
106
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`).
|
|
107
103
|
- **Follow-up**: Mandatory `think` or `quick_think` (based on selection).
|
|
108
104
|
|
|
109
105
|
### `think`
|
|
110
|
-
- **Purpose**: **MANDATORY Central Hub for Analysis and Planning.** Called after assessment,
|
|
111
|
-
- **Input**: `thought` (string) - Your detailed internal monologue
|
|
112
|
-
- **Follow-up**: Execute the immediate next action defined in the `## Plan:`
|
|
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.
|
|
113
109
|
|
|
114
110
|
### `quick_think`
|
|
115
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).
|
|
116
112
|
- **Input**: `brief_thought` (string) - Your concise thought or confirmation.
|
|
117
113
|
- **Follow-up**: Execute the simple next step.
|
|
118
114
|
|
|
119
|
-
### `gauge_confidence`
|
|
120
|
-
- **Purpose**: Meta-Cognitive Checkpoint. Guides *internal stating* of confidence (High/Medium/Low) and justification regarding a specific plan, analysis, or draft.
|
|
121
|
-
- **Workflow**: Internally generate assessment -> Call tool.
|
|
122
|
-
- **Input**: `assessment_and_confidence` (string) - Text containing the item being assessed AND your explicit internal assessment (Confidence Level + Justification).
|
|
123
|
-
- **Follow-up**: Mandatory `think` or `quick_think`.
|
|
124
|
-
|
|
125
115
|
### `chain_of_thought`
|
|
126
|
-
- **Purpose**: Guides *internal generation* of
|
|
116
|
+
- **Purpose**: Guides *internal generation* and logging of detailed, step-by-step reasoning draft (CoT).
|
|
127
117
|
- **Workflow**: Internally generate CoT -> Call tool.
|
|
128
118
|
- **Input**:
|
|
129
119
|
- `generated_cot_text` (string) - The full CoT draft you generated internally.
|
|
130
120
|
- `problem_statement` (string) - The original problem this CoT addresses.
|
|
131
121
|
- **Follow-up**: Mandatory `think` or `quick_think`.
|
|
132
122
|
|
|
133
|
-
### `plan_and_solve`
|
|
134
|
-
- **Purpose**: Guides *internal generation* of a structured plan draft.
|
|
135
|
-
- **Workflow**: Internally generate plan -> Call tool.
|
|
136
|
-
- **Input**:
|
|
137
|
-
- `generated_plan_text` (string) - The full, structured plan draft you generated internally.
|
|
138
|
-
- `task_objective` (string) - The original high-level task objective.
|
|
139
|
-
- **Follow-up**: Mandatory `think` or `quick_think`.
|
|
140
|
-
|
|
141
123
|
### `chain_of_draft`
|
|
142
|
-
- **Purpose**: Signals
|
|
143
|
-
- **Workflow**: Internally generate/refine draft(s) -> Call tool.
|
|
144
|
-
- **Input**: `draft_description` (string) - Brief but specific description of the draft(s) generated/refined internally.
|
|
145
|
-
- **Follow-up**: Mandatory `think` or `quick_think`.
|
|
146
|
-
|
|
147
|
-
### `reflection`
|
|
148
|
-
- **Purpose**: Guides *internal generation* of a critical self-evaluation (critique) on a prior step, draft, plan, or outcome.
|
|
149
|
-
- **Workflow**: Internally generate critique -> Call tool.
|
|
150
|
-
- **Input**:
|
|
151
|
-
- `generated_critique_text` (string) - The full critique text you generated internally.
|
|
152
|
-
- `input_subject_description` (string) - A brief description of what was critiqued.
|
|
153
|
-
- **Follow-up**: Mandatory `think` or `quick_think`.
|
|
154
|
-
|
|
155
|
-
### `synthesize_prior_reasoning`
|
|
156
|
-
- **Purpose**: Context Management Tool. Guides *internal generation* of a structured summary of preceding context.
|
|
157
|
-
- **Workflow**: Internally generate summary -> Call tool.
|
|
158
|
-
- **Input**:
|
|
159
|
-
- `generated_summary_text` (string) - The full, structured summary text you generated internally.
|
|
160
|
-
- `context_to_summarize_description` (string) - Description of the context that was summarized.
|
|
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.
|
|
161
127
|
- **Follow-up**: Mandatory `think` or `quick_think`.
|
|
162
128
|
|
|
163
|
-
|
|
164
129
|
## Development
|
|
165
130
|
|
|
166
131
|
```bash
|
|
@@ -281,16 +246,6 @@ npm run inspector
|
|
|
281
246
|
}
|
|
282
247
|
```
|
|
283
248
|
|
|
284
|
-
#### `gauge_confidence` Example
|
|
285
|
-
```json
|
|
286
|
-
{
|
|
287
|
-
"toolName": "gauge_confidence",
|
|
288
|
-
"arguments": {
|
|
289
|
-
"assessment_and_confidence": "Assessment of the plan to explain Mino-Bimaadiziwin using CoT.\\nConfidence Level: Medium.\\nJustification: The CoT approach is suitable, but explaining deep cultural concepts always carries a risk of nuance loss. Confidence is medium as external validation isn't possible here."
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
```
|
|
293
|
-
|
|
294
249
|
#### `chain_of_thought` Example
|
|
295
250
|
```json
|
|
296
251
|
{
|
|
@@ -302,17 +257,6 @@ npm run inspector
|
|
|
302
257
|
}
|
|
303
258
|
```
|
|
304
259
|
|
|
305
|
-
#### `plan_and_solve` Example
|
|
306
|
-
```json
|
|
307
|
-
{
|
|
308
|
-
"toolName": "plan_and_solve",
|
|
309
|
-
"arguments": {
|
|
310
|
-
"generated_plan_text": "Goal: Plan a community gathering honoring traditional protocols.\\nStep 1: Consult Elders on protocols (Timing: Next action).\\nStep 2: Identify suitable date/location based on consultation.\\nStep 3: Arrange traditional foods/medicines.\\nStep 4: Prepare space respectfully.\\nStep 5: Finalize opening/closing ceremony details.\\nAssumptions: Elders are available for consultation.\\nRisks: Scheduling conflicts (Medium).",
|
|
311
|
-
"task_objective": "Planning a community gathering that honors traditional protocols."
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
```
|
|
315
|
-
|
|
316
260
|
#### `chain_of_draft` Example
|
|
317
261
|
```json
|
|
318
262
|
{
|
|
@@ -323,28 +267,6 @@ npm run inspector
|
|
|
323
267
|
}
|
|
324
268
|
```
|
|
325
269
|
|
|
326
|
-
#### `reflection` Example
|
|
327
|
-
```json
|
|
328
|
-
{
|
|
329
|
-
"toolName": "reflection",
|
|
330
|
-
"arguments": {
|
|
331
|
-
"generated_critique_text": "Critique of CoT for Mino-Bimaadiziwin: Strengths - Covers key components. Weaknesses - Could elaborate more on the interconnectedness of the teachings. Suggestion - Add a concluding step summarizing the holistic nature.",
|
|
332
|
-
"input_subject_description": "Critique of the internally generated CoT for explaining Mino-Bimaadiziwin."
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
#### `synthesize_prior_reasoning` Example
|
|
338
|
-
```json
|
|
339
|
-
{
|
|
340
|
-
"toolName": "synthesize_prior_reasoning",
|
|
341
|
-
"arguments": {
|
|
342
|
-
"generated_summary_text": "Summary of last 3 steps: 1) Assessed task (explain Mino-Bimaadiziwin). 2) Planned to use CoT via 'think'. 3) Internally generated CoT draft covering definition, Four Hills, Seven Teachings, health aspects, and connection.",
|
|
343
|
-
"context_to_summarize_description": "Summary of assessment, planning, and CoT generation for Mino-Bimaadiziwin explanation."
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
```
|
|
347
|
-
|
|
348
270
|
## Citation
|
|
349
271
|
|
|
350
272
|
Please cite this project using the following BibTeX entry:
|
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
|
-
*
|
|
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
|
|
11
|
-
* This server focuses on managing the AI's *internal cognitive loop
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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. **
|
|
18
|
-
* reasoning,
|
|
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
|
|
22
|
-
*
|
|
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 (
|
|
25
|
-
* 4. **Internal Generation First:**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
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
|
|
39
|
+
const serverInfo = {
|
|
42
40
|
name: "gikendaasowin-aabajichiganan-mcp",
|
|
43
|
-
version:
|
|
44
|
-
description:
|
|
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:
|
|
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
|
-
//
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
|
124
|
-
* Workflow:
|
|
125
|
-
* Output: Returns the structured thought text itself,
|
|
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`),
|
|
128
|
-
thought: z.string().describe("Your **detailed** internal monologue
|
|
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
|
-
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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: [{
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
return
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
|
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
|
-
|
|
230
|
-
|
|
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 (
|
|
233
|
-
throw new Error('Invalid
|
|
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
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
*
|
|
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
|
|
288
|
-
draft_description: z.string().describe("Brief but specific description of the draft(s) generated/refined internally (e.g., '
|
|
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
|
-
|
|
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
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
return
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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(`
|
|
397
|
-
|
|
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.
|
|
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",
|