@nbiish/cognitive-tools-mcp 0.9.19 → 0.9.21
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 +1 -1
- package/build/index.js +154 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -115,7 +115,7 @@ Or:
|
|
|
115
115
|
### `chain_of_thought`
|
|
116
116
|
- **Purpose**: Guides *internal generation* and logging of detailed, step-by-step reasoning draft (CoT).
|
|
117
117
|
- **Workflow**: Internally generate CoT -> Call tool.
|
|
118
|
-
- **Input**:
|
|
118
|
+
- **Input**:
|
|
119
119
|
- `generated_cot_text` (string) - The full CoT draft you generated internally.
|
|
120
120
|
- `problem_statement` (string) - The original problem this CoT addresses.
|
|
121
121
|
- **Follow-up**: Mandatory `think` or `quick_think`.
|
package/build/index.js
CHANGED
|
@@ -38,10 +38,23 @@ import { z } from "zod";
|
|
|
38
38
|
// --- Server Definition ---
|
|
39
39
|
const serverInfo = {
|
|
40
40
|
name: "gikendaasowin-aabajichiganan-mcp",
|
|
41
|
-
version: "0.9.
|
|
41
|
+
version: "0.9.18",
|
|
42
42
|
description: `ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Core Cognitive Tools Suite (Simplified, Relaxed Validation): Enables structured reasoning (CoT/CoD) and analysis for AI agents. Returns results as Markdown.`
|
|
43
43
|
};
|
|
44
44
|
const server = new McpServer(serverInfo);
|
|
45
|
+
// --- Tool Prefix Compatibility Layer ---
|
|
46
|
+
// Add prefixed versions of each tool to ensure backward compatibility
|
|
47
|
+
const TOOL_PREFIX = "mcp_gikendaasowin-aabajichiganan_";
|
|
48
|
+
// This mapping will be used to redirect legacy prefixed tool calls to the simplified names
|
|
49
|
+
const prefixedToolMappings = {
|
|
50
|
+
[`${TOOL_PREFIX}think`]: "think",
|
|
51
|
+
[`${TOOL_PREFIX}assess_cuc_n_mode`]: "assess_cuc_n_mode",
|
|
52
|
+
[`${TOOL_PREFIX}quick_think`]: "quick_think",
|
|
53
|
+
[`${TOOL_PREFIX}chain_of_thought`]: "chain_of_thought",
|
|
54
|
+
[`${TOOL_PREFIX}chain_of_draft`]: "chain_of_draft",
|
|
55
|
+
[`${TOOL_PREFIX}reflection`]: "reflection",
|
|
56
|
+
[`${TOOL_PREFIX}plan_and_solve`]: "plan_and_solve"
|
|
57
|
+
};
|
|
45
58
|
// --- Logging Helpers ---
|
|
46
59
|
/**
|
|
47
60
|
* Logs an incoming tool call to stderr.
|
|
@@ -280,6 +293,146 @@ async function main() {
|
|
|
280
293
|
try {
|
|
281
294
|
const transport = new StdioServerTransport();
|
|
282
295
|
await server.connect(transport);
|
|
296
|
+
// Register prefixed tool redirects using the original tool definitions
|
|
297
|
+
// Manually register each prefixed version of the tools
|
|
298
|
+
// think
|
|
299
|
+
server.tool(`${TOOL_PREFIX}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.", {
|
|
300
|
+
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.")
|
|
301
|
+
}, async ({ thought }) => {
|
|
302
|
+
// Redirect to the original tool's logic
|
|
303
|
+
const toolName = 'think';
|
|
304
|
+
logToolCall(`${TOOL_PREFIX}${toolName} → ${toolName}`);
|
|
305
|
+
try {
|
|
306
|
+
// Basic Zod validation ensures it's a non-empty string. Content validation removed.
|
|
307
|
+
if (thought.trim().length === 0) {
|
|
308
|
+
throw new Error('Invalid thought: Must be a non-empty string containing substantive reasoning.');
|
|
309
|
+
}
|
|
310
|
+
logToolResult(toolName, true, `Thought logged (length: ${thought.length})`);
|
|
311
|
+
// Log full input for traceability
|
|
312
|
+
console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Input:\n${thought}`);
|
|
313
|
+
// Returns the same thought text received, formatted as Markdown.
|
|
314
|
+
return {
|
|
315
|
+
content: [{
|
|
316
|
+
type: "text",
|
|
317
|
+
text: "```markdown\n" + thought + "\n```"
|
|
318
|
+
}]
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
catch (error) {
|
|
322
|
+
// Use logToolError to format the error for the LLM
|
|
323
|
+
return logToolError(toolName, error);
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
// assess_cuc_n_mode
|
|
327
|
+
server.tool(`${TOOL_PREFIX}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.", {
|
|
328
|
+
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').")
|
|
329
|
+
}, async ({ assessment_and_choice }) => {
|
|
330
|
+
// Redirect to the original tool logic
|
|
331
|
+
const toolName = 'assess_cuc_n_mode';
|
|
332
|
+
logToolCall(`${TOOL_PREFIX}${toolName} → ${toolName}`);
|
|
333
|
+
try {
|
|
334
|
+
// Basic Zod validation ensures it's a string. Content validation removed.
|
|
335
|
+
const modeRegex = /Selected Mode: (think|quick_think)/i;
|
|
336
|
+
const modeMatch = assessment_and_choice.match(modeRegex);
|
|
337
|
+
const selectedMode = modeMatch ? modeMatch[1].toLowerCase() : "unknown"; // Extract mode for logging
|
|
338
|
+
logToolResult(toolName, true, `Selected mode (extracted): ${selectedMode}`);
|
|
339
|
+
// Log full input for traceability
|
|
340
|
+
console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Input:\n${assessment_and_choice}`);
|
|
341
|
+
// Return the full assessment text formatted as Markdown
|
|
342
|
+
return {
|
|
343
|
+
content: [{
|
|
344
|
+
type: "text",
|
|
345
|
+
text: "```markdown\n" + assessment_and_choice + "\n```"
|
|
346
|
+
}]
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
return logToolError(toolName, error);
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
// quick_think
|
|
354
|
+
server.tool(`${TOOL_PREFIX}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.", {
|
|
355
|
+
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.")
|
|
356
|
+
}, async ({ brief_thought }) => {
|
|
357
|
+
const toolName = 'quick_think';
|
|
358
|
+
logToolCall(`${TOOL_PREFIX}${toolName} → ${toolName}`);
|
|
359
|
+
try {
|
|
360
|
+
// Basic Zod validation ensures it's a non-empty string. Content validation removed.
|
|
361
|
+
if (brief_thought.trim().length === 0) {
|
|
362
|
+
throw new Error('Invalid brief_thought: Must be a non-empty string.');
|
|
363
|
+
}
|
|
364
|
+
logToolResult(toolName, true, `Logged: ${brief_thought.substring(0, 80)}...`);
|
|
365
|
+
// Log full input for traceability
|
|
366
|
+
console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Input:\n${brief_thought}`);
|
|
367
|
+
// Return the brief thought text, formatted as Markdown
|
|
368
|
+
return {
|
|
369
|
+
content: [{
|
|
370
|
+
type: "text",
|
|
371
|
+
text: "```markdown\n" + brief_thought + "\n```"
|
|
372
|
+
}]
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
catch (error) {
|
|
376
|
+
return logToolError(toolName, error);
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
// chain_of_thought
|
|
380
|
+
server.tool(`${TOOL_PREFIX}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.", {
|
|
381
|
+
generated_cot_text: z.string().describe("The **full, step-by-step Chain of Thought draft** you generated internally to solve or analyze the problem."),
|
|
382
|
+
problem_statement: z.string().describe("The original problem statement or question this CoT addresses.")
|
|
383
|
+
}, async ({ generated_cot_text, problem_statement }) => {
|
|
384
|
+
const toolName = 'chain_of_thought';
|
|
385
|
+
logToolCall(`${TOOL_PREFIX}${toolName} → ${toolName}`);
|
|
386
|
+
try {
|
|
387
|
+
// Basic Zod validation ensures non-empty strings. Content validation removed.
|
|
388
|
+
if (generated_cot_text.trim().length === 0) {
|
|
389
|
+
throw new Error('Invalid generated_cot_text: Must be a non-empty string containing the CoT.');
|
|
390
|
+
}
|
|
391
|
+
if (problem_statement.trim().length === 0) {
|
|
392
|
+
throw new Error('Invalid problem_statement: Must provide the original problem.');
|
|
393
|
+
}
|
|
394
|
+
logToolResult(toolName, true, `Problem: ${problem_statement.substring(0, 50)}...`);
|
|
395
|
+
// Log full input for traceability
|
|
396
|
+
console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Input:\nProblem: ${problem_statement}\nReasoning:\n${generated_cot_text}`);
|
|
397
|
+
// Return the CoT text, formatted as Markdown
|
|
398
|
+
return {
|
|
399
|
+
content: [{
|
|
400
|
+
type: "text",
|
|
401
|
+
text: "```markdown\n" + generated_cot_text + "\n```"
|
|
402
|
+
}]
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
catch (error) {
|
|
406
|
+
return logToolError(toolName, error);
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
// chain_of_draft
|
|
410
|
+
server.tool(`${TOOL_PREFIX}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.", {
|
|
411
|
+
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').")
|
|
412
|
+
}, async ({ draft_description }) => {
|
|
413
|
+
const toolName = 'chain_of_draft';
|
|
414
|
+
logToolCall(`${TOOL_PREFIX}${toolName} → ${toolName}`);
|
|
415
|
+
try {
|
|
416
|
+
// Basic Zod validation ensures non-empty string. Content validation removed.
|
|
417
|
+
if (draft_description.trim().length === 0) {
|
|
418
|
+
throw new Error('Invalid draft_description: Must provide a description.');
|
|
419
|
+
}
|
|
420
|
+
logToolResult(toolName, true);
|
|
421
|
+
// Log full input for traceability
|
|
422
|
+
console.error(`[${new Date().toISOString()}] [MCP Server] - ${toolName} Input:\nDescription: ${draft_description}`);
|
|
423
|
+
// Return the draft description, formatted as Markdown
|
|
424
|
+
return {
|
|
425
|
+
content: [{
|
|
426
|
+
type: "text",
|
|
427
|
+
text: "```markdown\n" + draft_description + "\n```"
|
|
428
|
+
}]
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
catch (error) {
|
|
432
|
+
return logToolError(toolName, error);
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
console.error(`[MCP Server] Registered compatibility aliases for prefixed tool names`);
|
|
283
436
|
const border = '-----------------------------------------------------';
|
|
284
437
|
console.error(border);
|
|
285
438
|
console.error(` ${serverInfo.description}`);
|
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.21",
|
|
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",
|