@nbiish/cognitive-tools-mcp 0.9.4 → 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/README.md +0 -31
  2. package/build/index.js +10 -7
  3. package/package.json +1 -1
  4. package/integration-prompts/new-prompts/latest.md +0 -134
  5. package/integration-prompts/old-prompts/integration-prompt-01.md +0 -71
  6. package/integration-prompts/old-prompts/integration-prompt-02.md +0 -32
  7. package/integration-prompts/old-prompts/integration-prompt-03.md +0 -71
  8. package/integration-prompts/old-prompts/integration-prompt-04.md +0 -144
  9. package/integration-prompts/old-prompts/integration-prompt-05.md +0 -84
  10. package/integration-prompts/old-prompts/integration-prompt-06.md +0 -91
  11. package/integration-prompts/old-prompts/integration-prompt-07.md +0 -88
  12. package/integration-prompts/old-prompts/integration-prompt-08.md +0 -86
  13. package/integration-prompts/old-prompts/integration-prompt-09.md +0 -86
  14. package/integration-prompts/old-prompts/integration-prompt-10.md +0 -100
  15. package/integration-prompts/old-prompts/integration-prompt-11.md +0 -79
  16. package/integration-prompts/old-prompts/integration-prompt-12.md +0 -93
  17. package/integration-prompts/old-prompts/integration-prompt-13.md +0 -81
  18. package/integration-prompts/old-prompts/integration-prompt-14.md +0 -81
  19. package/integration-prompts/old-prompts/integration-prompt-15.md +0 -80
  20. package/integration-prompts/old-prompts/integration-prompt-16.md +0 -96
  21. package/integration-tool-descriptions/old-descriptions/tool-descriptions-01.ts +0 -171
  22. package/integration-tool-descriptions/old-descriptions/tool-descriptions-02.ts +0 -216
  23. package/integration-tool-descriptions/old-descriptions/tool-descriptions-03.ts +0 -225
  24. package/integration-tool-descriptions/old-descriptions/tool-descriptions-04.ts +0 -221
  25. package/integration-tool-descriptions/old-descriptions/tool-descriptions-05.ts +0 -230
  26. package/integration-tool-descriptions/old-descriptions/tool-descriptions-06.ts +0 -506
  27. package/integration-tool-descriptions/old-descriptions/tool-descriptions-07.ts +0 -293
  28. package/integration-tool-descriptions/old-descriptions/tool-descriptions-08.ts +0 -458
