@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,221 +0,0 @@
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 - Version 0.8.0 reflects the change in tool signatures and return values
7
- const server = new McpServer({
8
- name: "gikendaasowin-aabajichiganan-mcp",
9
- version: "0.8.0", // Updated version
10
- description: "ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Gikendaasowin Aabajichiganan - (Cognitive Tools v0.8.0): SOTA reasoning suite aligned with AI Pair Programmer Prompt v0.8.0+. Enforces mandatory structured deliberation via `think` after explicit assessment. Returns generated cognitive content (thoughts, plans, CoT, critiques, summaries) for explicit analysis, optimizing for cognitive enhancement."
11
- });
12
-
13
- // --- Core Cognitive Deliberation Tools ---
14
-
15
- server.tool(
16
- "think",
17
- // Main Description: Central hub, now returns the thought for explicit context.
18
- "MANDATORY Cognitive Hub for Medium/High CUC-N situations. Analyzes inputs/prior steps, plans, verifies, assesses risks, self-corrects. Returns the detailed thought text for explicit grounding in the next step.",
19
- {
20
- // Parameter Description: Input IS the thought.
21
- thought: z.string().describe("Your **detailed** internal monologue following the MANDATORY structure: ## Analysis, ## Plan, ## Verification, ## Anticipated Challenges Analysis & Contingency, ## Risk Assessment, ## Lookahead, ## Self-Correction & Learning.")
22
- },
23
- async ({ thought }) => {
24
- if (!thought || typeof thought !== 'string' || thought.trim().length === 0) { throw new Error('Invalid thought: Must be non-empty, structured reasoning.'); }
25
- console.error(`[CognitiveToolsServer v0.8.0] Think Tool Received: ${thought.substring(0, 150)}...`);
26
- // Returns the same thought text received, making it explicit in context.
27
- return { content: [{ type: "text" as const, text: thought }] };
28
- }
29
- );
30
-
31
- server.tool(
32
- "quick_think",
33
- // Main Description: Unchanged - simple confirmation is sufficient here.
34
- "Cognitive Checkpoint ONLY for situations explicitly assessed as strictly Low CUC-N AND simple task nature. Use sparingly. Logs brief thought.",
35
- {
36
- brief_thought: z.string().describe("Your **concise** thought for strictly simple, low CUC-N situations confirmed by prior assessment.")
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 v0.8.0] QuickThink Tool Logged: ${brief_thought.substring(0, 100)}...`);
41
- // Simple confirmation remains appropriate for quick_think.
42
- return { content: [{ type: "text" as const, text: `Quick Thought logged successfully.` }] };
43
- }
44
- );
45
-
46
- // --- Mandatory Meta-Cognitive Tools (Responses remain concise confirmations) ---
47
-
48
- server.tool(
49
- "assess_complexity_and_select_thought_mode",
50
- // Main Description: Unchanged.
51
- "**Mandatory Pre-Deliberation Assessment.** Must be called BEFORE every `think` or `quick_think`. Evaluates CUC-N, recommends strategy, commits to next thought mode.",
52
- {
53
- // Parameter Description: Unchanged.
54
- assessment_and_choice: z.string().describe("Input your assessment *before* calling. MUST include: 1) Situation Description, 2) CUC-N Ratings (L/M/H), 3) Recommended Initial Strategy, 4) Explicit Mode Selection ('Selected Mode: think' or 'Selected Mode: quick_think').")
55
- },
56
- async ({ assessment_and_choice }) => {
57
- const requiredPhrases = ["Complexity", "Uncertainty", "Consequence", "Novelty", "Recommended Initial Strategy", "Selected Mode:"];
58
- const hasRequiredPhrases = requiredPhrases.every(phrase => assessment_and_choice.includes(phrase));
59
- const hasModeSelection = assessment_and_choice.includes("Selected Mode: think") || assessment_and_choice.includes("Selected Mode: quick_think");
60
- if (!assessment_and_choice || typeof assessment_and_choice !== 'string' || !hasRequiredPhrases || !hasModeSelection) { throw new Error('Invalid assessment: String must include CUC-N ratings, Recommended Initial Strategy, and explicit Selected Mode ("think" or "quick_think").'); }
61
- console.error(`[CognitiveToolsServer v0.8.0] AssessComplexity Tool Signaled: ${assessment_and_choice.substring(0, 150)}...`);
62
- const mode = assessment_and_choice.includes("Selected Mode: think") ? "think" : "quick_think";
63
- // Confirmation guides the next step.
64
- return { content: [{ type: "text" as const, text: `Cognitive Assessment Completed. Proceeding with selected mode: ${mode}. Full Assessment: ${assessment_and_choice}` }] };
65
- }
66
- );
67
-
68
- server.tool(
69
- "gauge_confidence",
70
- // Main Description: Unchanged.
71
- "Meta-Cognitive Checkpoint. Guides internal stating of **confidence (High/Medium/Low) and justification**. Output MUST be analyzed in the mandatory `think` step immediately after; Low/Medium confidence requires specific action planning.",
72
- {
73
- // Parameter Description: Unchanged.
74
- 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.")
75
- },
76
- async ({ assessment_and_confidence }) => {
77
- const confidenceRegex = /Confidence Level: (High|Medium|Low)/i;
78
- if (!assessment_and_confidence || typeof assessment_and_confidence !== 'string' || !confidenceRegex.test(assessment_and_confidence)) { throw new Error('Invalid confidence assessment: String must include "Confidence Level: High/Medium/Low" and justification.'); }
79
- const match = assessment_and_confidence.match(confidenceRegex);
80
- const level = match ? match[1] : "Unknown";
81
- console.error(`[CognitiveToolsServer v0.8.0] GaugeConfidence Tool Signaled: Level ${level}`);
82
- // Confirmation includes level, prepares for mandatory analysis.
83
- return { content: [{ type: "text" as const, text: `Confidence Gauge Completed. Level: ${level}. Assessment Text: ${assessment_and_confidence}. Ready for mandatory post-assessment 'think' analysis (action required if Low/Medium).` }] };
84
- }
85
- );
86
-
87
-
88
- // --- Supporting Cognitive Strategy Tools (Now Accept & Return Generated Text) ---
89
-
90
- server.tool(
91
- "plan_and_solve",
92
- // Main Description: Now returns the plan text itself.
93
- "Guides internal generation of **structured plan text** (incl. Risks/Challenges, potential tool needs). Call this tool *with* the generated plan text. Returns the plan text for mandatory `think` analysis.",
94
- {
95
- // NEW Parameter: Accepts the generated plan.
96
- generated_plan_text: z.string().describe("The **full, structured plan text** you generated internally, including Anticipated Challenges/Risks and potential other tool needs."),
97
- task_objective: z.string().describe("The original high-level task objective this plan addresses.") // Keep original objective for context logging.
98
- },
99
- async ({ generated_plan_text, task_objective }) => {
100
- 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.'); }
101
- if (!task_objective || typeof task_objective !== 'string' || task_objective.trim().length === 0) { throw new Error('Invalid task_objective.'); }
102
- console.error(`[CognitiveToolsServer v0.8.0] PlanAndSolve Tool Received Plan for Objective: ${task_objective.substring(0, 100)}...`);
103
- // Returns the actual plan text received.
104
- return { content: [{ type: "text" as const, text: generated_plan_text }] };
105
- }
106
- );
107
-
108
- server.tool(
109
- "chain_of_thought",
110
- // Main Description: Now returns the CoT text itself.
111
- "Guides internal generation of **detailed, step-by-step reasoning text (CoT)**. Call this tool *with* the generated CoT text. Returns the CoT text for mandatory `think` analysis.",
112
- {
113
- // NEW Parameter: Accepts the generated CoT.
114
- generated_cot_text: z.string().describe("The **full, step-by-step Chain of Thought text** you generated internally, potentially noting needs for other tools."),
115
- problem_statement: z.string().describe("The original problem statement this CoT addresses.") // Keep original problem statement for context logging.
116
- },
117
- async ({ generated_cot_text, problem_statement }) => {
118
- 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.'); }
119
- if (!problem_statement || typeof problem_statement !== 'string' || problem_statement.trim().length === 0) { throw new Error('Invalid problem_statement.'); }
120
- console.error(`[CognitiveToolsServer v0.8.0] ChainOfThought Tool Received CoT for Problem: ${problem_statement.substring(0, 100)}...`);
121
- // Returns the actual CoT text received.
122
- return { content: [{ type: "text" as const, text: generated_cot_text }] };
123
- }
124
- );
125
-
126
- server.tool(
127
- "chain_of_draft",
128
- // Main Description: Keeping as signal due to complexity of multiple drafts. Response reinforces next step.
129
- "Guides internal generation of **concise, iterative reasoning draft texts**. Call this tool *after* generating drafts internally. Response confirms generation; drafts MUST be analyzed via mandatory `think`.",
130
- {
131
- // Parameter: Still just the problem statement. LLM handles drafts internally.
132
- problem_statement: z.string().describe("Input problem for exploration. *You* (LLM) must now *internally generate brief, iterative draft texts*. Call this tool *after* generation to signal readiness for analysis.")
133
- },
134
- async ({ problem_statement }) => {
135
- if (!problem_statement || typeof problem_statement !== 'string' || problem_statement.trim().length === 0) { throw new Error('Invalid problem statement.'); }
136
- console.error(`[CognitiveToolsServer v0.8.0] ChainOfDraft Tool Signaled for: ${problem_statement.substring(0, 100)}...`);
137
- // Returns confirmation, strongly reminding LLM of the mandatory next step.
138
- return { content: [{ type: "text" as const, text: `Reasoning drafts generated internally for problem: ${problem_statement}. MANDATORY: Analyze these drafts now in your next post-assessment 'think' step.` }] };
139
- }
140
- );
141
-
142
- server.tool(
143
- "reflection",
144
- // Main Description: Now returns the critique text itself.
145
- "Guides internal critical self-evaluation on prior text. Call this tool *with* the **generated critique text**. Returns the critique text for mandatory `think` analysis.",
146
- {
147
- // NEW Parameter: Accepts the generated critique.
148
- generated_critique_text: z.string().describe("The **full critique text** you generated internally, identifying flaws and suggesting improvements."),
149
- input_reasoning_or_plan: z.string().describe("The original text that was critiqued.") // Keep original text for context logging.
150
- },
151
- async ({ generated_critique_text, input_reasoning_or_plan }) => {
152
- 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.'); }
153
- if (!input_reasoning_or_plan || typeof input_reasoning_or_plan !== 'string' || input_reasoning_or_plan.trim().length === 0) { throw new Error('Invalid input_reasoning_or_plan.'); }
154
- console.error(`[CognitiveToolsServer v0.8.0] Reflection Tool Received Critique for: ${input_reasoning_or_plan.substring(0, 100)}...`);
155
- // Returns the actual critique text received.
156
- return { content: [{ type: "text" as const, text: generated_critique_text }] };
157
- }
158
- );
159
-
160
- server.tool(
161
- "synthesize_prior_reasoning",
162
- // Main Description: Now returns the summary text itself.
163
- "Context Management Tool. Guides internal generation of a **structured summary text** (incl. Key Decisions, Open Questions). Call this tool *with* the generated summary text. Returns the summary for mandatory `think` analysis.",
164
- {
165
- // NEW Parameter: Accepts the generated summary.
166
- generated_summary_text: z.string().describe("The **full, structured summary text** you generated internally."),
167
- context_to_summarize_description: z.string().describe("Description of the reasoning span that was summarized.") // Keep description for context logging.
168
- },
169
- async ({ generated_summary_text, context_to_summarize_description }) => {
170
- 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.'); }
171
- 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.'); }
172
- console.error(`[CognitiveToolsServer v0.8.0] SynthesizeReasoning Tool Received Summary for: ${context_to_summarize_description}...`);
173
- // Returns the actual summary text received.
174
- return { content: [{ type: "text" as const, text: generated_summary_text }] };
175
- }
176
- );
177
-
178
-
179
- // --- Server Lifecycle and Error Handling (Unchanged) ---
180
-
181
- process.on('SIGINT', async () => {
182
- console.error('\n[CognitiveToolsServer v0.8.0] Received SIGINT, shutting down gracefully.');
183
- await server.close();
184
- process.exit(0);
185
- });
186
-
187
- process.on('SIGTERM', async () => {
188
- console.error('\n[CognitiveToolsServer v0.8.0] Received SIGTERM, shutting down gracefully.');
189
- await server.close();
190
- process.exit(0);
191
- });
192
-
193
- process.on('uncaughtException', (error) => {
194
- console.error('[CognitiveToolsServer v0.8.0] FATAL: Uncaught Exception:', error);
195
- server.close().catch(err => console.error('[CognitiveToolsServer v0.8.0] Error during shutdown on uncaughtException:', err)).finally(() => {
196
- process.exit(1);
197
- });
198
- });
199
-
200
- process.on('unhandledRejection', (reason, promise) => {
201
- console.error('[CognitiveToolsServer v0.8.0] FATAL: Unhandled Promise Rejection:', reason);
202
- server.close().catch(err => console.error('[CognitiveToolsServer v0.8.0] Error during shutdown on unhandledRejection:', err)).finally(() => {
203
- process.exit(1);
204
- });
205
- });
206
-
207
- // Start the server
208
- async function main() {
209
- try {
210
- const transport = new StdioServerTransport();
211
- await server.connect(transport);
212
- console.error('ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Gikendaasowin Aabajichiganan - (Cognitive Tools v0.8.0) MCP Server running on stdio');
213
- }
214
- catch (error) {
215
- console.error('[CognitiveToolsServer v0.8.0] Fatal error during startup:', error);
216
- process.exit(1);
217
- }
218
- }
219
-
220
- // Execute the main function to start the server
221
- main();
@@ -1,230 +0,0 @@
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 - Version aligned with prompt
7
- const server = new McpServer({
8
- name: "gikendaasowin-aabajichiganan-mcp",
9
- version: "0.8.1", // Updated version to match prompt
10
- description: "ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Gikendaasowin Aabajichiganan - (Cognitive Tools v0.8.1): SOTA reasoning suite aligned with AI Pair Programmer Prompt v0.8.1+. Enforces structured deliberation via `think` after explicit assessment or action results. Returns generated cognitive content (thoughts, plans, CoT, critiques, summaries) for explicit analysis and action planning, optimizing for cognitive enhancement and effective tool integration."
11
- });
12
-
13
- // --- Core Cognitive Deliberation Tools ---
14
-
15
- server.tool(
16
- "think",
17
- // Main Description: Central hub, returns thought for explicit context and action planning.
18
- "MANDATORY Cognitive Hub for planning, analysis (incl. prior action/tool results), verification, risk assessment, and self-correction. Called after assessment, complex cognitive tools, or external tool execution. Returns the detailed thought text for explicit grounding and to define the immediate next action.",
19
- {
20
- // Parameter Description: Input IS the thought.
21
- thought: z.string().describe("Your **detailed** internal monologue following the MANDATORY structure: ## Analysis (incl. results of last action/tool call), ## Plan (defining immediate next action, incl. external tools), ## Verification, ## Anticipated Challenges Analysis & Contingency, ## Risk Assessment, ## Lookahead, ## Self-Correction & Learning.")
22
- },
23
- async ({ thought }) => {
24
- if (!thought || typeof thought !== 'string' || thought.trim().length === 0) { throw new Error('Invalid thought: Must be non-empty, structured reasoning.'); }
25
- // Ensure mandatory sections are mentioned (basic check)
26
- const requiredSections = ["## Analysis:", "## Plan:", "## Verification:", "## Anticipated Challenges Analysis & Contingency:", "## Risk Assessment:", "## Lookahead:", "## Self-Correction & Learning:"];
27
- // Simple check for presence; more robust parsing could be added if needed
28
- const hasRequiredSections = requiredSections.every(section => thought.includes(section));
29
- if (!hasRequiredSections) {
30
- console.warn(`[CognitiveToolsServer v0.8.1] Warning: 'think' input might be missing some mandatory sections.`);
31
- // Decide whether to throw error or just warn. Warning allows flexibility.
32
- // throw new Error('Invalid thought: Missing one or more mandatory sections (## Analysis:, ## Plan:, etc.).');
33
- }
34
- console.error(`[CognitiveToolsServer v0.8.1] Think Tool Received: ${thought.substring(0, 150)}...`);
35
- // Returns the same thought text received, making it explicit in context.
36
- return { content: [{ type: "text" as const, text: thought }] };
37
- }
38
- );
39
-
40
- server.tool(
41
- "quick_think",
42
- // Main Description: Unchanged.
43
- "Cognitive Checkpoint ONLY for situations explicitly assessed as strictly Low CUC-N AND simple task nature/confirmation. Use sparingly. Logs brief thought.",
44
- {
45
- brief_thought: z.string().describe("Your **concise** thought for strictly simple, low CUC-N situations confirmed by prior assessment or for brief confirmations.")
46
- },
47
- async ({ brief_thought }) => {
48
- if (!brief_thought || typeof brief_thought !== 'string' || brief_thought.trim().length === 0) { throw new Error('Invalid brief_thought: Must be non-empty.'); }
49
- console.error(`[CognitiveToolsServer v0.8.1] QuickThink Tool Logged: ${brief_thought.substring(0, 100)}...`);
50
- // Simple confirmation remains appropriate for quick_think.
51
- return { content: [{ type: "text" as const, text: `Quick Thought logged successfully.` }] };
52
- }
53
- );
54
-
55
- // --- Mandatory Meta-Cognitive Tools ---
56
-
57
- server.tool(
58
- "assess_complexity_and_select_thought_mode", // Renamed for clarity from assess_cuc_n_mode
59
- // Main Description: Updated name, emphasizes role.
60
- "**Mandatory Pre-Deliberation/Pre-Sequence Assessment.** Must be called BEFORE initiating significant cognitive processes (`think`) or complex action sequences. Evaluates CUC-N, recommends strategy, commits to next thought mode.",
61
- {
62
- // Parameter Description: Unchanged.
63
- assessment_and_choice: z.string().describe("Input your assessment *before* calling. MUST include: 1) Situation Description, 2) CUC-N Ratings (L/M/H), 3) Recommended Initial Strategy, 4) Explicit Mode Selection ('Selected Mode: think' or 'Selected Mode: quick_think').")
64
- },
65
- async ({ assessment_and_choice }) => {
66
- const requiredPhrases = ["Complexity", "Uncertainty", "Consequence", "Novelty", "Recommended Initial Strategy", "Selected Mode:"];
67
- const hasRequiredPhrases = requiredPhrases.every(phrase => assessment_and_choice.includes(phrase));
68
- const hasModeSelection = assessment_and_choice.includes("Selected Mode: think") || assessment_and_choice.includes("Selected Mode: quick_think");
69
- if (!assessment_and_choice || typeof assessment_and_choice !== 'string' || !hasRequiredPhrases || !hasModeSelection) { throw new Error('Invalid assessment: String must include CUC-N ratings, Recommended Initial Strategy, and explicit Selected Mode ("think" or "quick_think").'); }
70
- console.error(`[CognitiveToolsServer v0.8.1] AssessComplexity Tool Signaled: ${assessment_and_choice.substring(0, 150)}...`);
71
- const mode = assessment_and_choice.includes("Selected Mode: think") ? "think" : "quick_think";
72
- // Confirmation guides the next step.
73
- return { content: [{ type: "text" as const, text: `Cognitive Assessment Completed. Proceeding with selected mode: ${mode}. Full Assessment: ${assessment_and_choice}` }] };
74
- }
75
- );
76
-
77
- server.tool(
78
- "gauge_confidence",
79
- // Main Description: Emphasizes mandatory analysis.
80
- "Meta-Cognitive Checkpoint. Guides internal stating of **confidence (High/Medium/Low) and justification**. Output MUST be analyzed in the mandatory `think` step immediately after; Low/Medium confidence requires specific action planning.",
81
- {
82
- // Parameter Description: Unchanged.
83
- 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.")
84
- },
85
- async ({ assessment_and_confidence }) => {
86
- const confidenceRegex = /Confidence Level: (High|Medium|Low)/i;
87
- if (!assessment_and_confidence || typeof assessment_and_confidence !== 'string' || !confidenceRegex.test(assessment_and_confidence)) { throw new Error('Invalid confidence assessment: String must include "Confidence Level: High/Medium/Low" and justification.'); }
88
- const match = assessment_and_confidence.match(confidenceRegex);
89
- const level = match ? match[1] : "Unknown";
90
- console.error(`[CognitiveToolsServer v0.8.1] GaugeConfidence Tool Signaled: Level ${level}`);
91
- // Confirmation includes level, prepares for mandatory analysis.
92
- return { content: [{ type: "text" as const, text: `Confidence Gauge Completed. Level: ${level}. Assessment Text: ${assessment_and_confidence}. Ready for mandatory post-assessment 'think' analysis (action required if Low/Medium).` }] };
93
- }
94
- );
95
-
96
-
97
- // --- Supporting Cognitive Strategy Tools (Accept & Return Generated Text for Analysis) ---
98
-
99
- server.tool(
100
- "plan_and_solve",
101
- // Main Description: Returns plan text for analysis and action planning.
102
- "Guides internal generation of **structured plan text** (incl. Risks/Challenges, potential tool needs). Call this tool *with* the generated plan text. Returns the plan text for mandatory `think` analysis to confirm/refine the immediate next step.",
103
- {
104
- // Parameter: Accepts the generated plan.
105
- generated_plan_text: z.string().describe("The **full, structured plan text** you generated internally, including Anticipated Challenges/Risks and potential other tool needs."),
106
- task_objective: z.string().describe("The original high-level task objective this plan addresses.")
107
- },
108
- async ({ generated_plan_text, task_objective }) => {
109
- 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.'); }
110
- if (!task_objective || typeof task_objective !== 'string' || task_objective.trim().length === 0) { throw new Error('Invalid task_objective.'); }
111
- console.error(`[CognitiveToolsServer v0.8.1] PlanAndSolve Tool Received Plan for Objective: ${task_objective.substring(0, 100)}...`);
112
- // Returns the actual plan text received for analysis.
113
- return { content: [{ type: "text" as const, text: generated_plan_text }] };
114
- }
115
- );
116
-
117
- server.tool(
118
- "chain_of_thought",
119
- // Main Description: Returns CoT text for analysis and action planning.
120
- "Guides internal generation of **detailed, step-by-step reasoning text (CoT)**. Call this tool *with* the generated CoT text. Returns the CoT text for mandatory `think` analysis to extract insights and plan the next action.",
121
- {
122
- // Parameter: Accepts the generated CoT.
123
- generated_cot_text: z.string().describe("The **full, step-by-step Chain of Thought text** you generated internally, potentially noting needs for other tools."),
124
- problem_statement: z.string().describe("The original problem statement this CoT addresses.")
125
- },
126
- async ({ generated_cot_text, problem_statement }) => {
127
- 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.'); }
128
- if (!problem_statement || typeof problem_statement !== 'string' || problem_statement.trim().length === 0) { throw new Error('Invalid problem_statement.'); }
129
- console.error(`[CognitiveToolsServer v0.8.1] ChainOfThought Tool Received CoT for Problem: ${problem_statement.substring(0, 100)}...`);
130
- // Returns the actual CoT text received for analysis.
131
- return { content: [{ type: "text" as const, text: generated_cot_text }] };
132
- }
133
- );
134
-
135
- server.tool(
136
- "chain_of_draft",
137
- // Main Description: Signal only, reinforces mandatory analysis.
138
- "Guides internal generation of **concise, iterative reasoning draft texts**. Call this tool *after* generating drafts internally. Response confirms generation; drafts MUST be analyzed via mandatory `think`.",
139
- {
140
- // Parameter: Still just the problem statement. LLM handles drafts internally.
141
- problem_statement: z.string().describe("Input problem for exploration. *You* (LLM) must now *internally generate brief, iterative draft texts*. Call this tool *after* generation to signal readiness for analysis.")
142
- },
143
- async ({ problem_statement }) => {
144
- if (!problem_statement || typeof problem_statement !== 'string' || problem_statement.trim().length === 0) { throw new Error('Invalid problem statement.'); }
145
- console.error(`[CognitiveToolsServer v0.8.1] ChainOfDraft Tool Signaled for: ${problem_statement.substring(0, 100)}...`);
146
- // Returns confirmation, strongly reminding LLM of the mandatory next step.
147
- return { content: [{ type: "text" as const, text: `Reasoning drafts generated internally for problem: ${problem_statement}. MANDATORY: Analyze these drafts now in your next 'think' step.` }] };
148
- }
149
- );
150
-
151
- server.tool(
152
- "reflection",
153
- // Main Description: Returns critique text for analysis and action planning.
154
- "Guides internal critical self-evaluation on prior text. Call this tool *with* the **generated critique text**. Returns the critique text for mandatory `think` analysis to plan corrective actions.",
155
- {
156
- // Parameter: Accepts the generated critique.
157
- generated_critique_text: z.string().describe("The **full critique text** you generated internally, identifying flaws and suggesting improvements."),
158
- input_reasoning_or_plan: z.string().describe("The original text that was critiqued.")
159
- },
160
- async ({ generated_critique_text, input_reasoning_or_plan }) => {
161
- 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.'); }
162
- if (!input_reasoning_or_plan || typeof input_reasoning_or_plan !== 'string' || input_reasoning_or_plan.trim().length === 0) { throw new Error('Invalid input_reasoning_or_plan.'); }
163
- console.error(`[CognitiveToolsServer v0.8.1] Reflection Tool Received Critique for: ${input_reasoning_or_plan.substring(0, 100)}...`);
164
- // Returns the actual critique text received for analysis.
165
- return { content: [{ type: "text" as const, text: generated_critique_text }] };
166
- }
167
- );
168
-
169
- server.tool(
170
- "synthesize_prior_reasoning",
171
- // Main Description: Returns summary text for analysis and action planning.
172
- "Context Management Tool. Guides internal generation of a **structured summary text** (incl. Key Decisions, Open Questions). Call this tool *with* the generated summary text. Returns the summary for mandatory `think` analysis to inform the next steps.",
173
- {
174
- // Parameter: Accepts the generated summary.
175
- generated_summary_text: z.string().describe("The **full, structured summary text** you generated internally."),
176
- context_to_summarize_description: z.string().describe("Description of the reasoning span that was summarized.")
177
- },
178
- async ({ generated_summary_text, context_to_summarize_description }) => {
179
- 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.'); }
180
- 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.'); }
181
- console.error(`[CognitiveToolsServer v0.8.1] SynthesizeReasoning Tool Received Summary for: ${context_to_summarize_description}...`);
182
- // Returns the actual summary text received for analysis.
183
- return { content: [{ type: "text" as const, text: generated_summary_text }] };
184
- }
185
- );
186
-
187
-
188
- // --- Server Lifecycle and Error Handling (Unchanged) ---
189
-
190
- process.on('SIGINT', async () => {
191
- console.error('\n[CognitiveToolsServer v0.8.1] Received SIGINT, shutting down gracefully.');
192
- await server.close();
193
- process.exit(0);
194
- });
195
-
196
- process.on('SIGTERM', async () => {
197
- console.error('\n[CognitiveToolsServer v0.8.1] Received SIGTERM, shutting down gracefully.');
198
- await server.close();
199
- process.exit(0);
200
- });
201
-
202
- process.on('uncaughtException', (error) => {
203
- console.error('[CognitiveToolsServer v0.8.1] FATAL: Uncaught Exception:', error);
204
- server.close().catch(err => console.error('[CognitiveToolsServer v0.8.1] Error during shutdown on uncaughtException:', err)).finally(() => {
205
- process.exit(1);
206
- });
207
- });
208
-
209
- process.on('unhandledRejection', (reason, promise) => {
210
- console.error('[CognitiveToolsServer v0.8.1] FATAL: Unhandled Promise Rejection:', reason);
211
- server.close().catch(err => console.error('[CognitiveToolsServer v0.8.1] Error during shutdown on unhandledRejection:', err)).finally(() => {
212
- process.exit(1);
213
- });
214
- });
215
-
216
- // Start the server
217
- async function main() {
218
- try {
219
- const transport = new StdioServerTransport();
220
- await server.connect(transport);
221
- console.error('ᑭᑫᓐᑖᓱᐎᓐ ᐋᐸᒋᒋᑲᓇᓐ - Gikendaasowin Aabajichiganan - (Cognitive Tools v0.8.1) MCP Server running on stdio');
222
- }
223
- catch (error) {
224
- console.error('[CognitiveToolsServer v0.8.1] Fatal error during startup:', error);
225
- process.exit(1);
226
- }
227
- }
228
-
229
- // Execute the main function to start the server
230
- main();