@nbiish/cognitive-tools-mcp 0.9.30 → 2.0.1
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/build/index.js +77 -65
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* -----------------------------------------------------------------------------
|
|
4
|
-
* Gikendaasowin Aabajichiganan -
|
|
4
|
+
* Gikendaasowin Aabajichiganan - Agentic Cognitive Tools MCP Server (v2.0)
|
|
5
5
|
*
|
|
6
|
-
* Description: Provides
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
6
|
+
* Description: Provides cognitive tools for an AI agent based on the
|
|
7
|
+
* Gikendaasowin Cognitive Framework (v7 Guidelines). Emphasizes
|
|
8
|
+
* a mandatory structured deliberation cycle (Observe-Orient-Decide-Act)
|
|
9
|
+
* performed *after* receiving information and *before* significant actions,
|
|
10
|
+
* ideally using the `think` tool. Supports adaptive reasoning styles
|
|
11
|
+
* (CoT, CoD/CRP, SCoT) and integrates with potentially dynamic toolsets,
|
|
12
|
+
* including a preference for Executable Code Actions (CodeAct) if available.
|
|
13
|
+
* Returns Markdown.
|
|
13
14
|
*
|
|
14
|
-
* Key Principles:
|
|
15
|
-
* 1. **
|
|
16
|
-
*
|
|
17
|
-
* 2. **Centralized Analysis (`think`):** The `think` tool is the
|
|
18
|
-
*
|
|
19
|
-
* 3. **
|
|
20
|
-
* 4. **
|
|
21
|
-
* 5. **
|
|
22
|
-
* 6. **
|
|
15
|
+
* Key Principles (v7 Alignment):
|
|
16
|
+
* 1. **Mandatory Deliberation:** A structured internal reasoning cycle is required
|
|
17
|
+
* before non-trivial actions.
|
|
18
|
+
* 2. **Centralized Analysis (`think`):** The `think` tool is the preferred mechanism
|
|
19
|
+
* for the mandatory deliberation cycle (analysis, planning, OODReAct structure).
|
|
20
|
+
* 3. **Adaptability:** Assumes the agent adapts to dynamically available tools.
|
|
21
|
+
* 4. **CodeAct Preference:** Aligns with agent preference for executable code actions.
|
|
22
|
+
* 5. **Adaptive Reasoning:** Supports CoT, CoD/CRP, SCoT styles within `think`.
|
|
23
|
+
* 6. **Traceability:** Logs tool usage; `think` tool provides reasoning trace.
|
|
24
|
+
* 7. **Markdown Output:** Tool results formatted as Markdown.
|
|
23
25
|
*
|
|
24
26
|
* Protocol: Model Context Protocol (MCP) over stdio.
|
|
25
27
|
* -----------------------------------------------------------------------------
|
|
@@ -29,13 +31,12 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
29
31
|
import { z } from "zod";
|
|
30
32
|
// --- Server Definition ---
|
|
31
33
|
const serverInfo = {
|
|
32
|
-
name: "gikendaasowin-
|
|
33
|
-
version: "
|
|
34
|
-
description: `ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ -
|
|
34
|
+
name: "gikendaasowin-agentic-cognitive-tools-mcp",
|
|
35
|
+
version: "2.0.0", // Version reflects alignment with v7 guidelines
|
|
36
|
+
description: `ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Agentic Cognitive Tools (v2.0): Implements Gikendaasowin v7 Guidelines. Facilitates mandatory Observe-Orient-Decide-Act deliberation cycle (using 'think' tool) before actions. Supports adaptive reasoning (CoT, CoD/CRP, SCoT) and dynamic tool environments (incl. CodeAct preference). Returns Markdown.`
|
|
35
37
|
};
|
|
36
38
|
const server = new McpServer(serverInfo);
|
|
37
39
|
// --- Logging Helpers ---
|
|
38
|
-
// [Keep existing logToolCall, logToolResult, logToolError functions]
|
|
39
40
|
/**
|
|
40
41
|
* Logs an incoming tool call to stderr.
|
|
41
42
|
* @param toolName The name of the tool being called.
|
|
@@ -66,42 +67,39 @@ function logToolError(toolName, error) {
|
|
|
66
67
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
67
68
|
console.error(`[${timestamp}] [MCP Server] ! Tool Error: ${toolName} - ${errorMessage}`);
|
|
68
69
|
logToolResult(toolName, false, errorMessage); // Log failure result as well
|
|
69
|
-
// Return a structured error message suitable for the LLM
|
|
70
|
+
// Return a structured error message suitable for the LLM, guiding towards the mandatory deliberation step
|
|
70
71
|
return {
|
|
71
72
|
content: [{
|
|
72
73
|
type: "text",
|
|
73
|
-
text: `Error executing tool '${toolName}': ${errorMessage}.
|
|
74
|
+
text: `Error executing tool '${toolName}': ${errorMessage}. **Action Required:** Initiate the mandatory deliberation cycle (use the 'think' tool if available) to analyze this error (Observe/Orient), review context/goals, and plan the next corrective step (Decide/Reason/Act(Plan)).`
|
|
74
75
|
}]
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
|
-
// --- Core Cognitive Deliberation & Refinement Tools ---
|
|
78
|
+
// --- Core Cognitive Deliberation & Refinement Tools (Aligned with v7 Guidelines) ---
|
|
78
79
|
/**
|
|
79
|
-
* Tool: assess_cuc_n_mode
|
|
80
|
-
* Purpose:
|
|
81
|
-
*
|
|
82
|
-
*
|
|
80
|
+
* Tool: assess_cuc_n_mode (Optional Initial Assessment)
|
|
81
|
+
* Purpose: Optional initial assessment of task characteristics (Complexity, Uncertainty, Consequence, Novelty)
|
|
82
|
+
* to *inform* the strategy for the mandatory deliberation cycle.
|
|
83
|
+
* Workflow: Can be called *optionally* at the start of complex tasks to help frame the initial approach.
|
|
84
|
+
* The primary, mandatory deliberation happens *later* using `think` or internally.
|
|
85
|
+
* Output: Returns the assessment text formatted as Markdown.
|
|
83
86
|
*/
|
|
84
|
-
server.tool("assess_cuc_n_mode", "**Initial Assessment.** Evaluates task Complexity, Uncertainty, Consequence, Novelty (CUC-N) to
|
|
85
|
-
|
|
86
|
-
}, async ({
|
|
87
|
+
server.tool("assess_cuc_n_mode", "**(Optional) Initial Task Assessment.** Evaluates task Complexity, Uncertainty, Consequence, Novelty (CUC-N) to *inform* the initial strategy. Call optionally before complex tasks. This assessment helps frame the mandatory deliberation cycle (which uses `think` or occurs internally) but does *not* replace it. Output is your assessment.", {
|
|
88
|
+
assessment_text: z.string().describe("Your structured CUC-N assessment including: 1) Situation/Task Summary, 2) CUC-N Analysis (Low/Medium/High rationale), 3) Potential Strategy Considerations (e.g., 'Requires careful step-by-step planning via CoT', 'Efficiency via CoD/CRP seems appropriate', 'Need to prioritize CodeAct for file manipulation'). This informs, but does not dictate, the mandatory deliberation step.")
|
|
89
|
+
}, async ({ assessment_text }) => {
|
|
87
90
|
const toolName = 'assess_cuc_n_mode';
|
|
88
91
|
logToolCall(toolName);
|
|
89
92
|
try {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const selectedMode = modeMatch ? modeMatch[1].toLowerCase() : "unknown";
|
|
93
|
-
if (assessment_and_choice.trim().length === 0) {
|
|
94
|
-
throw new Error('Invalid assessment_and_choice: Must be a non-empty string.');
|
|
93
|
+
if (assessment_text.trim().length === 0) {
|
|
94
|
+
throw new Error('Invalid assessment_text: Must be a non-empty string containing the CUC-N analysis.');
|
|
95
95
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
logToolResult(toolName, true, `Selected mode (extracted): ${selectedMode}`);
|
|
100
|
-
console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Input:\n${assessment_and_choice}`);
|
|
96
|
+
logToolResult(toolName, true, `Assessment logged (length: ${assessment_text.length})`);
|
|
97
|
+
console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Input:\n${assessment_text}`);
|
|
98
|
+
// Return the assessment text directly
|
|
101
99
|
return {
|
|
102
100
|
content: [{
|
|
103
101
|
type: "text",
|
|
104
|
-
text:
|
|
102
|
+
text: assessment_text
|
|
105
103
|
}]
|
|
106
104
|
};
|
|
107
105
|
}
|
|
@@ -110,22 +108,32 @@ server.tool("assess_cuc_n_mode", "**Initial Assessment.** Evaluates task Complex
|
|
|
110
108
|
}
|
|
111
109
|
});
|
|
112
110
|
/**
|
|
113
|
-
* Tool: think
|
|
114
|
-
* Purpose: The **CENTRAL HUB** for
|
|
115
|
-
*
|
|
116
|
-
*
|
|
111
|
+
* Tool: think (Mandatory Deliberation Hub)
|
|
112
|
+
* Purpose: The **PREFERRED & CENTRAL HUB** for the **MANDATORY** structured deliberation cycle
|
|
113
|
+
* (Observe-Orient-Decide-Act).
|
|
114
|
+
* Workflow: **MUST** be called (if available) *after* receiving new information (tool results, CodeAct output/errors,
|
|
115
|
+
* USER input, file reads) and *before* executing any non-trivial action (tool call, CodeAct execution,
|
|
116
|
+
* complex response generation). Use it to analyze inputs, orient context/goals/policies, decide the next
|
|
117
|
+
* action, reason (CoT, CoD/CRP, SCoT), plan the action details (tool params, CodeAct code), define
|
|
118
|
+
* verification, and consider risks. Essential for reliability, error handling, and complex tasks.
|
|
119
|
+
* Output: Returns the structured thought process itself, formatted as Markdown, serving as an internal log.
|
|
117
120
|
*/
|
|
118
|
-
server.tool("think", "**
|
|
119
|
-
thought: z.string().describe("Your **structured
|
|
121
|
+
server.tool("think", "**Mandatory Deliberation Hub.** Use this tool (if available) for the required structured deliberation cycle *after* info and *before* action. Input MUST follow the OODReAct structure: ## Observe (analyze inputs/results/errors), ## Orient (context/goals/policy check), ## Decide (next action: tool, CodeAct, query, respond), ## Reason (justify decision; use CoT, CoD/CRP, or SCoT style), ## Act (Plan) (tool params, CodeAct code, response draft), ## Verification (success criteria), ## Risk & Contingency (briefly).", {
|
|
122
|
+
thought: z.string().describe("Your **structured OODReAct deliberation**. MUST include all sections: Observe, Orient, Decide, Reason (using appropriate CoT/CoD/CRP/SCoT style), Act(Plan) (with specific tool parameters or CodeAct code), Verification, Risk & Contingency. This is critical for documenting the mandatory reasoning process before acting.")
|
|
120
123
|
}, async ({ thought }) => {
|
|
121
124
|
const toolName = 'think';
|
|
122
125
|
logToolCall(toolName);
|
|
123
126
|
try {
|
|
127
|
+
// Basic validation: Check if it's non-empty and maybe contains expected markers
|
|
124
128
|
if (thought.trim().length === 0) {
|
|
125
|
-
throw new Error('Invalid thought: Must be a non-empty string
|
|
129
|
+
throw new Error('Invalid thought: Must be a non-empty string.');
|
|
130
|
+
}
|
|
131
|
+
if (!thought.includes("## Observe:") || !thought.includes("## Orient:") || !thought.includes("## Decide:") || !thought.includes("## Reason:") || !thought.includes("## Act (Plan):")) {
|
|
132
|
+
throw new Error('Invalid thought structure: Must contain required OODReAct sections (Observe, Orient, Decide, Reason, Act(Plan)).');
|
|
126
133
|
}
|
|
127
|
-
logToolResult(toolName, true, `
|
|
134
|
+
logToolResult(toolName, true, `Deliberation logged (length: ${thought.length})`);
|
|
128
135
|
console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Input:\n${thought}`);
|
|
136
|
+
// Return the thought process itself as the result
|
|
129
137
|
return {
|
|
130
138
|
content: [{
|
|
131
139
|
type: "text",
|
|
@@ -138,13 +146,16 @@ server.tool("think", "**Central Hub for Analysis, Planning & Reasoning.** Use th
|
|
|
138
146
|
}
|
|
139
147
|
});
|
|
140
148
|
/**
|
|
141
|
-
* Tool: quick_think
|
|
142
|
-
* Purpose: A minimal cognitive step for trivial
|
|
143
|
-
* Workflow: Use ONLY
|
|
149
|
+
* Tool: quick_think (Minimal Cognitive Step - Use With Extreme Caution)
|
|
150
|
+
* Purpose: A minimal cognitive step ONLY for acknowledging *trivial*, *immediately obvious* successes or state transitions.
|
|
151
|
+
* Workflow: **STRONGLY DISCOURAGED.** Use ONLY if the mandatory deliberation cycle (`think` or internal) is genuinely unnecessary
|
|
152
|
+
* because the situation involves absolutely no analysis, planning, policy check, error handling, or complex reasoning.
|
|
153
|
+
* Example: Confirming receipt of simple data before an already-planned trivial action.
|
|
154
|
+
* **DO NOT USE** after most tool calls, CodeAct executions, or before any complex action - use `think` instead.
|
|
144
155
|
* Output: Returns the brief thought text, formatted as Markdown.
|
|
145
156
|
*/
|
|
146
|
-
server.tool("quick_think", "**Minimal Cognitive Step
|
|
147
|
-
brief_thought: z.string().describe("Your **extremely concise** confirmation
|
|
157
|
+
server.tool("quick_think", "**(Use Sparingly/Discouraged) Minimal Cognitive Step.** Use ONLY for acknowledging *trivial successes* or confirming *obvious, pre-planned* simple steps where NO analysis/planning/policy check is needed (e.g., 'Data received, proceeding with planned step X'). **The mandatory deliberation cycle (`think` tool or internal) is required for almost all situations.** Prefer `think` after any tool/CodeAct output or error.", {
|
|
158
|
+
brief_thought: z.string().describe("Your **extremely concise** confirmation for a truly trivial step (e.g., 'Trivial action X succeeded'). Must be non-empty but very short. DO NOT use for analysis, planning, error reflection, or complex reasoning - use the `think` tool for the mandatory deliberation cycle.")
|
|
148
159
|
}, async ({ brief_thought }) => {
|
|
149
160
|
const toolName = 'quick_think';
|
|
150
161
|
logToolCall(toolName);
|
|
@@ -152,12 +163,13 @@ server.tool("quick_think", "**Minimal Cognitive Step (Use Sparingly!).** Use ONL
|
|
|
152
163
|
if (brief_thought.trim().length === 0) {
|
|
153
164
|
throw new Error('Invalid brief_thought: Must be a non-empty string.');
|
|
154
165
|
}
|
|
155
|
-
// Optional
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
166
|
+
// Optional stricter length check to enforce brevity
|
|
167
|
+
if (brief_thought.length > 150) { // Example limit
|
|
168
|
+
console.error(`[${new Date().toISOString()}] [MCP Server] WARNING: 'quick_think' input is long. Ensure 'think' wasn't more appropriate.`);
|
|
169
|
+
}
|
|
159
170
|
logToolResult(toolName, true, `Logged: ${brief_thought.substring(0, 80)}...`);
|
|
160
171
|
console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Input:\n${brief_thought}`);
|
|
172
|
+
// Return the brief thought
|
|
161
173
|
return {
|
|
162
174
|
content: [{
|
|
163
175
|
type: "text",
|
|
@@ -170,7 +182,6 @@ server.tool("quick_think", "**Minimal Cognitive Step (Use Sparingly!).** Use ONL
|
|
|
170
182
|
}
|
|
171
183
|
});
|
|
172
184
|
// --- Server Lifecycle and Error Handling ---
|
|
173
|
-
// [Keep existing shutdown, process event handlers, main function]
|
|
174
185
|
/**
|
|
175
186
|
* Gracefully shuts down the server.
|
|
176
187
|
*/
|
|
@@ -186,19 +197,19 @@ async function shutdown() {
|
|
|
186
197
|
process.exit(1);
|
|
187
198
|
}
|
|
188
199
|
}
|
|
200
|
+
// Setup signal handlers
|
|
189
201
|
process.on('SIGINT', shutdown);
|
|
190
202
|
process.on('SIGTERM', shutdown);
|
|
203
|
+
// Setup global error handlers
|
|
191
204
|
process.on('uncaughtException', (error, origin) => {
|
|
192
205
|
const timestamp = new Date().toISOString();
|
|
193
206
|
console.error(`[${timestamp}] [MCP Server] FATAL: Uncaught Exception at: ${origin}`, error);
|
|
194
|
-
|
|
195
|
-
shutdown().catch(() => process.exit(1));
|
|
207
|
+
shutdown().catch(() => process.exit(1)); // Attempt graceful shutdown
|
|
196
208
|
});
|
|
197
209
|
process.on('unhandledRejection', (reason, promise) => {
|
|
198
210
|
const timestamp = new Date().toISOString();
|
|
199
211
|
console.error(`[${timestamp}] [MCP Server] FATAL: Unhandled Promise Rejection:`, reason);
|
|
200
|
-
|
|
201
|
-
shutdown().catch(() => process.exit(1));
|
|
212
|
+
shutdown().catch(() => process.exit(1)); // Attempt graceful shutdown
|
|
202
213
|
});
|
|
203
214
|
// --- Start the Server ---
|
|
204
215
|
/**
|
|
@@ -208,10 +219,11 @@ async function main() {
|
|
|
208
219
|
try {
|
|
209
220
|
const transport = new StdioServerTransport();
|
|
210
221
|
await server.connect(transport);
|
|
211
|
-
const border = '
|
|
222
|
+
const border = '=====================================================';
|
|
212
223
|
console.error(border);
|
|
213
224
|
console.error(` ${serverInfo.description}`);
|
|
214
225
|
console.error(` Version: ${serverInfo.version}`);
|
|
226
|
+
console.error(` Aligned with Gikendaasowin v7 Agentic Guidelines`);
|
|
215
227
|
console.error(' Status: Running on stdio, awaiting MCP requests...');
|
|
216
228
|
console.error(border);
|
|
217
229
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nbiish/cognitive-tools-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "2.0.1",
|
|
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",
|