@@ -1,293 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * -----------------------------------------------------------------------------
5
- * Gikendaasowin Aabajichiganan - Core Cognitive Tools MCP Server
6
- *
7
- * Description: Provides the essential suite of cognitive tools for an AI
8
- * Pair Programmer to structure its reasoning, plan actions,
9
- * analyze results, and iteratively refine its work, focusing on
10
- * the internal cognitive loop as described in the corresponding
11
- * integration prompt. External actions are planned within 'think'
12
- * but executed by the environment.
13
- * Protocol: Model Context Protocol (MCP) over stdio.
14
- * -----------------------------------------------------------------------------
15
- */
16
-
17
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
18
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
19
- import { z } from "zod";
20
-
21
- // --- Server Definition ---
22
-
23
- const server = new McpServer({
24
- name: "gikendaasowin-aabajichiganan-mcp",
25
- version: "0.9.2",
26
- description: "ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Core Cognitive Tools Suite: Enables structured, iterative reasoning (Chain of Draft), planning, and analysis for AI Pair Programming, focusing on the cognitive loop."
27
- });
28
-
29
- // --- Logging Helper ---
30
- function logToolCall(toolName: string, details?: string) {
31
- console.error(`[MCP Server] > Tool Call: ${toolName}${details ? ` - ${details}` : ''}`);
32
- }
33
-
34
- function logToolResult(toolName: string, success: boolean, resultDetails?: string) {
35
- console.error(`[MCP Server] < Tool Result: ${toolName} - ${success ? 'Success' : 'Failure'}${resultDetails ? ` - ${resultDetails}` : ''}`);
36
- }
37
-
38
- function logToolError(toolName: string, error: any) {
39
- const errorMessage = error instanceof Error ? error.message : String(error);
40
- console.error(`[MCP Server] ! Tool Error: ${toolName} - ${errorMessage}`);
41
- logToolResult(toolName, false, errorMessage); // Log failure result as well
42
- // Return a structured error message suitable for the LLM
43
- return { content: [{ type: "text" as const, text: `Error in ${toolName}: ${errorMessage}` }] };
44
- }
45
-
46
-
47
- // --- Core Cognitive Deliberation & Refinement Tools ---
48
-
49
- server.tool(
50
- "assess_cuc_n_mode",
51
- "**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.",
52
- {
53
- assessment_and_choice: z.string().describe("Structured assessment including: 1) Situation Description, 2) CUC-N Ratings (L/M/H), 3) Recommended Initial Cognitive Strategy (e.g., 'Start with chain_of_thought'), 4) Explicit Mode Selection ('Selected Mode: think' or 'Selected Mode: quick_think').")
54
- },
55
- async ({ assessment_and_choice }) => {
56
- logToolCall('assess_cuc_n_mode');
57
- try {
58
- // Basic validation for required components
59
- if (!assessment_and_choice.includes("Selected Mode:") || !assessment_and_choice.includes("CUC-N Ratings:") || !assessment_and_choice.includes("Recommended Initial Strategy:")) {
60
- throw new Error('Invalid assessment: String must include CUC-N ratings, Recommended Initial Strategy, and explicit Selected Mode.');
61
- }
62
- const mode = assessment_and_choice.includes("Selected Mode: think") ? "think" : "quick_think";
63
- const resultText = `Cognitive Assessment Completed. Proceeding with selected mode: ${mode}. Full Assessment:\n${assessment_and_choice}`;
64
- logToolResult('assess_cuc_n_mode', true, `Selected mode: ${mode}`);
65
- return { content: [{ type: "text" as const, text: resultText }] };
66
- } catch (error: any) {
67
- return logToolError('assess_cuc_n_mode', error);
68
- }
69
- }
70
- );
71
-
72
- server.tool(
73
- "think",
74
- "**MANDATORY Central Hub for Analysis, Planning, and Refinement.** Called after assessment, cognitive tools, internal drafts, or external action results. Analyzes previous step's outcome/draft, plans immediate next action (cognitive or planning external action), verifies, assesses risk, and self-corrects. Returns the thought text for grounding.",
75
- {
76
- thought: z.string().describe("Your **detailed** internal monologue following the MANDATORY structure: ## Analysis (critically evaluate last result/draft), ## Plan (define *immediate* next action & purpose - cognitive or planning external), ## Verification (how to check next step), ## Anticipated Challenges & Contingency, ## Risk Assessment, ## Lookahead, ## Self-Correction & Learning.")
77
- },
78
- async ({ thought }) => {
79
- logToolCall('think');
80
- try {
81
- if (!thought || typeof thought !== 'string' || thought.trim().length === 0) {
82
- throw new Error('Invalid thought: Must be a non-empty string.');
83
- }
84
- // Basic check for mandatory sections
85
- const requiredSections = ["## Analysis:", "## Plan:", "## Verification:", "## Anticipated Challenges & Contingency:", "## Risk Assessment:", "## Lookahead:", "## Self-Correction & Learning:"];
86
- const missingSections = requiredSections.filter(section => !thought.includes(section));
87
- if (missingSections.length > 0) {
88
- console.warn(`[MCP Server] Warning: 'think' input might be missing sections: ${missingSections.join(', ')}`);
89
- }
90
- logToolResult('think', true, `Thought logged (length: ${thought.length})`);
91
- // Returns the same thought text received.
92
- return { content: [{ type: "text" as const, text: thought }] };
93
- } catch (error: any) {
94
- return logToolError('think', error);
95
- }
96
- }
97
- );
98
-
99
- server.tool(
100
- "quick_think",
101
- "Cognitive Checkpoint ONLY for situations explicitly assessed as strictly Low CUC-N (via assess_cuc_n_mode) or for trivial confirmations where detailed analysis via `think` is unnecessary. Use sparingly.",
102
- {
103
- brief_thought: z.string().describe("Your **concise** thought for strictly simple, low CUC-N situations or brief confirmations.")
104
- },
105
- async ({ brief_thought }) => {
106
- logToolCall('quick_think');
107
- try {
108
- if (!brief_thought || typeof brief_thought !== 'string' || brief_thought.trim().length === 0) {
109
- throw new Error('Invalid brief_thought: Must be non-empty.');
110
- }
111
- logToolResult('quick_think', true, `Logged: ${brief_thought.substring(0, 50)}...`);
112
- return { content: [{ type: "text" as const, text: `Quick Thought logged successfully.` }] };
113
- } catch (error: any) {
114
- return logToolError('quick_think', error);
115
- }
116
- }
117
- );
118
-
119
- server.tool(
120
- "gauge_confidence",
121
- "Meta-Cognitive Checkpoint. Guides internal stating of **confidence (High/Medium/Low) and justification** regarding a plan, analysis, or draft. Output MUST be analyzed in the mandatory `think` step immediately after.",
122
- {
123
- assessment_and_confidence: z.string().describe("Input item being assessed. *Internally determine and state*: 1) Confidence Level (H/M/L). 2) Justification. Call this tool *after* making the assessment.")
124
- },
125
- async ({ assessment_and_confidence }) => {
126
- logToolCall('gauge_confidence');
127
- try {
128
- const confidenceRegex = /Confidence Level: (High|Medium|Low)/i;
129
- if (!assessment_and_confidence || typeof assessment_and_confidence !== 'string' || !confidenceRegex.test(assessment_and_confidence)) {
130
- throw new Error('Invalid confidence assessment: String must include "Confidence Level: High/Medium/Low" and justification.');
131
- }
132
- const match = assessment_and_confidence.match(confidenceRegex);
133
- const level = match ? match[1] : "Unknown";
134
- const resultText = `Confidence Gauge Completed. Level: ${level}. Assessment Text: ${assessment_and_confidence}. Ready for mandatory post-assessment 'think' analysis (action required if Low/Medium).`;
135
- logToolResult('gauge_confidence', true, `Level: ${level}`);
136
- return { content: [{ type: "text" as const, text: resultText }] };
137
- } catch (error: any) {
138
- return logToolError('gauge_confidence', error);
139
- }
140
- }
141
- );
142
-
143
- server.tool(
144
- "plan_and_solve",
145
- "Guides internal generation of a **structured plan draft**. Call this tool *with* the generated plan text. Returns the plan text for mandatory `think` analysis to critically evaluate feasibility, refine, and confirm the first action step.",
146
- {
147
- generated_plan_text: z.string().describe("The **full, structured plan draft** you generated internally, including goals, steps, potential external tool needs, and risks."),
148
- task_objective: z.string().describe("The original high-level task objective this plan addresses.")
149
- },
150
- async ({ generated_plan_text, task_objective }) => {
151
- logToolCall('plan_and_solve', `Objective: ${task_objective.substring(0, 50)}...`);
152
- try {
153
- if (!generated_plan_text || typeof generated_plan_text !== 'string' || generated_plan_text.trim().length === 0) { throw new Error('Invalid generated_plan_text: Must be non-empty.'); }
154
- if (!task_objective || typeof task_objective !== 'string' || task_objective.trim().length === 0) { throw new Error('Invalid task_objective.'); }
155
- logToolResult('plan_and_solve', true, `Returned plan draft (length: ${generated_plan_text.length})`);
156
- // Returns the actual plan text received for analysis.
157
- return { content: [{ type: "text" as const, text: generated_plan_text }] };
158
- } catch (error: any) {
159
- return logToolError('plan_and_solve', error);
160
- }
161
- }
162
- );
163
-
164
- server.tool(
165
- "chain_of_thought",
166
- "Guides internal generation of **detailed, step-by-step reasoning draft (CoT)**. Call this tool *with* the generated CoT text. Returns the CoT text for mandatory `think` analysis to extract insights, identify flaws/gaps, and plan the next concrete action.",
167
- {
168
- generated_cot_text: z.string().describe("The **full, step-by-step Chain of Thought draft** you generated internally."),
169
- problem_statement: z.string().describe("The original problem statement this CoT addresses.")
170
- },
171
- async ({ generated_cot_text, problem_statement }) => {
172
- logToolCall('chain_of_thought', `Problem: ${problem_statement.substring(0, 50)}...`);
173
- try {
174
- if (!generated_cot_text || typeof generated_cot_text !== 'string' || generated_cot_text.trim().length === 0) { throw new Error('Invalid generated_cot_text: Must be non-empty.'); }
175
- if (!problem_statement || typeof problem_statement !== 'string' || problem_statement.trim().length === 0) { throw new Error('Invalid problem_statement.'); }
176
- logToolResult('chain_of_thought', true, `Returned CoT draft (length: ${generated_cot_text.length})`);
177
- // Returns the actual CoT text received for analysis.
178
- return { content: [{ type: "text" as const, text: generated_cot_text }] };
179
- } catch (error: any) {
180
- return logToolError('chain_of_thought', error);
181
- }
182
- }
183
- );
184
-
185
- server.tool(
186
- "chain_of_draft",
187
- "Signals that one or more **internal drafts** (code, text, plan fragments) have been generated or refined and are ready for analysis. Call this tool *after* generating/refining draft(s) internally. Response confirms readiness; drafts MUST be analyzed via mandatory `think`.",
188
- {
189
- draft_description: z.string().describe("Brief description of the draft(s) generated/refined internally (e.g., 'Initial code snippet for function X', 'Refined plan section 3').")
190
- },
191
- async ({ draft_description }) => {
192
- logToolCall('chain_of_draft', `Description: ${draft_description}`);
193
- try {
194
- if (!draft_description || typeof draft_description !== 'string' || draft_description.trim().length === 0) { throw new Error('Invalid draft_description.'); }
195
- const resultText = `Internal draft(s) ready for analysis: ${draft_description}. MANDATORY: Analyze these draft(s) now in your next 'think' step.`;
196
- logToolResult('chain_of_draft', true);
197
- return { content: [{ type: "text" as const, text: resultText }] };
198
- } catch (error: any) {
199
- return logToolError('chain_of_draft', error);
200
- }
201
- }
202
- );
203
-
204
- server.tool(
205
- "reflection",
206
- "Guides internal critical self-evaluation on a prior step, draft, or outcome. Call this tool *with* the **generated critique text**. Returns the critique text for mandatory `think` analysis to plan specific corrective actions or refinements.",
207
- {
208
- generated_critique_text: z.string().describe("The **full critique text** you generated internally, identifying flaws, strengths, and suggesting improvements."),
209
- input_subject_description: z.string().describe("A brief description of the original reasoning, plan, code draft, or action result that was critiqued.")
210
- },
211
- async ({ generated_critique_text, input_subject_description }) => {
212
- logToolCall('reflection', `Subject: ${input_subject_description}`);
213
- try {
214
- if (!generated_critique_text || typeof generated_critique_text !== 'string' || generated_critique_text.trim().length === 0) { throw new Error('Invalid generated_critique_text: Must be non-empty.'); }
215
- if (!input_subject_description || typeof input_subject_description !== 'string' || input_subject_description.trim().length === 0) { throw new Error('Invalid input_subject_description.'); }
216
- logToolResult('reflection', true, `Returned critique (length: ${generated_critique_text.length})`);
217
- // Returns the actual critique text received for analysis.
218
- return { content: [{ type: "text" as const, text: generated_critique_text }] };
219
- } catch (error: any) {
220
- return logToolError('reflection', error);
221
- }
222
- }
223
- );
224
-
225
- server.tool(
226
- "synthesize_prior_reasoning",
227
- "Context Management Tool. Guides internal generation of a **structured summary** of preceding steps, decisions, or context. Call this tool *with* the generated summary text. Returns the summary for mandatory `think` analysis to consolidate understanding and inform next steps.",
228
- {
229
- generated_summary_text: z.string().describe("The **full, structured summary text** you generated internally (e.g., key decisions, open questions, current state)."),
230
- context_to_summarize_description: z.string().describe("Description of the reasoning span or context that was summarized.")
231
- },
232
- async ({ generated_summary_text, context_to_summarize_description }) => {
233
- logToolCall('synthesize_prior_reasoning', `Context: ${context_to_summarize_description}`);
234
- try {
235
- if (!generated_summary_text || typeof generated_summary_text !== 'string' || generated_summary_text.trim().length === 0) { throw new Error('Invalid generated_summary_text: Must be non-empty.'); }
236
- if (!context_to_summarize_description || typeof context_to_summarize_description !== 'string' || context_to_summarize_description.trim().length === 0) { throw new Error('Invalid context_to_summarize_description.'); }
237
- logToolResult('synthesize_prior_reasoning', true, `Returned summary (length: ${generated_summary_text.length})`);
238
- // Returns the actual summary text received for analysis.
239
- return { content: [{ type: "text" as const, text: generated_summary_text }] };
240
- } catch (error: any) {
241
- return logToolError('synthesize_prior_reasoning', error);
242
- }
243
- }
244
- );
245
-
246
-
247
- // --- Server Lifecycle and Error Handling ---
248
-
249
- process.on('SIGINT', async () => {
250
- console.error('\n[MCP Server] Received SIGINT, shutting down gracefully.');
251
- await server.close();
252
- process.exit(0);
253
- });
254
-
255
- process.on('SIGTERM', async () => {
256
- console.error('\n[MCP Server] Received SIGTERM, shutting down gracefully.');
257
- await server.close();
258
- process.exit(0);
259
- });
260
-
261
- process.on('uncaughtException', (error, origin) => {
262
- console.error(`[MCP Server] FATAL: Uncaught Exception at: ${origin}`, error);
263
- server.close().catch(err => console.error('[MCP Server] Error during shutdown on uncaughtException:', err)).finally(() => {
264
- process.exit(1);
265
- });
266
- });
267
-
268
- process.on('unhandledRejection', (reason, promise) => {
269
- console.error('[MCP Server] FATAL: Unhandled Promise Rejection:', reason);
270
- server.close().catch(err => console.error('[MCP Server] Error during shutdown on unhandledRejection:', err)).finally(() => {
271
- process.exit(1);
272
- });
273
- });
274
-
275
- // --- Start the Server ---
276
-
277
- async function main() {
278
- try {
279
- const transport = new StdioServerTransport();
280
- await server.connect(transport);
281
- console.error('-----------------------------------------------------');
282
- console.error(' ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Core Cognitive Tools MCP Server');
283
- console.error(' Status: Running on stdio');
284
- console.error('-----------------------------------------------------');
285
- }
286
- catch (error) {
287
- console.error('[MCP Server] Fatal error during startup:', error);
288
- process.exit(1);
289
- }
290
- }
291
-
292
- // Execute the main function to start the server
293
- main();