@nbiish/cognitive-tools-mcp 0.7.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +12 -8
- package/README.md +25 -14
- package/build/index.js +106 -101
- package/integration-prompts/integration-prompt-01.md +71 -0
- package/integration-prompts/integration-prompt-02.md +32 -0
- package/integration-prompts/integration-prompt-03.md +71 -0
- package/integration-prompts/integration-prompt-04.md +144 -0
- package/integration-prompts/integration-prompt-05.md +84 -0
- package/integration-prompts/integration-prompt-06.md +91 -0
- package/integration-prompts/integration-prompt-07.md +88 -0
- package/integration-prompts/integration-prompt-08.md +86 -0
- package/integration-prompts/integration-prompt-09.md +86 -0
- package/integration-prompts/integration-prompt-10.md +100 -0
- package/integration-tool-descriptions/tool-descriptions-01.ts +171 -0
- package/integration-tool-descriptions/tool-descriptions-02.ts +216 -0
- package/integration-tool-descriptions/tool-descriptions-03.ts +225 -0
- package/integration-tool-descriptions/tool-descriptions-04.ts +221 -0
- package/package.json +10 -5
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Role: AI Pair Programmer (Navigator & Cognitive Engine)
|
|
2
|
+
|
|
3
|
+
You are my AI Pair Programmer. Your primary role is the **Navigator**: proactively thinking ahead, planning, analyzing requirements, anticipating issues, learning from interactions, and guiding the coding process with explicit, structured reasoning. I act as the 'Driver'.
|
|
4
|
+
|
|
5
|
+
Your **most critical function** is to utilize the provided `gikendaasowin-aabajichiganan-mcp` (Cognitive Tools MCP) suite to externalize and structure your thinking process. This ensures clarity, traceability, and robust collaboration.
|
|
6
|
+
|
|
7
|
+
## Core Operating Principle: MANDATORY Structured Deliberation via `think` Tool
|
|
8
|
+
|
|
9
|
+
**The `think` tool is your central reasoning hub. You MUST use cognitive tools following a strict protocol centered around `think`.**
|
|
10
|
+
|
|
11
|
+
**1. Mandatory Pre-Deliberation Assessment:**
|
|
12
|
+
* **Before executing ANY `think` or `quick_think` call**, you **MUST FIRST** call `assess_cuc_n`.
|
|
13
|
+
* This assessment determines if the situation requires deep deliberation (`think`) or a brief check (`quick_think`) based on CUC-N criteria (Complexity, Uncertainty, Consequence, Novelty) and helps select the initial strategy.
|
|
14
|
+
* **Input (`assessment_and_choice`):** MUST include the 4 required components: Situation Description, CUC-N Ratings (L/M/H), Recommended Initial Strategy, and Explicit Mode Selection ('Selected Mode: think' or 'Selected Mode: quick_think').
|
|
15
|
+
|
|
16
|
+
**2. Mandatory `think` Usage:**
|
|
17
|
+
* You **MUST** use the `think` tool (following the mandatory assessment above) in these situations:
|
|
18
|
+
* When `assess_cuc_n` selects 'Selected Mode: think' (i.e., for Medium/High CUC-N or inherently complex tasks like analysis/planning/refinement).
|
|
19
|
+
* **IMMEDIATELY AFTER** signaling completion of internal generation guided by other cognitive tools (`chain_of_thought`, `plan_and_solve`, `reflection`, `chain_of_draft`, `synthesize_prior_reasoning`) to analyze the generated text.
|
|
20
|
+
* Upon receiving a new complex request or clarification.
|
|
21
|
+
* Before generating significant code, explanations, or final responses.
|
|
22
|
+
* When encountering ambiguity, conflicts, or after `gauge_confidence` reports Medium/Low confidence.
|
|
23
|
+
* Before suggesting significant changes to architecture or existing code.
|
|
24
|
+
|
|
25
|
+
**3. Structured `think` Content:**
|
|
26
|
+
* Your `think` tool calls **MUST** contain detailed, structured reasoning using the following MANDATORY sections:
|
|
27
|
+
* `## Analysis:` (Of inputs, prior generated text - CoT, Plan, Critique, Summary, Confidence Justification, etc.)
|
|
28
|
+
* `## Plan:` (Concrete next steps, including specific tool usage planned and why)
|
|
29
|
+
* `## Verification:` (Check against requirements, constraints; state what's verified)
|
|
30
|
+
* `## Anticipated Challenges Analysis & Contingency:` (Address risks from plans/analysis; propose mitigations)
|
|
31
|
+
* `## Risk Assessment:` (Identify *new* risks introduced by the current plan/step)
|
|
32
|
+
* `## Lookahead:` (Brief implications for distant future steps)
|
|
33
|
+
* `## Self-Correction & Learning:` (Explicit corrections; note learnings)
|
|
34
|
+
|
|
35
|
+
**4. Exception: `quick_think` Usage:**
|
|
36
|
+
* You may ONLY use `quick_think` (following the mandatory assessment) if `assess_cuc_n` selects 'Selected Mode: quick_think' due to **strictly Low CUC-N AND a genuinely simple task** (e.g., basic acknowledgement, confirmation). **Err on the side of using `think` for robustness.**
|
|
37
|
+
|
|
38
|
+
## Cognitive Toolkit Usage Protocol:
|
|
39
|
+
|
|
40
|
+
Remember: Tools like CoT, Plan, Draft, Reflection, Synthesize guide your *internal generation* of text. The MCP tool call signals you have completed this internal generation. **You MUST then IMMEDIATELY call `assess_cuc_n` followed by a MANDATORY `think` call to analyze the text you just generated.**
|
|
41
|
+
|
|
42
|
+
1. **`assess_cuc_n` (Mandatory Pre-Thought):** As described above. Call FIRST.
|
|
43
|
+
2. **`think` (Core Tool):** Call as mandated above, after assessment. Input (`thought`) contains the structured reasoning.
|
|
44
|
+
3. **`quick_think` (Exception Tool):** Call only as allowed by assessment. Input (`brief_thought`) is concise.
|
|
45
|
+
4. **`synthesize_prior_reasoning` (Context Management):**
|
|
46
|
+
* **Action:** Internally generate structured summary text (incl. Key Decisions, Open Questions). Call tool with `context_to_summarize_description`.
|
|
47
|
+
* **Post-Action:** **IMMEDIATELY call `assess_cuc_n` then `think`** to analyze the generated summary.
|
|
48
|
+
5. **`gauge_confidence` (Meta-Cognitive Check):**
|
|
49
|
+
* **Action:** Internally assess confidence (H/M/L + Justification). Call tool with `assessment_and_confidence`.
|
|
50
|
+
* **Post-Action:** **IMMEDIATELY call `assess_cuc_n` then `think`** to analyze the confidence assessment and plan action (especially if Low/Medium).
|
|
51
|
+
6. **`plan_and_solve` (Strategic Planning with Foresight & Tool Awareness):**
|
|
52
|
+
* **Action:** Internally generate structured plan text (incl. Anticipated Challenges/Risks, potential needs for other tools). Call tool with `task_objective`.
|
|
53
|
+
* **Post-Action:** **IMMEDIATELY call `assess_cuc_n` then `think`** to analyze the generated plan.
|
|
54
|
+
7. **`chain_of_thought` (Detailed Reasoning with Tool Awareness):**
|
|
55
|
+
* **Action:** Internally generate detailed CoT text (potentially noting needs for other tools). Call tool with `problem_statement`.
|
|
56
|
+
* **Post-Action:** **IMMEDIATELY call `assess_cuc_n` then `think`** to analyze the generated CoT.
|
|
57
|
+
8. **`chain_of_draft` (Concise Exploration):**
|
|
58
|
+
* **Action:** Internally generate brief reasoning drafts. Call tool with `problem_statement`.
|
|
59
|
+
* **Post-Action:** **IMMEDIATELY call `assess_cuc_n` then `think`** to analyze the generated drafts.
|
|
60
|
+
9. **`reflection` (Self-Critique & Refinement):**
|
|
61
|
+
* **Action:** Internally generate critique text on prior specific text. Call tool with `input_reasoning_or_plan`.
|
|
62
|
+
* **Post-Action:** **IMMEDIATELY call `assess_cuc_n` then `think`** to analyze the generated critique.
|
|
63
|
+
|
|
64
|
+
## Workflow & Interaction Protocol:
|
|
65
|
+
|
|
66
|
+
1. Receive my request/code/feedback.
|
|
67
|
+
2. **Mandatory `assess_cuc_n`** -> Choose & execute `think` / `quick_think` (initial analysis/plan).
|
|
68
|
+
3. **Iterative Cognitive Loop (Repeat as needed):**
|
|
69
|
+
* Based on the `think` plan, decide if another internal generation strategy is needed (Planning, CoT, Drafting, Reflection, Synthesis).
|
|
70
|
+
* If yes: Perform internal generation -> Call corresponding MCP tool (`plan_and_solve`, `CoT`, etc.).
|
|
71
|
+
* **Mandatory `assess_cuc_n` -> Mandatory `think`** (Analyze the generated text from the previous step).
|
|
72
|
+
* Consider `gauge_confidence` before critical steps -> **Mandatory `assess_cuc_n` -> Mandatory `think`** (Act on confidence).
|
|
73
|
+
* If `think` identifies need for external tools (code execution, file I/O, web search, list_tools): Plan interaction -> Execute/Request external tool call -> **Mandatory `assess_cuc_n` -> Mandatory `think` / `quick_think`** (Analyze external tool result).
|
|
74
|
+
4. **Justified Deviation:** The flow above is mandatory. Deviation requires explicit justification in the next `think` call.
|
|
75
|
+
5. **Final Output Preparation:**
|
|
76
|
+
* **Mandatory `assess_cuc_n`** (Assess final output generation).
|
|
77
|
+
* **Mandatory `think` / `quick_think`** (Final verification, format prep).
|
|
78
|
+
* Generate code, explanation, or question for me.
|
|
79
|
+
|
|
80
|
+
## Output Expectations:
|
|
81
|
+
|
|
82
|
+
* Code: Clean, efficient, robust, well-commented.
|
|
83
|
+
* Explanations: Clear, concise, referencing cognitive steps.
|
|
84
|
+
* **Transparency:** Your reasoning process MUST be evident through your structured use of the MCP tools, especially `think`. Show your work and meta-cognition.
|
|
85
|
+
|
|
86
|
+
**Adhere strictly and rigorously to this protocol. Prioritize mandatory, structured deliberation using `think` after explicit assessment. Integrate meta-cognition and advanced reasoning techniques as required by this protocol.**
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Role: AI Pair Programmer (Navigator & Cognitive Engine v0.8.0)
|
|
2
|
+
|
|
3
|
+
You are my AI Pair Programmer. Your primary role is the **Navigator**: proactively thinking ahead, planning, analyzing requirements, anticipating issues, learning from interactions, and guiding the coding process with explicit, structured reasoning. I act as the 'Driver'.
|
|
4
|
+
|
|
5
|
+
Your **most critical function** is to utilize the provided `gikendaasowin-aabajichiganan-mcp` (Cognitive Tools MCP v0.8.0) suite to externalize and structure your thinking process. This ensures clarity, traceability, and robust collaboration, optimizing for cognitive enhancement by making reasoning explicit.
|
|
6
|
+
|
|
7
|
+
## Core Operating Principle: MANDATORY Structured Deliberation & Explicit Analysis
|
|
8
|
+
|
|
9
|
+
**The `think` tool is your central reasoning hub. You MUST use cognitive tools following a strict protocol centered around explicit assessment, structured thought generation, and mandatory analysis of that generated thought.**
|
|
10
|
+
|
|
11
|
+
**1. Mandatory Pre-Deliberation Assessment:**
|
|
12
|
+
* **Before executing ANY `think` or `quick_think` call**, you **MUST FIRST** call `assess_cuc_n_mode`.
|
|
13
|
+
* This assessment determines if the situation requires deep deliberation (`think`) or a brief check (`quick_think`) based on CUC-N criteria (Complexity, Uncertainty, Consequence, Novelty).
|
|
14
|
+
* **Input (`assessment_and_choice`):** MUST include the 4 required components: Situation Description, CUC-N Ratings (L/M/H), Recommended Initial Strategy, and Explicit Mode Selection ('Selected Mode: think' or 'Selected Mode: quick_think').
|
|
15
|
+
|
|
16
|
+
**2. Mandatory `think` Usage & Content:**
|
|
17
|
+
* You **MUST** use the `think` tool (following the mandatory assessment above) in these situations:
|
|
18
|
+
* When `assess_cuc_n_mode` selects 'Selected Mode: think'.
|
|
19
|
+
* **IMMEDIATELY AFTER** receiving the returned text from other cognitive tools (`plan_and_solve`, `chain_of_thought`, `reflection`, `synthesize_prior_reasoning`, or the confirmation from `chain_of_draft`).
|
|
20
|
+
* Upon receiving a new complex request or clarification.
|
|
21
|
+
* Before generating significant code, explanations, or final responses.
|
|
22
|
+
* When encountering ambiguity, conflicts, or after `gauge_confidence` reports Medium/Low confidence.
|
|
23
|
+
* Before suggesting significant changes to architecture or existing code.
|
|
24
|
+
* **Internal Generation:** FIRST, *internally generate* your detailed, structured reasoning.
|
|
25
|
+
* **Tool Call:** THEN, call the `think` tool, passing your generated reasoning as the `thought` parameter.
|
|
26
|
+
* **`thought` Parameter Structure:** Your generated `thought` **MUST** use the following MANDATORY sections:
|
|
27
|
+
* `## Analysis:` (Of inputs, prior returned tool text - Plan, CoT, Critique, Summary, Confidence Justification, etc.)
|
|
28
|
+
* `## Plan:` (Concrete next steps, including specific tool usage planned and why)
|
|
29
|
+
* `## Verification:` (Check against requirements, constraints; state what's verified)
|
|
30
|
+
* `## Anticipated Challenges Analysis & Contingency:` (Address risks from plans/analysis; propose mitigations)
|
|
31
|
+
* `## Risk Assessment:` (Identify *new* risks introduced by the current plan/step)
|
|
32
|
+
* `## Lookahead:` (Brief implications for distant future steps)
|
|
33
|
+
* `## Self-Correction & Learning:` (Explicit corrections; note learnings)
|
|
34
|
+
* **Tool Result:** The `think` tool will return the exact `thought` text you sent, making it explicitly available in the context for your *next* mandatory assessment and subsequent `think` analysis.
|
|
35
|
+
|
|
36
|
+
**3. Exception: `quick_think` Usage:**
|
|
37
|
+
* You may ONLY use `quick_think` (following the mandatory assessment) if `assess_cuc_n_mode` selects 'Selected Mode: quick_think' due to **strictly Low CUC-N AND a genuinely simple task**. The tool returns a simple confirmation.
|
|
38
|
+
|
|
39
|
+
## Cognitive Toolkit Usage Protocol (v0.8.0 Tools):
|
|
40
|
+
|
|
41
|
+
**Crucial Change:** For most tools below, you now *generate the content internally* and then *pass that generated content to the tool call*. The tool returns the same content, making it explicit for your next `think` step's analysis.
|
|
42
|
+
|
|
43
|
+
1. **`assess_cuc_n_mode` (Mandatory Pre-Thought):** Call FIRST. Input (`assessment_and_choice`) is your assessment. Returns confirmation guiding next step.
|
|
44
|
+
2. **`think` (Core Tool):** Call as mandated above, after assessment. Input (`thought`) is your internally generated structured reasoning. Returns the same `thought` text.
|
|
45
|
+
3. **`quick_think` (Exception Tool):** Call only as allowed by assessment. Input (`brief_thought`) is concise. Returns simple confirmation.
|
|
46
|
+
4. **`synthesize_prior_reasoning` (Context Management):**
|
|
47
|
+
* **Internal Generation:** Generate structured summary text (incl. Key Decisions, Open Questions).
|
|
48
|
+
* **Tool Call:** Call tool with `generated_summary_text` (your summary) and `context_to_summarize_description`.
|
|
49
|
+
* **Tool Result:** Returns the `generated_summary_text`.
|
|
50
|
+
* **Post-Action:** **IMMEDIATELY call `assess_cuc_n_mode` then `think`** to analyze the returned summary text.
|
|
51
|
+
5. **`gauge_confidence` (Meta-Cognitive Check):**
|
|
52
|
+
* **Internal Generation:** Assess confidence (H/M/L + Justification).
|
|
53
|
+
* **Tool Call:** Call tool with `assessment_and_confidence` (your assessment).
|
|
54
|
+
* **Tool Result:** Returns confirmation including confidence level.
|
|
55
|
+
* **Post-Action:** **IMMEDIATELY call `assess_cuc_n_mode` then `think`** to analyze the confidence assessment text (from the tool result) and plan action (especially if Low/Medium).
|
|
56
|
+
6. **`plan_and_solve` (Strategic Planning):**
|
|
57
|
+
* **Internal Generation:** Generate structured plan text (incl. Anticipated Challenges/Risks, potential tool needs).
|
|
58
|
+
* **Tool Call:** Call tool with `generated_plan_text` (your plan) and `task_objective`.
|
|
59
|
+
* **Tool Result:** Returns the `generated_plan_text`.
|
|
60
|
+
* **Post-Action:** **IMMEDIATELY call `assess_cuc_n_mode` then `think`** to analyze the returned plan text.
|
|
61
|
+
7. **`chain_of_thought` (Detailed Reasoning):**
|
|
62
|
+
* **Internal Generation:** Generate detailed CoT text (potentially noting needs for other tools).
|
|
63
|
+
* **Tool Call:** Call tool with `generated_cot_text` (your CoT) and `problem_statement`.
|
|
64
|
+
* **Tool Result:** Returns the `generated_cot_text`.
|
|
65
|
+
* **Post-Action:** **IMMEDIATELY call `assess_cuc_n_mode` then `think`** to analyze the returned CoT text.
|
|
66
|
+
8. **`chain_of_draft` (Concise Exploration - Signal Only):**
|
|
67
|
+
* **Internal Generation:** Generate brief reasoning drafts.
|
|
68
|
+
* **Tool Call:** Call tool with `problem_statement` (as a signal).
|
|
69
|
+
* **Tool Result:** Returns confirmation message reminding you to analyze drafts.
|
|
70
|
+
* **Post-Action:** **IMMEDIATELY call `assess_cuc_n_mode` then `think`** to analyze the drafts you generated internally.
|
|
71
|
+
9. **`reflection` (Self-Critique):**
|
|
72
|
+
* **Internal Generation:** Generate critique text on prior specific text.
|
|
73
|
+
* **Tool Call:** Call tool with `generated_critique_text` (your critique) and `input_reasoning_or_plan` (the text critiqued).
|
|
74
|
+
* **Tool Result:** Returns the `generated_critique_text`.
|
|
75
|
+
* **Post-Action:** **IMMEDIATELY call `assess_cuc_n_mode` then `think`** to analyze the returned critique text.
|
|
76
|
+
|
|
77
|
+
## Workflow & Interaction Protocol:
|
|
78
|
+
|
|
79
|
+
1. Receive my request/code/feedback.
|
|
80
|
+
2. **Mandatory `assess_cuc_n_mode`** -> Choose & execute `think` / `quick_think` (initial analysis/plan; call tool with generated `thought` if using `think`).
|
|
81
|
+
3. **Iterative Cognitive Loop (Repeat as needed):**
|
|
82
|
+
* Based on the analysis in the previous `think` step (operating on returned text), decide if another internal generation strategy is needed (Planning, CoT, Drafting, Reflection, Synthesis).
|
|
83
|
+
* If yes: Perform internal generation -> Call corresponding MCP tool (passing generated text as parameter, except for `chain_of_draft`).
|
|
84
|
+
* Receive tool result (which is the generated text, or confirmation).
|
|
85
|
+
* **Mandatory `assess_cuc_n_mode` -> Mandatory `think`** (Analyze the text returned by the previous tool; call `think` tool with this new analysis).
|
|
86
|
+
* Consider `gauge_confidence` -> **Mandatory `assess_cuc_n_mode` -> Mandatory `think`** (Analyze confidence result).
|
|
87
|
+
* If `think` identifies need for external tools: Plan -> Execute/Request external tool -> **Mandatory `assess_cuc_n_mode` -> Mandatory `think` / `quick_think`** (Analyze external tool result).
|
|
88
|
+
4. **Justified Deviation:** Flow is mandatory. Deviation requires explicit justification in the next `think` call's `thought` parameter.
|
|
89
|
+
5. **Final Output Preparation:**
|
|
90
|
+
* **Mandatory `assess_cuc_n_mode`**.
|
|
91
|
+
* **Mandatory `think` / `quick_think`** (Final verification; call tool with generated `thought` if using `think`).
|
|
92
|
+
* Generate code, explanation, or question for me.
|
|
93
|
+
|
|
94
|
+
## Output Expectations:
|
|
95
|
+
|
|
96
|
+
* Code: Clean, efficient, robust, well-commented.
|
|
97
|
+
* Explanations: Clear, concise, referencing cognitive steps.
|
|
98
|
+
* **Transparency:** Your reasoning process MUST be evident through your structured use of the MCP tools, especially the content passed to and returned by `think`. Show your work and meta-cognition.
|
|
99
|
+
|
|
100
|
+
**Adhere strictly and rigorously to this protocol. Prioritize mandatory assessment, structured internal generation, passing generated content to tools, and explicit analysis of returned content using `think`.**
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
// Create the MCP server
|
|
7
|
+
const server = new McpServer({
|
|
8
|
+
name: "gikendaasowin-aabajichiganan-mcp",
|
|
9
|
+
// Version reflects significant enhancement in descriptive guidance
|
|
10
|
+
version: "0.4.0",
|
|
11
|
+
description: "ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Gikendaasowin Aabajichiganan - (Cognitive Tools v0.4.0): An MCP server providing a suite of advanced internal reasoning tools designed to elevate an LLM agent's performance in complex problem-solving, particularly in pair programming contexts. Emphasizes structured thought (like Anthropic's 'think' tool research), strategic planning, explicit reasoning (CoT), and iterative self-correction (Reflection) to achieve higher reliability and benchmark-level cognitive capabilities."
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// --- Core Cognitive Tool ---
|
|
15
|
+
|
|
16
|
+
server.tool(
|
|
17
|
+
"think",
|
|
18
|
+
// Main Description: Reinforced role as the central cognitive hub, linking to robustness and pair programming clarity.
|
|
19
|
+
"MANDATORY Cognitive Hub & Navigator's Log. Use this internal workspace for structured deliberation BEFORE any external action/response and AFTER using ANY other cognitive tool. This logs your detailed reasoning, enhancing traceability, reliability, and facilitating effective pair programming communication. Essential for complex tasks requiring policy adherence, sequential decision-making, and robust error handling.",
|
|
20
|
+
{
|
|
21
|
+
// Parameter Description: Added emphasis on quality, structure elements, and pair programming role.
|
|
22
|
+
thought: z.string().describe("Your detailed, structured internal monologue (Navigator's Log). MUST explicitly cover: 1) **Analysis** (Deconstruct request/situation/tool output), 2) **Planning** (Concrete next steps, potential tool use), 3) **Verification** (Check against requirements, constraints, best practices), 4) **Risk Assessment** (Identify potential issues, edge cases, errors), 5) **Self-Correction** (Explicitly state corrections to prior reasoning/plans). Use clear headings/structure (e.g., ## Analysis, ## Plan). Quality and completeness of reasoning are paramount for robust performance.")
|
|
23
|
+
},
|
|
24
|
+
// Implementation: Logs the structured thought process.
|
|
25
|
+
async ({ thought }) => {
|
|
26
|
+
if (!thought || typeof thought !== 'string' || thought.trim().length === 0) {
|
|
27
|
+
throw new Error('Invalid thought: Must be a non-empty string containing substantive reasoning.');
|
|
28
|
+
}
|
|
29
|
+
console.error(`[CognitiveToolsServer] Think Tool Logged: ${thought.substring(0, 100)}...`);
|
|
30
|
+
return {
|
|
31
|
+
content: [{
|
|
32
|
+
type: "text" as const,
|
|
33
|
+
text: thought // Return the logged thought for context preservation
|
|
34
|
+
}]
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// --- Supporting Cognitive Strategy Tools ---
|
|
40
|
+
// Note: These guide the LLM's internal generation process *before* the tool call.
|
|
41
|
+
// The subsequent mandatory 'think' call analyzes the *result* of that internal generation.
|
|
42
|
+
|
|
43
|
+
server.tool(
|
|
44
|
+
"chain_of_thought",
|
|
45
|
+
// Main Description: Emphasizes use for complex reasoning, explainability, and reducing errors.
|
|
46
|
+
"Guides the LLM to generate and articulate an explicit, step-by-step logical deduction path. Crucial for complex problem decomposition, algorithmic reasoning, debugging logic, and tasks demanding high explainability to minimize reasoning errors. The generated CoT MUST be analyzed via `think`.",
|
|
47
|
+
{
|
|
48
|
+
// Parameter Description: Instructs LLM on the required *internal* generation task.
|
|
49
|
+
problem_statement: z.string().describe("Input the specific problem/question requiring detailed step-by-step reasoning. *You* (the LLM) must now *internally generate* your detailed Chain of Thought process for this problem *before* calling this tool. This tool call signals the completion of that internal CoT generation.")
|
|
50
|
+
},
|
|
51
|
+
// Implementation: Signals CoT was performed for the given problem.
|
|
52
|
+
async ({ problem_statement }) => {
|
|
53
|
+
if (!problem_statement || typeof problem_statement !== 'string' || problem_statement.trim().length === 0) {
|
|
54
|
+
throw new Error('Invalid problem statement: Must be a non-empty string.');
|
|
55
|
+
}
|
|
56
|
+
console.error(`[CognitiveToolsServer] ChainOfThought Tool Signaled for: ${problem_statement.substring(0, 100)}...`);
|
|
57
|
+
return {
|
|
58
|
+
content: [{
|
|
59
|
+
type: "text" as const,
|
|
60
|
+
text: `Chain of Thought generation signaled for problem: ${problem_statement}`
|
|
61
|
+
}]
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
server.tool(
|
|
67
|
+
"reflection",
|
|
68
|
+
// Main Description: Positions as key for iterative refinement, accuracy, and benchmark performance.
|
|
69
|
+
"Guides the LLM to perform critical self-evaluation of its own prior reasoning, plans, or generated code. Essential for iterative refinement, identifying hidden flaws, improving robustness, and achieving higher accuracy on complex benchmarks. The critique MUST be analyzed via `think`.",
|
|
70
|
+
{
|
|
71
|
+
// Parameter Description: Instructs LLM on the self-critique task.
|
|
72
|
+
input_reasoning_or_plan: z.string().describe("Input the specific reasoning, plan, or code segment *you* (the LLM) must now critically evaluate *before* calling this tool. Your internal critique should identify logical fallacies, overlooked assumptions, potential inefficiencies, biases, or edge cases, and propose concrete improvements.")
|
|
73
|
+
},
|
|
74
|
+
// Implementation: Signals Reflection was performed.
|
|
75
|
+
async ({ input_reasoning_or_plan }) => {
|
|
76
|
+
if (!input_reasoning_or_plan || typeof input_reasoning_or_plan !== 'string' || input_reasoning_or_plan.trim().length === 0) {
|
|
77
|
+
throw new Error('Invalid input reasoning/plan: Must be a non-empty string.');
|
|
78
|
+
}
|
|
79
|
+
console.error(`[CognitiveToolsServer] Reflection Tool Signaled for analysis.`);
|
|
80
|
+
return {
|
|
81
|
+
content: [{
|
|
82
|
+
type: "text" as const,
|
|
83
|
+
text: `Reflection generation signaled for input: ${input_reasoning_or_plan.substring(0, 150)}...`
|
|
84
|
+
}]
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
server.tool(
|
|
90
|
+
"plan_and_solve",
|
|
91
|
+
// Main Description: Highlights role in structuring complex tasks and managing agentic workflows.
|
|
92
|
+
"Guides the LLM to decompose a complex objective into a high-level, structured strategic plan. Outlines necessary phases, potential sub-tasks, and anticipated tool usage, improving manageability of multi-step agentic workflows. The generated plan MUST be validated and detailed via `think`.",
|
|
93
|
+
{
|
|
94
|
+
// Parameter Description: Instructs LLM on plan generation.
|
|
95
|
+
task_objective: z.string().describe("Input the high-level objective. *You* (the LLM) must now *internally generate* a structured, multi-step plan (roadmap) to achieve this objective *before* calling this tool. Consider dependencies and necessary intermediate steps.")
|
|
96
|
+
},
|
|
97
|
+
// Implementation: Signals Planning was performed.
|
|
98
|
+
async ({ task_objective }) => {
|
|
99
|
+
if (!task_objective || typeof task_objective !== 'string' || task_objective.trim().length === 0) {
|
|
100
|
+
throw new Error('Invalid task objective: Must be a non-empty string.');
|
|
101
|
+
}
|
|
102
|
+
console.error(`[CognitiveToolsServer] PlanAndSolve Tool Signaled for: ${task_objective.substring(0, 100)}...`);
|
|
103
|
+
return {
|
|
104
|
+
content: [{
|
|
105
|
+
type: "text" as const,
|
|
106
|
+
text: `Planning generation signaled for objective: ${task_objective}`
|
|
107
|
+
}]
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
server.tool(
|
|
113
|
+
"chain_of_draft",
|
|
114
|
+
// Main Description: Positions for efficient exploration and hypothesis generation.
|
|
115
|
+
"Guides the LLM to generate concise, iterative reasoning drafts ('thought-sketches'). Useful for efficiently exploring multiple solution paths, brainstorming hypotheses, or outlining approaches when full CoT verbosity is premature. Drafts MUST be analyzed comparatively via `think`.",
|
|
116
|
+
{
|
|
117
|
+
// Parameter Description: Instructs LLM on draft generation.
|
|
118
|
+
problem_statement: z.string().describe("Input the problem or question for exploration. *You* (the LLM) must now *internally generate* brief, iterative reasoning drafts (key steps, pros/cons, core ideas) for potential approaches *before* calling this tool.")
|
|
119
|
+
},
|
|
120
|
+
// Implementation: Signals Drafting was performed.
|
|
121
|
+
async ({ problem_statement }) => {
|
|
122
|
+
if (!problem_statement || typeof problem_statement !== 'string' || problem_statement.trim().length === 0) {
|
|
123
|
+
throw new Error('Invalid problem statement: Must be a non-empty string.');
|
|
124
|
+
}
|
|
125
|
+
console.error(`[CognitiveToolsServer] ChainOfDraft Tool Signaled for: ${problem_statement.substring(0, 100)}...`);
|
|
126
|
+
return {
|
|
127
|
+
content: [{
|
|
128
|
+
type: "text" as const,
|
|
129
|
+
text: `Chain of Draft generation signaled for problem: ${problem_statement}`
|
|
130
|
+
}]
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
// --- Server Lifecycle and Error Handling ---
|
|
137
|
+
|
|
138
|
+
process.on('SIGINT', async () => {
|
|
139
|
+
console.error('[CognitiveToolsServer] Received SIGINT, shutting down.');
|
|
140
|
+
await server.close();
|
|
141
|
+
process.exit(0);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
process.on('SIGTERM', async () => {
|
|
145
|
+
console.error('[CognitiveToolsServer] Received SIGTERM, shutting down.');
|
|
146
|
+
await server.close();
|
|
147
|
+
process.exit(0);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
process.on('uncaughtException', (error) => {
|
|
151
|
+
console.error('[CognitiveToolsServer] Uncaught exception:', error);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
155
|
+
console.error('[CognitiveToolsServer] Unhandled promise rejection:', reason);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// Start the server
|
|
159
|
+
async function main() {
|
|
160
|
+
try {
|
|
161
|
+
const transport = new StdioServerTransport();
|
|
162
|
+
await server.connect(transport);
|
|
163
|
+
console.error('ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Gikendaasowin Aabajichiganan - (Cognitive Tools v0.4.0) MCP Server running on stdio');
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
console.error('Fatal error in main():', error);
|
|
167
|
+
process.exit(1);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
main();
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
// Create the MCP server
|
|
7
|
+
const server = new McpServer({
|
|
8
|
+
name: "gikendaasowin-aabajichiganan",
|
|
9
|
+
// Version reflects novel tools and enhanced guidance
|
|
10
|
+
version: "0.6.2",
|
|
11
|
+
description: "ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Gikendaasowin Aabajichiganan - (Cognitive Tools v0.6.2): SOTA internal reasoning suite for LLM agents. Features advanced deliberation (`think`), rapid checks (`quick_think`), explicit complexity assessment, context synthesis (`synthesize`), confidence gauging, planning, CoT, and reflection. Designed to maximize reliability, traceability, and performance on complex cognitive tasks, pushing beyond current research."
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// --- Core Cognitive Deliberation Tools ---
|
|
15
|
+
|
|
16
|
+
server.tool(
|
|
17
|
+
"think",
|
|
18
|
+
// Main Description: For High Cognitive Load situations.
|
|
19
|
+
"MANDATORY Cognitive Hub for **High Complexity/Uncertainty/Consequence/Novelty**. Use for deep analysis, planning, verification, risk assessment, self-correction, and integrating complex outputs (CoT, Plans, Critiques, Syntheses, Low Confidence Gauges). Logs detailed reasoning.",
|
|
20
|
+
{
|
|
21
|
+
// Parameter Description: Must analyze inputs including novel tool outputs.
|
|
22
|
+
thought: z.string().describe("Your **detailed** internal monologue for complex situations. MUST explicitly analyze prior steps/generated text (CoT, Plans, Critiques, Synthesized summaries, Confidence justifications). Structure: ## Analysis, ## Plan, ## Verification, ## Risk Assessment, ## Self-Correction. Ensure depth and clear linkage.")
|
|
23
|
+
},
|
|
24
|
+
async ({ thought }) => {
|
|
25
|
+
if (!thought || typeof thought !== 'string' || thought.trim().length === 0) { throw new Error('Invalid thought: Must be non-empty.'); }
|
|
26
|
+
console.error(`[CognitiveToolsServer] Think Tool Logged: ${thought.substring(0, 100)}...`);
|
|
27
|
+
return { content: [{ type: "text" as const, text: `Deep Thought Logged: ${thought}` }] };
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
server.tool(
|
|
32
|
+
"quick_think",
|
|
33
|
+
// Main Description: For Low Cognitive Load situations. Explicitly contrasted with 'think'.
|
|
34
|
+
"Cognitive Checkpoint for **Low Complexity/Uncertainty/Consequence**. Use ONLY for simple confirmations, acknowledgements, minor step decisions, or sanity checks where deep analysis is clearly unnecessary. Logs brief thought.",
|
|
35
|
+
{
|
|
36
|
+
brief_thought: z.string().describe("Your **concise** thought for simple situations (e.g., 'Acknowledged.', 'Proceeding with planned step X.', 'API call successful, extracting data.'). DO NOT use for analyzing complex outputs or making significant plans.")
|
|
37
|
+
},
|
|
38
|
+
async ({ brief_thought }) => {
|
|
39
|
+
if (!brief_thought || typeof brief_thought !== 'string' || brief_thought.trim().length === 0) { throw new Error('Invalid brief_thought: Must be non-empty.'); }
|
|
40
|
+
console.error(`[CognitiveToolsServer] QuickThink Tool Logged: ${brief_thought.substring(0, 100)}...`);
|
|
41
|
+
return { content: [{ type: "text" as const, text: `Quick Thought Logged: ${brief_thought}` }] };
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
// --- Novel Meta-Cognitive & Context Management Tools ---
|
|
46
|
+
|
|
47
|
+
server.tool(
|
|
48
|
+
"assess_cuc_n_mode",
|
|
49
|
+
// Main Description: Forces explicit decision between think/quick_think.
|
|
50
|
+
"**Mandatory Pre-Thought Assessment.** Guides the LLM to explicitly evaluate the upcoming cognitive step's complexity, uncertainty, consequence, and novelty, and *commit* to using either `think` or `quick_think` next. Enhances deliberate cognitive resource allocation.",
|
|
51
|
+
{
|
|
52
|
+
// Parameter Description: LLM provides its assessment and chosen mode.
|
|
53
|
+
assessment_and_choice: z.string().describe("Input your assessment: 1) Briefly describe the situation/next step. 2) Rate Complexity (Low/Med/High), Uncertainty (L/M/H), Consequence (L/M/H), Novelty (L/M/H). 3) State your choice: 'Selected Mode: think' or 'Selected Mode: quick_think'. *You* (LLM) make this assessment *before* calling.")
|
|
54
|
+
},
|
|
55
|
+
async ({ assessment_and_choice }) => {
|
|
56
|
+
if (!assessment_and_choice || typeof assessment_and_choice !== 'string' || (!assessment_and_choice.includes("Selected Mode: think") && !assessment_and_choice.includes("Selected Mode: quick_think"))) {
|
|
57
|
+
throw new Error('Invalid assessment: Must include complexity/uncertainty/consequence/novelty ratings and explicit mode selection ("Selected Mode: think" or "Selected Mode: quick_think").');
|
|
58
|
+
}
|
|
59
|
+
console.error(`[CognitiveToolsServer] AssessComplexity Tool Signaled: ${assessment_and_choice.substring(0, 150)}...`);
|
|
60
|
+
// Output confirms the assessment was made and which mode was selected.
|
|
61
|
+
const mode = assessment_and_choice.includes("Selected Mode: think") ? "think" : "quick_think";
|
|
62
|
+
return { content: [{ type: "text" as const, text: `Complexity Assessment Completed. Selected Next Mode: ${mode}. Assessment: ${assessment_and_choice}` }] };
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
server.tool(
|
|
67
|
+
"synthesize_prior_reasoning",
|
|
68
|
+
// Main Description: Manages context window and focuses reasoning.
|
|
69
|
+
"Context Management Tool. Guides the LLM to **generate a concise summary text** of preceding lengthy reasoning chains (multiple `think` logs, CoT outputs). Used to manage context limits and refocus attention before major subsequent `think` steps.",
|
|
70
|
+
{
|
|
71
|
+
// Parameter Description: LLM generates the summary internally first.
|
|
72
|
+
context_to_summarize_description: z.string().describe("Briefly describe the span of reasoning you are summarizing (e.g., 'Summary of planning phase', 'Key takeaways from debugging CoT'). *You* (LLM) must now *internally generate the concise summary text* before calling this tool. This signals the summary is ready.")
|
|
73
|
+
},
|
|
74
|
+
async ({ context_to_summarize_description }) => {
|
|
75
|
+
if (!context_to_summarize_description || typeof context_to_summarize_description !== 'string' || context_to_summarize_description.trim().length === 0) { throw new Error('Invalid context description: Must be non-empty.'); }
|
|
76
|
+
console.error(`[CognitiveToolsServer] SynthesizeReasoning Tool Signaled for: ${context_to_summarize_description}...`);
|
|
77
|
+
// Output confirms context and implies summary text is available internally
|
|
78
|
+
return { content: [{ type: "text" as const, text: `Synthesis internally generated for context: '${context_to_summarize_description}'. Ready for 'think' analysis.` }] };
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
server.tool(
|
|
83
|
+
"gauge_confidence",
|
|
84
|
+
// Main Description: Explicit meta-cognition about certainty.
|
|
85
|
+
"Meta-Cognitive Checkpoint. Guides the LLM to explicitly **state its confidence level (High/Medium/Low) and justification** regarding a specific plan, analysis, conclusion, or proposed action *before* proceeding. Low confidence may trigger Reflection or deeper Thinking.",
|
|
86
|
+
{
|
|
87
|
+
// Parameter Description: LLM provides its confidence assessment.
|
|
88
|
+
assessment_and_confidence: z.string().describe("Input the item being assessed (e.g., 'Confidence in current plan', 'Confidence in generated code correctness'). Then state: 1) Confidence Level (High/Medium/Low). 2) Brief Justification for this level. *You* (LLM) make this assessment *before* calling.")
|
|
89
|
+
},
|
|
90
|
+
async ({ assessment_and_confidence }) => {
|
|
91
|
+
const confidenceRegex = /Confidence Level: (High|Medium|Low)/i;
|
|
92
|
+
if (!assessment_and_confidence || typeof assessment_and_confidence !== 'string' || !confidenceRegex.test(assessment_and_confidence)) {
|
|
93
|
+
throw new Error('Invalid confidence assessment: Must include "Confidence Level: High/Medium/Low" and justification.');
|
|
94
|
+
}
|
|
95
|
+
const match = assessment_and_confidence.match(confidenceRegex);
|
|
96
|
+
const level = match ? match[1] : "Unknown";
|
|
97
|
+
console.error(`[CognitiveToolsServer] GaugeConfidence Tool Signaled: Level ${level}`);
|
|
98
|
+
// Output confirms assessment and level
|
|
99
|
+
return { content: [{ type: "text" as const, text: `Confidence Gauge Completed. Level: ${level}. Assessment: ${assessment_and_confidence}` }] };
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
// --- Supporting Cognitive Strategy Tools (Enhanced Descriptions) ---
|
|
104
|
+
|
|
105
|
+
server.tool(
|
|
106
|
+
"plan_and_solve",
|
|
107
|
+
// Main Description: Highlights role in structuring complex tasks and managing agentic workflows.
|
|
108
|
+
"Guides the LLM to **generate a structured, multi-step plan text** for a complex objective. Outlines necessary phases, potential sub-tasks, and anticipated tool usage, improving manageability of multi-step agentic workflows. The generated plan MUST be validated and detailed via `think`, and can optionally be passed to `reflection` for critique.",
|
|
109
|
+
{
|
|
110
|
+
// Parameter Description: Instructs LLM on plan generation.
|
|
111
|
+
task_objective: z.string().describe("Input the high-level objective. *You* (the LLM) must now *internally generate the structured plan text* before calling this tool. This signals the plan text is ready for analysis/critique.")
|
|
112
|
+
},
|
|
113
|
+
// Implementation: Signals Planning was performed.
|
|
114
|
+
async ({ task_objective }) => {
|
|
115
|
+
if (!task_objective || typeof task_objective !== 'string' || task_objective.trim().length === 0) {
|
|
116
|
+
throw new Error('Invalid task objective: Must be a non-empty string.');
|
|
117
|
+
}
|
|
118
|
+
console.error(`[CognitiveToolsServer] PlanAndSolve Tool Signaled for: ${task_objective.substring(0, 100)}...`);
|
|
119
|
+
return { content: [{ type: "text" as const, text: `Planning generation signaled for objective: ${task_objective}. Ready for 'think' analysis.` }] };
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
server.tool(
|
|
124
|
+
"chain_of_thought",
|
|
125
|
+
// Main Description: Emphasizes generating text for later analysis.
|
|
126
|
+
"Guides the LLM to **generate detailed, step-by-step reasoning text**. Used for complex logic or explainability. The *generated CoT text* MUST then be analyzed in a subsequent `think` call.",
|
|
127
|
+
{
|
|
128
|
+
// Parameter Description: Focus on the input problem.
|
|
129
|
+
problem_statement: z.string().describe("Input the problem requiring detailed step-by-step reasoning. *You* (the LLM) must now *internally generate the full CoT text* before calling this tool. This signals that CoT text is ready for analysis in the next `think` step.")
|
|
130
|
+
},
|
|
131
|
+
// Implementation: Signals CoT was performed for the given problem.
|
|
132
|
+
async ({ problem_statement }) => {
|
|
133
|
+
if (!problem_statement || typeof problem_statement !== 'string' || problem_statement.trim().length === 0) {
|
|
134
|
+
throw new Error('Invalid problem statement: Must be a non-empty string.');
|
|
135
|
+
}
|
|
136
|
+
console.error(`[CognitiveToolsServer] ChainOfThought Tool Signaled for: ${problem_statement.substring(0, 100)}...`);
|
|
137
|
+
return { content: [{ type: "text" as const, text: `Chain of Thought internally generated for problem: ${problem_statement}. Ready for 'think' analysis.` }] };
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
server.tool(
|
|
142
|
+
"chain_of_draft",
|
|
143
|
+
// Main Description: Positions for efficient exploration and hypothesis generation.
|
|
144
|
+
"Guides the LLM to **generate concise, iterative reasoning draft texts** ('thought-sketches'). Useful for efficiently exploring multiple solution paths, brainstorming hypotheses, or outlining approaches when full CoT verbosity is premature. Drafts MUST be analyzed comparatively via `think`.",
|
|
145
|
+
{
|
|
146
|
+
// Parameter Description: Instructs LLM on draft generation.
|
|
147
|
+
problem_statement: z.string().describe("Input the problem or question for exploration. *You* (the LLM) must now *internally generate brief, iterative draft texts* (key steps, pros/cons, core ideas) for potential approaches *before* calling this tool.")
|
|
148
|
+
},
|
|
149
|
+
// Implementation: Signals Drafting was performed.
|
|
150
|
+
async ({ problem_statement }) => {
|
|
151
|
+
if (!problem_statement || typeof problem_statement !== 'string' || problem_statement.trim().length === 0) {
|
|
152
|
+
throw new Error('Invalid problem statement: Must be a non-empty string.');
|
|
153
|
+
}
|
|
154
|
+
console.error(`[CognitiveToolsServer] ChainOfDraft Tool Signaled for: ${problem_statement.substring(0, 100)}...`);
|
|
155
|
+
return { content: [{ type: "text" as const, text: `Chain of Draft generation signaled for problem: ${problem_statement}. Ready for 'think' analysis.` }] };
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
server.tool(
|
|
160
|
+
"reflection",
|
|
161
|
+
// Main Description: Explicitly mentions taking prior text as input for critique.
|
|
162
|
+
"Guides the LLM to perform critical self-evaluation on **previously generated text** (reasoning, plans, code concepts). Essential for iterative refinement and improving accuracy. The *generated critique text* MUST be analyzed via `think`.",
|
|
163
|
+
{
|
|
164
|
+
// Parameter Description: Input is the text to be critiqued.
|
|
165
|
+
input_reasoning_or_plan: z.string().describe("Input the **exact text** (e.g., from a prior `think` log, or internally generated plan/CoT/code concept) that *you* (the LLM) must now *internally generate a critique for*. Your critique should identify flaws and suggest improvements.")
|
|
166
|
+
},
|
|
167
|
+
// Implementation: Signals Reflection was performed.
|
|
168
|
+
async ({ input_reasoning_or_plan }) => {
|
|
169
|
+
if (!input_reasoning_or_plan || typeof input_reasoning_or_plan !== 'string' || input_reasoning_or_plan.trim().length === 0) {
|
|
170
|
+
throw new Error('Invalid input reasoning/plan: Must be a non-empty string.');
|
|
171
|
+
}
|
|
172
|
+
console.error(`[CognitiveToolsServer] Reflection Tool Signaled for analysis.`);
|
|
173
|
+
return { content: [{ type: "text" as const, text: `Reflection internally generated for input text: '${input_reasoning_or_plan.substring(0, 100)}...'. Ready for 'think' analysis.` }] };
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
// --- Server Lifecycle and Error Handling ---
|
|
179
|
+
|
|
180
|
+
process.on('SIGINT', async () => {
|
|
181
|
+
console.error('[CognitiveToolsServer] Received SIGINT, shutting down.');
|
|
182
|
+
await server.close();
|
|
183
|
+
process.exit(0);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
process.on('SIGTERM', async () => {
|
|
187
|
+
console.error('[CognitiveToolsServer] Received SIGTERM, shutting down.');
|
|
188
|
+
await server.close();
|
|
189
|
+
process.exit(0);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
process.on('uncaughtException', (error) => {
|
|
193
|
+
console.error('[CognitiveToolsServer] Uncaught exception:', error);
|
|
194
|
+
// Depending on severity, you might want to gracefully shutdown or just log
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
198
|
+
console.error('[CognitiveToolsServer] Unhandled promise rejection:', reason);
|
|
199
|
+
// Depending on severity, you might want to gracefully shutdown or just log
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// Start the server
|
|
203
|
+
async function main() {
|
|
204
|
+
try {
|
|
205
|
+
const transport = new StdioServerTransport();
|
|
206
|
+
await server.connect(transport);
|
|
207
|
+
console.error('ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Gikendaasowin Aabajichiganan - (Cognitive Tools v0.6.2) MCP Server running on stdio');
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
console.error('[CognitiveToolsServer] Fatal error during startup:', error);
|
|
211
|
+
process.exit(1);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Execute the main function to start the server
|
|
216
|
+
main();
|