deepthinking-mcp 8.2.1 → 9.1.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.
Files changed (4) hide show
  1. package/README.md +1038 -899
  2. package/dist/index.js +41286 -29738
  3. package/dist/index.js.map +1 -1
  4. package/package.json +6 -2
package/README.md CHANGED
@@ -1,899 +1,1038 @@
1
- # DeepThinking MCP
2
-
3
- [![TypeScript](https://img.shields.io/badge/TypeScript-100%25-blue.svg)](https://www.typescriptlang.org/)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
- [![MCP Compatible](https://img.shields.io/badge/MCP-Compatible-green.svg)](https://modelcontextprotocol.io)
6
-
7
- A comprehensive Model Context Protocol (MCP) server featuring **33 reasoning modes** (29 with dedicated thought types, 4 advanced runtime modes) including meta-reasoning for strategic oversight, with intelligent mode recommendation, taxonomy-based classification, enterprise security, and production-ready features for complex problem-solving, analysis, and decision-making.
8
-
9
- > 📋 **Latest Release**: v7.5.0 - See [CHANGELOG](CHANGELOG.md) for updates and improvements.
10
- >
11
- > 🎉 **New in v7.5.0**: Phase 14 Accessible Reasoning Modes! All 29 modes with dedicated thought types are now accessible via MCP tools. 2 new tools: `deepthinking_engineering` and `deepthinking_academic`. Total: 12 focused tools.
12
- >
13
- > ✨ **v7.4.0**: Phase 13 Academic Research Modes for PhD students! Synthesis (literature review), Argumentation (Toulmin model), Critique (peer review), and Analysis (qualitative methods) modes.
14
- >
15
- > ✨ **v7.3.0**: Phase 12 Algorithmic Reasoning Mode with comprehensive CLRS coverage! 100+ named algorithms, complexity analysis, design patterns.
16
- >
17
- > ✨ **v7.2.0**: Phase 11 Historical Computing Extensions! Computability mode (Turing machines), Cryptanalytic mode (deciban evidence system), extended Game Theory (von Neumann).
18
-
19
- ## Table of Contents
20
-
21
- - [Features](#features)
22
- - [Installation](#installation)
23
- - [Quick Start](#quick-start)
24
- - [Reasoning Modes](#reasoning-modes)
25
- - [Proof Decomposition](#proof-decomposition)
26
- - [Usage Examples](#usage-examples)
27
- - [Production Features](#production-features)
28
- - [API Documentation](#api-documentation)
29
- - [Contributing](#contributing)
30
- - [License](#license)
31
-
32
- ## Features
33
-
34
- - **33 Specialized Reasoning Modes** - From sequential thinking to game theory, formal logic, and meta-reasoning (29 with full thought types, 4 advanced runtime modes)
35
- - **Academic Research Modes (NEW!)** - Synthesis (literature review), Argumentation (Toulmin), Critique (peer review), Analysis (qualitative methods)
36
- - **Algorithmic Reasoning (v7.3.0)** - Comprehensive CLRS coverage with 100+ named algorithms, complexity analysis, design patterns
37
- - **Historical Computing Extensions** - Computability (Turing machines), Cryptanalytic (decibans), extended Game Theory (von Neumann)
38
- - **Proof Decomposition** - Break proofs into atomic statements, detect gaps, track assumption chains
39
- - **Native SVG Export** - Direct SVG generation without external tools for proof visualizations
40
- - **Meta-Reasoning** - Strategic oversight that monitors effectiveness, recommends mode switches, and assesses quality
41
- - **Adaptive Mode Switching** - Automatic evaluation-based mode switching when effectiveness drops below thresholds
42
- - **Intelligent Mode Recommendation** - Automatic mode selection based on problem characteristics
43
- - **Taxonomy Classifier** - 69 reasoning types across 12 categories for intelligent task classification (110 planned)
44
- - **Visual Exports** - Generate Mermaid diagrams, DOT graphs, ASCII art, SVG graphics, and LaTeX documents
45
- - **Production-Ready** - Search engine, templates, batch processing, caching, backup/restore
46
- - **Enterprise Security** - Input validation (Zod), rate limiting, path sanitization, PII redaction
47
- - **High Performance** - LRU caching with auto-eviction, async I/O, 4-5x validation speedups
48
- - **Type-Safe** - 100% TypeScript with zero suppressions (down from 231 baseline)
49
- - **Repository Pattern** - Clean architecture with dependency injection
50
- - **Extensible** - Plugin architecture for custom reasoning modes
51
- - **MCP Compatible** - Full integration with Model Context Protocol
52
-
53
- ## Installation
54
-
55
- ### NPM Package
56
-
57
- ```bash
58
- npm install deepthinking-mcp
59
- ```
60
-
61
- ### From Source
62
-
63
- ```bash
64
- git clone https://github.com/danielsimonjr/deepthinking-mcp.git
65
- cd deepthinking-mcp
66
- npm install
67
- npm run build
68
- ```
69
-
70
- ### MCP Configuration
71
-
72
- Add to your MCP settings file:
73
-
74
- ```json
75
- {
76
- "mcpServers": {
77
- "deepthinking": {
78
- "command": "npx",
79
- "args": ["deepthinking-mcp"]
80
- }
81
- }
82
- }
83
- ```
84
-
85
- ## Quick Start
86
-
87
- ### MCP Tool Usage
88
-
89
- DeepThinking MCP provides 12 focused tools for different reasoning domains:
90
-
91
- | Tool | Modes | Description |
92
- |------|-------|-------------|
93
- | `deepthinking_core` | inductive, deductive, abductive | Fundamental reasoning |
94
- | `deepthinking_standard` | sequential, shannon, hybrid | Standard workflow modes |
95
- | `deepthinking_mathematics` | mathematics, physics, computability | Math/physics/computability |
96
- | `deepthinking_temporal` | temporal | Time-based reasoning |
97
- | `deepthinking_probabilistic` | bayesian, evidential | Probabilistic reasoning |
98
- | `deepthinking_causal` | causal, counterfactual | Cause-effect analysis |
99
- | `deepthinking_strategic` | gametheory, optimization | Strategic reasoning |
100
- | `deepthinking_analytical` | analogical, firstprinciples, metareasoning, cryptanalytic | Analytical reasoning |
101
- | `deepthinking_scientific` | scientificmethod, systemsthinking, formallogic | Scientific reasoning |
102
- | `deepthinking_engineering` | engineering, algorithmic | Engineering/algorithmic |
103
- | `deepthinking_academic` | synthesis, argumentation, critique, analysis | Academic research |
104
- | `deepthinking_session` | - | Session management |
105
-
106
- ### Example: Sequential Reasoning
107
-
108
- ```json
109
- {
110
- "tool": "deepthinking_standard",
111
- "arguments": {
112
- "mode": "sequential",
113
- "thought": "First, identify the main bottlenecks in the distributed system",
114
- "thoughtNumber": 1,
115
- "totalThoughts": 5,
116
- "nextThoughtNeeded": true
117
- }
118
- }
119
- ```
120
-
121
- ### Example: Causal Analysis
122
-
123
- ```json
124
- {
125
- "tool": "deepthinking_causal",
126
- "arguments": {
127
- "mode": "causal",
128
- "thought": "Analyzing the root cause of the service outage",
129
- "thoughtNumber": 1,
130
- "totalThoughts": 3,
131
- "nextThoughtNeeded": true,
132
- "causalGraph": {
133
- "nodes": [
134
- {"id": "n1", "name": "High Load", "type": "cause"},
135
- {"id": "n2", "name": "Memory Exhaustion", "type": "mediator"},
136
- {"id": "n3", "name": "Service Crash", "type": "effect"}
137
- ],
138
- "edges": [
139
- {"from": "n1", "to": "n2", "strength": 0.9},
140
- {"from": "n2", "to": "n3", "strength": 0.95}
141
- ]
142
- }
143
- }
144
- }
145
- ```
146
-
147
- ### Example: Session Export
148
-
149
- ```json
150
- {
151
- "tool": "deepthinking_session",
152
- "arguments": {
153
- "action": "export",
154
- "sessionId": "session-123",
155
- "exportFormat": "markdown"
156
- }
157
- }
158
- ```
159
-
160
- ## Reasoning Modes
161
-
162
- The server supports 33 reasoning modes organized into categories:
163
-
164
- - **Core Modes (5)**: Sequential, Shannon, Mathematics, Physics, Hybrid
165
- - **Historical Computing (2)**: Computability (Turing), Cryptanalytic (Turing) - *v7.2.0*
166
- - **Algorithmic (1)**: Algorithmic (CLRS) - *v7.3.0*
167
- - **Academic Research (4)**: Synthesis, Argumentation, Critique, Analysis - *v7.4.0*
168
- - **Advanced Runtime Modes (6)**: Metareasoning, Recursive, Modal, Stochastic, Constraint, Optimization
169
- - **Fundamental Modes (3)**: Inductive, Deductive, Abductive
170
- - **Experimental Modes (12)**: Causal, Bayesian, Counterfactual, Analogical, Temporal, Game Theory (+ von Neumann extensions), Evidential, First Principles, Systems Thinking, Scientific Method, Formal Logic, Engineering
171
-
172
- ### Core Modes
173
-
174
- #### Sequential
175
- Iterative refinement with revision capabilities. Perfect for step-by-step problem solving.
176
-
177
- ```typescript
178
- mode: 'sequential'
179
- // Use for: Debugging, algorithmic thinking, systematic analysis
180
- ```
181
-
182
- #### Shannon
183
- 5-stage systematic problem-solving methodology (problem → constraints → model → proof → implementation).
184
-
185
- ```typescript
186
- mode: 'shannon'
187
- // Use for: Engineering problems, system design, complex optimizations
188
- ```
189
-
190
- #### Mathematics
191
- Theorem proving, lemma derivation, symbolic computation with LaTeX support.
192
-
193
- ```typescript
194
- mode: 'mathematics'
195
- // Use for: Proofs, mathematical modeling, symbolic algebra
196
- ```
197
-
198
- #### Physics
199
- Tensor mathematics, dimensional analysis, conservation laws, field theory.
200
-
201
- ```typescript
202
- mode: 'physics'
203
- // Use for: Physical modeling, dimensional analysis, scientific computing
204
- ```
205
-
206
- #### Hybrid
207
- Intelligently combines multiple reasoning modes based on problem characteristics.
208
-
209
- ```typescript
210
- mode: 'hybrid'
211
- // Use for: Complex multi-faceted problems requiring diverse approaches
212
- ```
213
-
214
- ### Advanced Modes
215
-
216
- #### Causal
217
- Build causal graphs, analyze interventions and effects.
218
-
219
- ```typescript
220
- mode: 'causal'
221
- // Use for: Impact analysis, system design, decision making
222
- ```
223
-
224
- #### Bayesian
225
- Probabilistic reasoning with priors, likelihoods, and evidence updates.
226
-
227
- ```typescript
228
- mode: 'bayesian'
229
- // Use for: Risk assessment, A/B testing, uncertainty quantification
230
- ```
231
-
232
- #### Counterfactual
233
- Explore alternative scenarios and compare outcomes.
234
-
235
- ```typescript
236
- mode: 'counterfactual'
237
- // Use for: Post-mortems, strategic planning, what-if analysis
238
- ```
239
-
240
- #### Analogical
241
- Transfer knowledge across domains by identifying structural similarities.
242
-
243
- ```typescript
244
- mode: 'analogical'
245
- // Use for: Design patterns, innovative problem-solving, knowledge transfer
246
- ```
247
-
248
- ### Specialized Modes
249
-
250
- #### Temporal
251
- Model events, intervals, and temporal relationships using Allen's interval algebra.
252
-
253
- ```typescript
254
- mode: 'temporal'
255
- // Use for: Timeline analysis, scheduling, event sequencing
256
- ```
257
-
258
- #### Game Theory
259
- Analyze strategic interactions, compute Nash equilibria, build game trees.
260
-
261
- ```typescript
262
- mode: 'game-theory'
263
- // Use for: Competitive analysis, mechanism design, strategic decisions
264
- ```
265
-
266
- #### Evidential
267
- Dempster-Shafer theory for reasoning with uncertain evidence.
268
-
269
- ```typescript
270
- mode: 'evidential'
271
- // Use for: Sensor fusion, intelligence analysis, incomplete information
272
- ```
273
-
274
- #### First Principles
275
- Derive conclusions from foundational axioms using deductive reasoning.
276
-
277
- ```typescript
278
- mode: 'first-principles'
279
- // Use for: Fundamental analysis, conceptual understanding, basic truths
280
- ```
281
-
282
- #### Meta-Reasoning
283
- Strategic oversight of reasoning process - monitors effectiveness, recommends mode switches, assesses quality.
284
-
285
- ```typescript
286
- mode: 'metareasoning'
287
- // Use for: Strategy evaluation, adaptive mode switching, quality assessment
288
- // Metrics: Effectiveness, Efficiency, Confidence, Quality (6 dimensions)
289
- // Auto-switches at effectiveness < 0.3
290
- ```
291
-
292
- See [full documentation](docs/modes/METAREASONING.md) for detailed usage.
293
-
294
- #### Systems Thinking
295
- Holistic analysis of complex systems, feedback loops, and emergence.
296
-
297
- ```typescript
298
- mode: 'systems-thinking'
299
- // Use for: Complex systems, organizational design, ecosystem analysis
300
- ```
301
-
302
- #### Scientific Method
303
- Hypothesis-driven experimentation with research design and statistical analysis.
304
-
305
- ```typescript
306
- mode: 'scientific-method'
307
- // Use for: Experimental design, hypothesis testing, research
308
- ```
309
-
310
- #### Optimization
311
- Constraint satisfaction and optimization with decision variables.
312
-
313
- ```typescript
314
- mode: 'optimization'
315
- // Use for: Resource allocation, scheduling, constrained optimization
316
- ```
317
-
318
- #### Formal Logic
319
- Rigorous logical reasoning with formal systems and proof verification.
320
-
321
- ```typescript
322
- mode: 'formal-logic'
323
- // Use for: Proof verification, logical analysis, formal methods
324
- ```
325
-
326
- ### Advanced Runtime Modes
327
-
328
- #### Recursive
329
- Recursive problem decomposition - break complex problems into smaller subproblems.
330
-
331
- ```typescript
332
- mode: 'recursive'
333
- // Use for: Divide-and-conquer, tree-structured problems, recursive algorithms
334
- ```
335
-
336
- #### Modal
337
- Possibility and necessity reasoning using modal logic.
338
-
339
- ```typescript
340
- mode: 'modal'
341
- // Use for: What's possible vs necessary, requirement analysis, constraint exploration
342
- ```
343
-
344
- #### Stochastic
345
- Probabilistic state transitions and Markov chain reasoning.
346
-
347
- ```typescript
348
- mode: 'stochastic'
349
- // Use for: Process modeling, state machines, probabilistic sequences
350
- ```
351
-
352
- #### Constraint
353
- Constraint satisfaction problem solving.
354
-
355
- ```typescript
356
- mode: 'constraint'
357
- // Use for: Scheduling, resource allocation, constraint propagation
358
- ```
359
-
360
- ### Fundamental Modes
361
-
362
- #### Inductive
363
- Reasoning from specific observations to general principles.
364
-
365
- ```typescript
366
- mode: 'inductive'
367
- // Use for: Pattern recognition, generalization, empirical reasoning
368
- ```
369
-
370
- #### Deductive
371
- Reasoning from general principles to specific conclusions.
372
-
373
- ```typescript
374
- mode: 'deductive'
375
- // Use for: Logical proofs, applying rules, deriving conclusions
376
- ```
377
-
378
- #### Abductive
379
- Generate and evaluate hypotheses to explain observations.
380
-
381
- ```typescript
382
- mode: 'abductive'
383
- // Use for: Debugging, root cause analysis, diagnostic reasoning
384
- ```
385
-
386
- ### Historical Computing Modes (v7.2.0)
387
-
388
- Tributes to Alan Turing and John von Neumann's foundational work.
389
-
390
- #### Computability
391
- Turing machines, decidability proofs, reductions, and diagonalization arguments.
392
-
393
- ```typescript
394
- mode: 'computability'
395
- // Use for: Decidability analysis, algorithm limits, computational complexity
396
- // Features: Turing machine simulation, reduction chains, halting problem analysis
397
- ```
398
-
399
- #### Cryptanalytic
400
- Turing's deciban evidence system from Bletchley Park.
401
-
402
- ```typescript
403
- mode: 'cryptanalytic'
404
- // Use for: Evidence quantification, hypothesis testing, code-breaking analysis
405
- // Features: Deciban accumulation (10 db ≈ 10:1 odds), frequency analysis, Banburismus
406
- ```
407
-
408
- #### Extended Game Theory (v7.2.0)
409
- Von Neumann's minimax theorem, cooperative games, and Shapley values.
410
-
411
- ```typescript
412
- mode: 'gametheory'
413
- // Enhanced with: Minimax analysis, cooperative game theory, coalition analysis
414
- // Use for: Zero-sum games, fair value distribution, strategic decision-making
415
- ```
416
-
417
- ### Algorithmic Mode (v7.3.0)
418
-
419
- #### Algorithmic
420
- Comprehensive coverage of algorithms from "Introduction to Algorithms" (CLRS) with 100+ named algorithms.
421
-
422
- ```typescript
423
- mode: 'algorithmic'
424
- // Use for: Algorithm design, complexity analysis, correctness proofs
425
- // Features: Divide-and-conquer, dynamic programming, greedy, graph algorithms
426
- // Coverage: Sorting, searching, graph, string, computational geometry
427
- ```
428
-
429
- ### Academic Research Modes (v7.4.0)
430
-
431
- Designed for PhD students and scientific paper writing.
432
-
433
- #### Synthesis
434
- Literature review and knowledge integration.
435
-
436
- ```typescript
437
- mode: 'synthesis'
438
- // Use for: Literature reviews, theme extraction, knowledge integration
439
- // Features: Source synthesis, pattern identification, gap analysis
440
- ```
441
-
442
- #### Argumentation
443
- Academic argumentation using the Toulmin model.
444
-
445
- ```typescript
446
- mode: 'argumentation'
447
- // Use for: Building arguments, dialectical reasoning, rhetorical analysis
448
- // Features: Toulmin model (claim, data, warrant, backing), counter-arguments
449
- ```
450
-
451
- #### Critique
452
- Critical analysis and peer review frameworks.
453
-
454
- ```typescript
455
- mode: 'critique'
456
- // Use for: Peer review, methodology evaluation, evidence assessment
457
- // Features: Systematic critique, strengths/weaknesses analysis
458
- ```
459
-
460
- #### Analysis
461
- Qualitative analysis methods.
462
-
463
- ```typescript
464
- mode: 'analysis'
465
- // Use for: Thematic analysis, grounded theory, discourse analysis
466
- // Features: Multiple qualitative analysis frameworks, coding support
467
- ```
468
-
469
- ## Proof Decomposition
470
-
471
- **New in v7.0.0!** The proof decomposition system provides advanced mathematical reasoning capabilities:
472
-
473
- ### Components
474
-
475
- | Component | Purpose |
476
- |-----------|---------|
477
- | **ProofDecomposer** | Breaks proofs into atomic statements with dependency tracking |
478
- | **GapAnalyzer** | Detects missing steps, unjustified leaps, and implicit assumptions |
479
- | **AssumptionTracker** | Traces conclusions back to their supporting assumptions |
480
- | **InconsistencyDetector** | Detects circular dependencies and contradictions |
481
- | **MathematicsReasoningEngine** | Integrated proof analysis with improvement suggestions |
482
-
483
- ### Features
484
-
485
- - **Atomic Statement Types**: axiom, hypothesis, definition, derived, lemma, conclusion
486
- - **Inference Rules**: algebraic_manipulation, substitution, modus_ponens, universal_instantiation, etc.
487
- - **Gap Detection**: Identify missing steps with severity levels (minor, significant, critical)
488
- - **Rigor Levels**: informal, textbook, rigorous, formal
489
- - **Visual Export**: Mermaid, DOT, ASCII, and native SVG formats
490
-
491
- ### Example: Proof Analysis
492
-
493
- ```json
494
- {
495
- "tool": "deepthinking_mathematics",
496
- "arguments": {
497
- "mode": "mathematics",
498
- "thought": "Analyzing the proof that n² is even when n is even",
499
- "thoughtNumber": 1,
500
- "totalThoughts": 3,
501
- "nextThoughtNeeded": true,
502
- "proofDecomposition": {
503
- "theorem": "If n is even, then n² is even",
504
- "atoms": [
505
- {"id": "a1", "content": "n is an even integer", "type": "hypothesis"},
506
- {"id": "a2", "content": "n = 2k for some integer k", "type": "definition"},
507
- {"id": "a3", "content": "n² = 4k² = 2(2k²)", "type": "derived"},
508
- {"id": "a4", "content": "n² is even", "type": "conclusion"}
509
- ],
510
- "dependencies": {
511
- "nodes": ["a1", "a2", "a3", "a4"],
512
- "edges": [
513
- {"from": "a1", "to": "a2"},
514
- {"from": "a2", "to": "a3"},
515
- {"from": "a3", "to": "a4"}
516
- ]
517
- }
518
- }
519
- }
520
- }
521
- ```
522
-
523
- ### Visual Export Formats
524
-
525
- Export proof decompositions to multiple visual formats:
526
-
527
- ```typescript
528
- // Native SVG (no external tools required)
529
- exportProofDecomposition(decomposition, {
530
- format: 'svg',
531
- colorScheme: 'default', // 'default' | 'pastel' | 'monochrome'
532
- includeMetrics: true,
533
- svgWidth: 1200,
534
- svgHeight: 800
535
- });
536
-
537
- // Mermaid diagram
538
- exportProofDecomposition(decomposition, { format: 'mermaid' });
539
-
540
- // GraphViz DOT
541
- exportProofDecomposition(decomposition, { format: 'dot' });
542
-
543
- // ASCII text
544
- exportProofDecomposition(decomposition, { format: 'ascii' });
545
- ```
546
-
547
- ## Usage Examples
548
-
549
- ### Example 1: Debugging with Abductive Reasoning
550
-
551
- ```json
552
- // Step 1: Start with observation
553
- {
554
- "tool": "deepthinking_core",
555
- "arguments": {
556
- "mode": "abductive",
557
- "thought": "Observed: Users report intermittent 500 errors on checkout during high traffic periods",
558
- "thoughtNumber": 1,
559
- "totalThoughts": 4,
560
- "nextThoughtNeeded": true,
561
- "observations": ["Errors occur during high traffic", "Checkout page affected", "Intermittent pattern"]
562
- }
563
- }
564
-
565
- // Step 2: Generate hypothesis
566
- {
567
- "tool": "deepthinking_core",
568
- "arguments": {
569
- "sessionId": "session-from-step-1",
570
- "mode": "abductive",
571
- "thought": "Hypothesis: Database connection pool exhaustion under load",
572
- "thoughtNumber": 2,
573
- "totalThoughts": 4,
574
- "nextThoughtNeeded": true,
575
- "hypotheses": [{
576
- "id": "h1",
577
- "explanation": "Connection pool exhausted",
578
- "assumptions": ["Fixed pool size", "No connection recycling"],
579
- "predictions": ["Errors correlate with traffic spikes"],
580
- "score": 0.8
581
- }]
582
- }
583
- }
584
- ```
585
-
586
- ### Example 2: Impact Analysis with Causal Reasoning
587
-
588
- ```json
589
- {
590
- "tool": "deepthinking_causal",
591
- "arguments": {
592
- "mode": "causal",
593
- "thought": "Analyzing impact of increasing API rate limits on system behavior",
594
- "thoughtNumber": 1,
595
- "totalThoughts": 3,
596
- "nextThoughtNeeded": true,
597
- "causalGraph": {
598
- "nodes": [
599
- {"id": "rate_limit", "name": "Rate Limit", "type": "cause", "description": "API rate limit setting"},
600
- {"id": "server_load", "name": "Server Load", "type": "mediator", "description": "CPU/Memory usage"},
601
- {"id": "response_time", "name": "Response Time", "type": "effect", "description": "API latency"},
602
- {"id": "satisfaction", "name": "User Satisfaction", "type": "effect", "description": "User experience"}
603
- ],
604
- "edges": [
605
- {"from": "rate_limit", "to": "server_load", "strength": 0.9, "confidence": 0.85},
606
- {"from": "server_load", "to": "response_time", "strength": 0.85, "confidence": 0.9},
607
- {"from": "response_time", "to": "satisfaction", "strength": -0.7, "confidence": 0.8}
608
- ]
609
- }
610
- }
611
- }
612
- ```
613
-
614
- ### Example 3: Strategic Analysis with Game Theory
615
-
616
- ```json
617
- {
618
- "tool": "deepthinking_strategic",
619
- "arguments": {
620
- "mode": "gametheory",
621
- "thought": "Analyzing pricing strategy in competitive market using game theory",
622
- "thoughtNumber": 1,
623
- "totalThoughts": 3,
624
- "nextThoughtNeeded": true,
625
- "game": {
626
- "type": "strategic",
627
- "players": ["Company A", "Company B"],
628
- "strategies": {
629
- "Company A": ["premium", "competitive", "discount"],
630
- "Company B": ["premium", "competitive", "discount"]
631
- },
632
- "payoffMatrix": [
633
- [{"A": 10, "B": 10}, {"A": 5, "B": 15}, {"A": 2, "B": 12}],
634
- [{"A": 15, "B": 5}, {"A": 8, "B": 8}, {"A": 4, "B": 10}],
635
- [{"A": 12, "B": 2}, {"A": 10, "B": 4}, {"A": 6, "B": 6}]
636
- ]
637
- }
638
- }
639
- }
640
- ```
641
-
642
- ## Production Features
643
-
644
- > **Note**: DeepThinking MCP is an MCP server, not a library. These features are accessed through MCP tools and internal architecture. The examples below describe the internal capabilities.
645
-
646
- ### Proof Decomposition (v7.0.0)
647
-
648
- Advanced mathematical reasoning with proof analysis:
649
-
650
- - **ProofDecomposer**: Break proofs into atomic statements with dependency graphs
651
- - **GapAnalyzer**: Detect missing steps, unjustified leaps, implicit assumptions
652
- - **AssumptionTracker**: Trace conclusions to their supporting assumptions
653
- - **InconsistencyDetector**: Find circular dependencies and contradictions
654
- - **Native SVG Export**: Generate proof visualizations without external tools
655
-
656
- ### Search Engine
657
-
658
- Full-text search with faceted filtering and relevance ranking. Used internally to search across reasoning sessions by mode, tags, date ranges, and content.
659
-
660
- ### Template System
661
-
662
- Pre-built templates for common reasoning patterns, accessible through session creation.
663
-
664
- ### Batch Processing
665
-
666
- Process multiple sessions concurrently with 8 operation types:
667
-
668
- - **export** - Batch export sessions to various formats
669
- - **import** - Batch import sessions from files
670
- - **analyze** - Batch taxonomy/quality/pattern analysis
671
- - **validate** - Batch session validation
672
- - **transform** - Batch mode switching, merging, splitting
673
- - **index** - Batch search/analytics indexing
674
- - **backup** - Batch backup with compression
675
- - **cleanup** - Batch cleanup of old/incomplete sessions
676
-
677
- ### Backup & Restore
678
-
679
- Automated backup with compression and local storage, with support for multiple providers (Local, S3, GCS, Azure).
680
-
681
- ### Session Comparison
682
-
683
- Compare reasoning sessions to analyze differences and similarities with quantitative metrics.
684
-
685
- ### Security & Validation
686
-
687
- Enterprise-grade security features built into the MCP server:
688
-
689
- - **Input Validation** - Zod schemas validate all 33 mode inputs
690
- - **Rate Limiting** - Sliding window rate limiter for API protection
691
- - **Path Sanitization** - Prevents directory traversal attacks
692
- - **PII Redaction** - GDPR-compliant log sanitization
693
-
694
- ### Taxonomy Classifier
695
-
696
- Intelligent classification of reasoning tasks using 69 reasoning types across 12 categories. Use the `recommend_mode` action in `deepthinking_session` to get mode recommendations based on problem characteristics.
697
-
698
- ## API Documentation
699
-
700
- ### MCP Tool Interface
701
-
702
- All reasoning is done through MCP tools. Each tool accepts arguments and returns JSON responses.
703
-
704
- #### Common Parameters (all thinking tools)
705
-
706
- | Parameter | Type | Required | Description |
707
- |-----------|------|----------|-------------|
708
- | `sessionId` | string | No | Session ID (auto-created if omitted) |
709
- | `thought` | string | Yes | The reasoning content |
710
- | `thoughtNumber` | integer | Yes | Current thought number (1-based) |
711
- | `totalThoughts` | integer | Yes | Estimated total thoughts |
712
- | `nextThoughtNeeded` | boolean | Yes | Whether more reasoning needed |
713
- | `mode` | string | Yes | The reasoning mode |
714
-
715
- #### Session Actions (`deepthinking_session`)
716
-
717
- | Action | Parameters | Description |
718
- |--------|------------|-------------|
719
- | `summarize` | `sessionId` | Generate session summary |
720
- | `export` | `sessionId`, `exportFormat` | Export to format (json, markdown, latex, html, jupyter, mermaid, dot, ascii, svg) |
721
- | `get_session` | `sessionId` | Get session details |
722
- | `switch_mode` | `sessionId`, `newMode` | Switch reasoning mode |
723
- | `recommend_mode` | `problemType` or `problemCharacteristics` | Get mode recommendations |
724
-
725
- #### Example Response
726
-
727
- ```json
728
- {
729
- "sessionId": "session-abc123",
730
- "thoughtId": "thought-xyz789",
731
- "thoughtNumber": 1,
732
- "mode": "sequential",
733
- "nextThoughtNeeded": true,
734
- "sessionComplete": false,
735
- "totalThoughts": 3
736
- }
737
- ```
738
-
739
- For architecture details, see [docs/architecture/](docs/architecture/).
740
-
741
- ## Project Stats
742
-
743
- | Metric | Value |
744
- |--------|-------|
745
- | TypeScript Files | 183 |
746
- | Lines of Code | ~62,000 |
747
- | Test Files | 40 |
748
- | Passing Tests | 792+ |
749
- | Thinking Modes | 33 (29 with thought types) |
750
- | MCP Tools | 10 focused + 1 legacy |
751
- | Export Formats | 11 (including native SVG) |
752
- | Visual Formats | 11 (mermaid, dot, ascii, svg, etc.) |
753
- | Reasoning Types | 69 (110 planned) |
754
- | Modules | 16 |
755
- | Total Exports | 970 |
756
-
757
- ## Architecture
758
-
759
- The codebase is organized into 16 modules with clean separation of concerns. See [docs/architecture/DEPENDENCY_GRAPH.md](docs/architecture/DEPENDENCY_GRAPH.md) for the complete dependency graph.
760
-
761
- ### Core Structure
762
-
763
- ```
764
- src/
765
- ├── index.ts # MCP server entry point (tool handlers)
766
- ├── types/ # Type definitions including 33 mode types
767
- │ ├── core.ts # ThinkingMode enum, Thought union type
768
- │ └── modes/ # One file per reasoning mode (23 files)
769
- ├── services/ # Business logic layer
770
- │ ├── ThoughtFactory.ts # Thought creation and validation
771
- │ ├── ExportService.ts # Multi-format export handling
772
- │ └── ModeRouter.ts # Mode switching and recommendations
773
- ├── session/ # SessionManager, persistence, storage
774
- ├── modes/ # Advanced reasoning implementations (7 files)
775
- ├── proof/ # Proof decomposition system (v7.0.0)
776
- │ ├── decomposer.ts # ProofDecomposer class
777
- │ ├── gap-analyzer.ts # GapAnalyzer class
778
- │ └── assumption-tracker.ts # AssumptionTracker class
779
- ├── reasoning/ # Reasoning engines (v7.0.0)
780
- │ └── inconsistency-detector.ts # InconsistencyDetector class
781
- └── tools/ # MCP tool definitions and schemas
782
- ```
783
-
784
- ### Feature Modules
785
-
786
- ```
787
- src/
788
- ├── taxonomy/ # 69 reasoning types, classifier, suggestion engine
789
- │ ├── reasoning-types.ts # Full taxonomy definitions
790
- │ ├── classifier.ts # Task classification
791
- │ └── suggestion-engine.ts # Mode recommendations
792
- ├── export/ # Visual and document exporters
793
- │ ├── visual/ # 21 mode-specific visual exporters + native SVG
794
- │ │ ├── proof-decomposition.ts # Proof visualization (v7.0.0)
795
- │ │ └── [19 mode exporters] # Mermaid, DOT, ASCII, SVG
796
- │ └── latex.ts # LaTeX document generation
797
- ├── search/ # Full-text search with faceted filtering
798
- ├── batch/ # Batch processing (8 operations)
799
- ├── backup/ # Backup manager with provider abstraction
800
- ├── cache/ # LRU/LFU/FIFO caching strategies
801
- ├── rate-limit/ # Sliding window rate limiter
802
- ├── validation/ # Zod schemas (25+ mode validators)
803
- ├── comparison/ # Session comparison & diff generation
804
- ├── templates/ # Session templates with usage tracking
805
- ├── analytics/ # Analytics engine and dashboard
806
- ├── webhooks/ # Event-driven webhook system
807
- ├── collaboration/ # Annotations and conflict resolution
808
- └── ml/ # Pattern recognition & recommendations
809
- ```
810
-
811
- ### Security Features
812
-
813
- Security is built into multiple modules:
814
-
815
- - **validation/** - Input validation with Zod schemas for all 33 modes
816
- - **utils/sanitization.ts** - Path sanitization & traversal prevention
817
- - **utils/log-sanitizer.ts** - PII redaction for GDPR compliance
818
- - **rate-limit/** - Per-key rate limiting with sliding windows
819
- - **utils/errors.ts** - Standardized error hierarchy with context
820
-
821
- ## Contributing
822
-
823
- We welcome contributions! Please open an issue or pull request on [GitHub](https://github.com/danielsimonjr/deepthinking-mcp).
824
-
825
- ### Adding New Reasoning Modes
826
-
827
- Want to add a new reasoning mode? We've made it easy:
828
-
829
- 📖 **[Complete Guide: Adding a New Mode](docs/ADDING_NEW_MODE.md)**
830
-
831
- This guide includes:
832
- - Step-by-step instructions for all 8 required files
833
- - Template files in `templates/mode-scaffolding/`
834
- - Code examples and common patterns
835
- - Complete checklist to ensure nothing is missed
836
- - Testing guidelines
837
-
838
- **Quick Start**:
839
- ```bash
840
- # Copy template files
841
- cp templates/mode-scaffolding/example-mode.type.ts src/types/modes/yourmode.ts
842
- cp templates/mode-scaffolding/example-mode.validator.ts src/validation/validators/modes/yourmode.ts
843
-
844
- # Follow the guide
845
- cat docs/ADDING_NEW_MODE.md
846
- ```
847
-
848
- ### Development Setup
849
-
850
- ```bash
851
- # Clone repository
852
- git clone https://github.com/danielsimonjr/deepthinking-mcp.git
853
- cd deepthinking-mcp
854
-
855
- # Install dependencies
856
- npm install
857
-
858
- # Run tests
859
- npm test
860
-
861
- # Run type checking
862
- npm run typecheck
863
-
864
- # Build
865
- npm run build
866
- ```
867
-
868
- ### Running Tests
869
-
870
- ```bash
871
- # Run all tests
872
- npm test
873
-
874
- # Run specific test file
875
- npm test -- path/to/test.test.ts
876
-
877
- # Run with coverage
878
- npm run test:coverage
879
- ```
880
-
881
- ## License
882
-
883
- MIT License - see [LICENSE](LICENSE) file for details.
884
-
885
- ## Acknowledgments
886
-
887
- - Built on the [Model Context Protocol](https://modelcontextprotocol.io)
888
- - Inspired by research in cognitive science and AI reasoning
889
- - Community contributions from researchers and practitioners
890
-
891
- ## Support
892
-
893
- - 📚 [Documentation](docs/)
894
- - 🐛 [Issue Tracker](https://github.com/danielsimonjr/deepthinking-mcp/issues)
895
- - 💬 [Discussions](https://github.com/danielsimonjr/deepthinking-mcp/discussions)
896
-
897
- ---
898
-
899
- Made with ❤️ by the DeepThinking MCP team
1
+ # DeepThinking MCP
2
+
3
+ [![TypeScript](https://img.shields.io/badge/TypeScript-100%25-blue.svg)](https://www.typescriptlang.org/)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![MCP Compatible](https://img.shields.io/badge/MCP-Compatible-green.svg)](https://modelcontextprotocol.io)
6
+
7
+ A comprehensive Model Context Protocol (MCP) server featuring **34 reasoning modes** (30 with dedicated thought types, 4 advanced runtime modes) including historical reasoning, meta-reasoning for strategic oversight, with intelligent mode recommendation, taxonomy-based classification, enterprise security, and production-ready features for complex problem-solving, analysis, and decision-making.
8
+
9
+ > 📋 **Latest Release**: v9.1.0 - See [CHANGELOG](CHANGELOG.md) for updates and improvements.
10
+ >
11
+ > 🎉 **New in v9.1.0**: Historical Reasoning Mode - Analyze historical events, evaluate sources, identify patterns, trace causal chains, and define periods with 5 thought types.
12
+ >
13
+ > ✨ **Codebase**: 237 TypeScript files | 102,500 LOC | 15 modules | 5,048+ tests passing
14
+
15
+
16
+ ## Table of Contents
17
+
18
+ - [Features](#features)
19
+ - [Installation](#installation)
20
+ - [Quick Start](#quick-start)
21
+ - [Reasoning Modes](#reasoning-modes)
22
+ - [Proof Decomposition](#proof-decomposition)
23
+ - [Usage Examples](#usage-examples)
24
+ - [Production Features](#production-features)
25
+ - [API Documentation](#api-documentation)
26
+ - [Contributing](#contributing)
27
+ - [License](#license)
28
+
29
+ ## Features
30
+
31
+ - **34 Specialized Reasoning Modes** - From sequential thinking to historical analysis, game theory, formal logic, and meta-reasoning (30 with full thought types, 4 advanced runtime modes)
32
+ - **ModeHandler Architecture (v9.x)** - Strategy pattern with 37 specialized handlers providing advanced validation and enhancements for all 34 modes
33
+ - **Historical Reasoning (v9.1.0)** - Event analysis, source evaluation, pattern identification, causal chains, periodization with 5 thought types
34
+ - **Specialized Handler Enhancements** - Systems Archetypes (8 patterns), Socratic Questions (6 categories), auto Bayesian posteriors, Nash equilibria, source reliability scoring
35
+ - **Visual Builder APIs** - 14 fluent builder classes: DOTGraphBuilder, MermaidGraphBuilder, MermaidGanttBuilder, MermaidStateDiagramBuilder, ASCIIDocBuilder, SVGBuilder, TikZBuilder, UMLBuilder, HTMLDocBuilder, MarkdownBuilder, ModelicaBuilder, JSONExportBuilder, GraphMLBuilder, SVGGroupBuilder
36
+ - **Academic Research Modes** - Synthesis (literature review), Argumentation (Toulmin), Critique (peer review), Analysis (qualitative methods)
37
+ - **Algorithmic Reasoning** - Comprehensive CLRS coverage with 100+ named algorithms, complexity analysis, design patterns
38
+ - **Historical Computing Extensions** - Computability (Turing machines), Cryptanalytic (decibans), extended Game Theory (von Neumann)
39
+ - **Proof Decomposition** - Break proofs into atomic statements, detect gaps, track assumption chains
40
+ - **Native SVG Export** - Direct SVG generation without external tools for proof visualizations
41
+ - **Meta-Reasoning** - Strategic oversight that monitors effectiveness, recommends mode switches, and assesses quality
42
+ - **Intelligent Mode Recommendation** - Automatic mode selection based on problem characteristics
43
+ - **Taxonomy Classifier** - 69 reasoning types across 12 categories for intelligent task classification (110 planned)
44
+ - **Visual Exports** - Generate Mermaid diagrams, DOT graphs, ASCII art, SVG graphics, and LaTeX documents
45
+ - **File Export System** - Export sessions to files with configurable output directory and profiles
46
+ - **Production-Ready** - Search engine, session management, caching, multi-instance support
47
+ - **Enterprise Security** - Input validation (Zod), path sanitization, PII redaction
48
+ - **High Performance** - LRU caching with auto-eviction, async I/O
49
+ - **Type-Safe** - 100% TypeScript with comprehensive type coverage
50
+ - **Extensible** - Plugin architecture for custom reasoning modes
51
+ - **MCP Compatible** - Full integration with Model Context Protocol
52
+
53
+
54
+ ## Installation
55
+
56
+ ### NPM Package
57
+
58
+ ```bash
59
+ npm install deepthinking-mcp
60
+ ```
61
+
62
+ ### From Source
63
+
64
+ ```bash
65
+ git clone https://github.com/danielsimonjr/deepthinking-mcp.git
66
+ cd deepthinking-mcp
67
+ npm install
68
+ npm run build
69
+ ```
70
+
71
+ ### MCP Configuration
72
+
73
+ Add to your MCP settings file:
74
+
75
+ ```json
76
+ {
77
+ "mcpServers": {
78
+ "deepthinking": {
79
+ "command": "npx",
80
+ "args": ["deepthinking-mcp"]
81
+ }
82
+ }
83
+ }
84
+ ```
85
+
86
+ ### Configuration with Environment Variables
87
+
88
+ Configure the server with environment variables:
89
+
90
+ ```json
91
+ {
92
+ "mcpServers": {
93
+ "deepthinking": {
94
+ "command": "npx",
95
+ "args": ["deepthinking-mcp"],
96
+ "env": {
97
+ "MCP_EXPORT_PATH": "C:/deepthinking-exports",
98
+ "MCP_EXPORT_OVERWRITE": "false",
99
+ "MCP_LOG_LEVEL": "info"
100
+ }
101
+ }
102
+ }
103
+ }
104
+ ```
105
+
106
+ | Variable | Description | Default |
107
+ |----------|-------------|---------|
108
+ | `MCP_EXPORT_PATH` | Default directory for file exports | `` (returns content) |
109
+ | `MCP_EXPORT_OVERWRITE` | Overwrite existing files | `false` |
110
+ | `MCP_LOG_LEVEL` | Log level (debug/info/warn/error) | `info` |
111
+ | `MCP_MAX_SESSIONS` | Maximum active sessions | `100` |
112
+ | `MCP_SESSION_TIMEOUT_MS` | Session timeout (0 = none) | `0` |
113
+ | `SESSION_DIR` | Shared session storage for multi-instance | `` (in-memory) |
114
+
115
+ ## Quick Start
116
+
117
+ ### MCP Tool Usage
118
+
119
+ DeepThinking MCP provides 13 focused tools for different reasoning domains:
120
+
121
+ | Tool | Modes | Description |
122
+ |------|-------|-------------|
123
+ | `deepthinking_core` | inductive, deductive, abductive | Fundamental reasoning |
124
+ | `deepthinking_standard` | sequential, shannon, hybrid | Standard workflow modes |
125
+ | `deepthinking_mathematics` | mathematics, physics, computability | Math/physics/computability |
126
+ | `deepthinking_temporal` | temporal | Time-based reasoning |
127
+ | `deepthinking_probabilistic` | bayesian, evidential | Probabilistic reasoning |
128
+ | `deepthinking_causal` | causal, counterfactual | Cause-effect analysis |
129
+ | `deepthinking_strategic` | gametheory, optimization | Strategic reasoning |
130
+ | `deepthinking_analytical` | analogical, firstprinciples, metareasoning, cryptanalytic | Analytical reasoning |
131
+ | `deepthinking_scientific` | scientificmethod, systemsthinking, formallogic | Scientific reasoning |
132
+ | `deepthinking_engineering` | engineering, algorithmic | Engineering/algorithmic |
133
+ | `deepthinking_academic` | synthesis, argumentation, critique, analysis | Academic research |
134
+ | `deepthinking_session` | - | Session management |
135
+ | `deepthinking_analyze` | Multi-mode | Analysis with presets and merge strategies |
136
+
137
+ ### Example: Sequential Reasoning
138
+
139
+ ```json
140
+ {
141
+ "tool": "deepthinking_standard",
142
+ "arguments": {
143
+ "mode": "sequential",
144
+ "thought": "First, identify the main bottlenecks in the distributed system",
145
+ "thoughtNumber": 1,
146
+ "totalThoughts": 5,
147
+ "nextThoughtNeeded": true
148
+ }
149
+ }
150
+ ```
151
+
152
+ ### Example: Causal Analysis
153
+
154
+ ```json
155
+ {
156
+ "tool": "deepthinking_causal",
157
+ "arguments": {
158
+ "mode": "causal",
159
+ "thought": "Analyzing the root cause of the service outage",
160
+ "thoughtNumber": 1,
161
+ "totalThoughts": 3,
162
+ "nextThoughtNeeded": true,
163
+ "causalGraph": {
164
+ "nodes": [
165
+ {"id": "n1", "name": "High Load", "type": "cause"},
166
+ {"id": "n2", "name": "Memory Exhaustion", "type": "mediator"},
167
+ {"id": "n3", "name": "Service Crash", "type": "effect"}
168
+ ],
169
+ "edges": [
170
+ {"from": "n1", "to": "n2", "strength": 0.9},
171
+ {"from": "n2", "to": "n3", "strength": 0.95}
172
+ ]
173
+ }
174
+ }
175
+ }
176
+ ```
177
+
178
+ ### Example: Session Export
179
+
180
+ ```json
181
+ {
182
+ "tool": "deepthinking_session",
183
+ "arguments": {
184
+ "action": "export",
185
+ "sessionId": "session-123",
186
+ "exportFormat": "markdown"
187
+ }
188
+ }
189
+ ```
190
+
191
+ ## Reasoning Modes
192
+
193
+ The server supports 34 reasoning modes organized into categories:
194
+
195
+ - **Core Modes (5)**: Sequential, Shannon, Mathematics, Physics, Hybrid
196
+ - **Causal/Probabilistic (7)**: Causal, Bayesian, Counterfactual, Temporal, Historical, GameTheory, Evidential
197
+ - **Historical Computing (2)**: Computability (Turing), Cryptanalytic (Turing) - *v7.2.0*
198
+ - **Algorithmic (1)**: Algorithmic (CLRS) - *v7.3.0*
199
+ - **Academic Research (4)**: Synthesis, Argumentation, Critique, Analysis - *v7.4.0*
200
+ - **Advanced Runtime Modes (6)**: Metareasoning, Recursive, Modal, Stochastic, Constraint, Optimization
201
+ - **Fundamental Modes (3)**: Inductive, Deductive, Abductive
202
+ - **Systems/Scientific (3)**: SystemsThinking, ScientificMethod, FormalLogic
203
+ - **Analogical (2)**: Analogical, FirstPrinciples
204
+ - **Engineering (1)**: Engineering
205
+
206
+ ### Core Modes
207
+
208
+ #### Sequential
209
+ Iterative refinement with revision capabilities. Perfect for step-by-step problem solving.
210
+
211
+ ```typescript
212
+ mode: 'sequential'
213
+ // Use for: Debugging, algorithmic thinking, systematic analysis
214
+ ```
215
+
216
+ #### Shannon
217
+ 5-stage systematic problem-solving methodology (problem constraints → model → proof → implementation).
218
+
219
+ ```typescript
220
+ mode: 'shannon'
221
+ // Use for: Engineering problems, system design, complex optimizations
222
+ ```
223
+
224
+ #### Mathematics
225
+ Theorem proving, lemma derivation, symbolic computation with LaTeX support.
226
+
227
+ ```typescript
228
+ mode: 'mathematics'
229
+ // Use for: Proofs, mathematical modeling, symbolic algebra
230
+ ```
231
+
232
+ #### Physics
233
+ Tensor mathematics, dimensional analysis, conservation laws, field theory.
234
+
235
+ ```typescript
236
+ mode: 'physics'
237
+ // Use for: Physical modeling, dimensional analysis, scientific computing
238
+ ```
239
+
240
+ #### Hybrid
241
+ Intelligently combines multiple reasoning modes based on problem characteristics.
242
+
243
+ ```typescript
244
+ mode: 'hybrid'
245
+ // Use for: Complex multi-faceted problems requiring diverse approaches
246
+ ```
247
+
248
+ ### Historical Reasoning (v9.1.0)
249
+
250
+ #### Historical
251
+ Comprehensive historical analysis with source evaluation, pattern recognition, and causal chain analysis.
252
+
253
+ ```typescript
254
+ mode: 'historical'
255
+ // Use for: Historical research, source criticism, event analysis, periodization
256
+ // Features: 5 thought types, aggregate reliability scoring, pattern detection
257
+ ```
258
+
259
+ **5 Thought Types:**
260
+ - `event_analysis` - Analyze historical events with significance ratings
261
+ - `source_evaluation` - Evaluate primary/secondary/tertiary sources with reliability scoring
262
+ - `pattern_identification` - Identify recurring patterns across time (cyclical, structural, contingent)
263
+ - `causal_chain` - Trace cause-effect relationships with confidence scores
264
+ - `periodization` - Define and analyze historical periods with characteristics
265
+
266
+ **Data Structures:**
267
+ - `HistoricalEvent` - Events with dates, actors, causes/effects, significance levels
268
+ - `HistoricalSource` - Sources with type, reliability (0-1), bias analysis, corroboration
269
+ - `HistoricalPeriod` - Time periods with characteristics, key events, transitions
270
+ - `CausalChain` - Linked causal relationships with evidence and confidence
271
+ - `HistoricalActor` - Individuals, groups, institutions, nations, movements
272
+
273
+ **Handler Features:**
274
+ - Aggregate reliability calculation (weighted by source type with corroboration bonus)
275
+ - Causal chain continuity validation
276
+ - Automatic pattern detection from events
277
+ - Temporal span calculation
278
+ - Cross-reference validation (events ↔ sources ↔ actors)
279
+
280
+ ### Advanced Modes
281
+
282
+ #### Causal
283
+ Build causal graphs, analyze interventions and effects.
284
+
285
+ ```typescript
286
+ mode: 'causal'
287
+ // Use for: Impact analysis, system design, decision making
288
+ ```
289
+
290
+ #### Bayesian
291
+ Probabilistic reasoning with priors, likelihoods, and evidence updates.
292
+
293
+ ```typescript
294
+ mode: 'bayesian'
295
+ // Use for: Risk assessment, A/B testing, uncertainty quantification
296
+ ```
297
+
298
+ #### Counterfactual
299
+ Explore alternative scenarios and compare outcomes.
300
+
301
+ ```typescript
302
+ mode: 'counterfactual'
303
+ // Use for: Post-mortems, strategic planning, what-if analysis
304
+ ```
305
+
306
+ #### Analogical
307
+ Transfer knowledge across domains by identifying structural similarities.
308
+
309
+ ```typescript
310
+ mode: 'analogical'
311
+ // Use for: Design patterns, innovative problem-solving, knowledge transfer
312
+ ```
313
+
314
+ ### Specialized Modes
315
+
316
+ #### Temporal
317
+ Model events, intervals, and temporal relationships using Allen's interval algebra.
318
+
319
+ ```typescript
320
+ mode: 'temporal'
321
+ // Use for: Timeline analysis, scheduling, event sequencing
322
+ ```
323
+
324
+ #### Game Theory
325
+ Analyze strategic interactions, compute Nash equilibria, build game trees.
326
+
327
+ ```typescript
328
+ mode: 'game-theory'
329
+ // Use for: Competitive analysis, mechanism design, strategic decisions
330
+ ```
331
+
332
+ #### Evidential
333
+ Dempster-Shafer theory for reasoning with uncertain evidence.
334
+
335
+ ```typescript
336
+ mode: 'evidential'
337
+ // Use for: Sensor fusion, intelligence analysis, incomplete information
338
+ ```
339
+
340
+ #### First Principles
341
+ Derive conclusions from foundational axioms using deductive reasoning.
342
+
343
+ ```typescript
344
+ mode: 'first-principles'
345
+ // Use for: Fundamental analysis, conceptual understanding, basic truths
346
+ ```
347
+
348
+ #### Meta-Reasoning
349
+ Strategic oversight of reasoning process - monitors effectiveness, recommends mode switches, assesses quality.
350
+
351
+ ```typescript
352
+ mode: 'metareasoning'
353
+ // Use for: Strategy evaluation, adaptive mode switching, quality assessment
354
+ // Metrics: Effectiveness, Efficiency, Confidence, Quality (6 dimensions)
355
+ // Auto-switches at effectiveness < 0.3
356
+ ```
357
+
358
+ See [full documentation](docs/modes/METAREASONING.md) for detailed usage.
359
+
360
+ #### Systems Thinking
361
+ Holistic analysis of complex systems, feedback loops, and emergence.
362
+
363
+ ```typescript
364
+ mode: 'systems-thinking'
365
+ // Use for: Complex systems, organizational design, ecosystem analysis
366
+ ```
367
+
368
+ #### Scientific Method
369
+ Hypothesis-driven experimentation with research design and statistical analysis.
370
+
371
+ ```typescript
372
+ mode: 'scientific-method'
373
+ // Use for: Experimental design, hypothesis testing, research
374
+ ```
375
+
376
+ #### Optimization
377
+ Constraint satisfaction and optimization with decision variables.
378
+
379
+ ```typescript
380
+ mode: 'optimization'
381
+ // Use for: Resource allocation, scheduling, constrained optimization
382
+ ```
383
+
384
+ #### Formal Logic
385
+ Rigorous logical reasoning with formal systems and proof verification.
386
+
387
+ ```typescript
388
+ mode: 'formal-logic'
389
+ // Use for: Proof verification, logical analysis, formal methods
390
+ ```
391
+
392
+ ### Advanced Runtime Modes
393
+
394
+ #### Recursive
395
+ Recursive problem decomposition - break complex problems into smaller subproblems.
396
+
397
+ ```typescript
398
+ mode: 'recursive'
399
+ // Use for: Divide-and-conquer, tree-structured problems, recursive algorithms
400
+ ```
401
+
402
+ #### Modal
403
+ Possibility and necessity reasoning using modal logic.
404
+
405
+ ```typescript
406
+ mode: 'modal'
407
+ // Use for: What's possible vs necessary, requirement analysis, constraint exploration
408
+ ```
409
+
410
+ #### Stochastic
411
+ Probabilistic state transitions and Markov chain reasoning.
412
+
413
+ ```typescript
414
+ mode: 'stochastic'
415
+ // Use for: Process modeling, state machines, probabilistic sequences
416
+ ```
417
+
418
+ #### Constraint
419
+ Constraint satisfaction problem solving.
420
+
421
+ ```typescript
422
+ mode: 'constraint'
423
+ // Use for: Scheduling, resource allocation, constraint propagation
424
+ ```
425
+
426
+ ### Fundamental Modes
427
+
428
+ #### Inductive
429
+ Reasoning from specific observations to general principles.
430
+
431
+ ```typescript
432
+ mode: 'inductive'
433
+ // Use for: Pattern recognition, generalization, empirical reasoning
434
+ ```
435
+
436
+ #### Deductive
437
+ Reasoning from general principles to specific conclusions.
438
+
439
+ ```typescript
440
+ mode: 'deductive'
441
+ // Use for: Logical proofs, applying rules, deriving conclusions
442
+ ```
443
+
444
+ #### Abductive
445
+ Generate and evaluate hypotheses to explain observations.
446
+
447
+ ```typescript
448
+ mode: 'abductive'
449
+ // Use for: Debugging, root cause analysis, diagnostic reasoning
450
+ ```
451
+
452
+ ### Historical Computing Modes (v7.2.0)
453
+
454
+ Tributes to Alan Turing and John von Neumann's foundational work.
455
+
456
+ #### Computability
457
+ Turing machines, decidability proofs, reductions, and diagonalization arguments.
458
+
459
+ ```typescript
460
+ mode: 'computability'
461
+ // Use for: Decidability analysis, algorithm limits, computational complexity
462
+ // Features: Turing machine simulation, reduction chains, halting problem analysis
463
+ ```
464
+
465
+ #### Cryptanalytic
466
+ Turing's deciban evidence system from Bletchley Park.
467
+
468
+ ```typescript
469
+ mode: 'cryptanalytic'
470
+ // Use for: Evidence quantification, hypothesis testing, code-breaking analysis
471
+ // Features: Deciban accumulation (10 db 10:1 odds), frequency analysis, Banburismus
472
+ ```
473
+
474
+ #### Extended Game Theory (v7.2.0)
475
+ Von Neumann's minimax theorem, cooperative games, and Shapley values.
476
+
477
+ ```typescript
478
+ mode: 'gametheory'
479
+ // Enhanced with: Minimax analysis, cooperative game theory, coalition analysis
480
+ // Use for: Zero-sum games, fair value distribution, strategic decision-making
481
+ ```
482
+
483
+ ### Algorithmic Mode (v7.3.0)
484
+
485
+ #### Algorithmic
486
+ Comprehensive coverage of algorithms from "Introduction to Algorithms" (CLRS) with 100+ named algorithms.
487
+
488
+ ```typescript
489
+ mode: 'algorithmic'
490
+ // Use for: Algorithm design, complexity analysis, correctness proofs
491
+ // Features: Divide-and-conquer, dynamic programming, greedy, graph algorithms
492
+ // Coverage: Sorting, searching, graph, string, computational geometry
493
+ ```
494
+
495
+ ### Academic Research Modes (v7.4.0)
496
+
497
+ Designed for PhD students and scientific paper writing.
498
+
499
+ #### Synthesis
500
+ Literature review and knowledge integration.
501
+
502
+ ```typescript
503
+ mode: 'synthesis'
504
+ // Use for: Literature reviews, theme extraction, knowledge integration
505
+ // Features: Source synthesis, pattern identification, gap analysis
506
+ ```
507
+
508
+ #### Argumentation
509
+ Academic argumentation using the Toulmin model.
510
+
511
+ ```typescript
512
+ mode: 'argumentation'
513
+ // Use for: Building arguments, dialectical reasoning, rhetorical analysis
514
+ // Features: Toulmin model (claim, data, warrant, backing), counter-arguments
515
+ ```
516
+
517
+ #### Critique
518
+ Critical analysis and peer review frameworks.
519
+
520
+ ```typescript
521
+ mode: 'critique'
522
+ // Use for: Peer review, methodology evaluation, evidence assessment
523
+ // Features: Systematic critique, strengths/weaknesses analysis
524
+ ```
525
+
526
+ #### Analysis
527
+ Qualitative analysis methods.
528
+
529
+ ```typescript
530
+ mode: 'analysis'
531
+ // Use for: Thematic analysis, grounded theory, discourse analysis
532
+ // Features: Multiple qualitative analysis frameworks, coding support
533
+ ```
534
+
535
+ ### Specialized Mode Handlers (v9.x)
536
+
537
+ The ModeHandler system provides 37 specialized handlers with advanced validation and enhancements. Key examples:
538
+
539
+ | Handler | Mode | Key Enhancements |
540
+ |---------|------|------------------|
541
+ | **HistoricalHandler** | historical | Aggregate reliability scoring, causal chain validation, pattern detection |
542
+ | **CausalHandler** | causal | Validates graph structure, detects cycles, propagates interventions |
543
+ | **BayesianHandler** | bayesian | Auto-calculates posteriors from prior × likelihood, validates probability sums |
544
+ | **GameTheoryHandler** | gametheory | Validates payoff matrix dimensions, computes Nash equilibria |
545
+ | **CounterfactualHandler** | counterfactual | Tracks world states, validates divergence points, compares outcomes |
546
+ | **SynthesisHandler** | synthesis | Tracks source coverage, validates theme extraction, detects contradictions |
547
+ | **SystemsThinkingHandler** | systemsthinking | Detects 8 Systems Archetypes, adds warning signs and interventions |
548
+ | **CritiqueHandler** | critique | 6 Socratic question categories for rigorous critical analysis |
549
+
550
+ #### Systems Archetypes Detection
551
+
552
+ SystemsThinkingHandler automatically detects Peter Senge's 8 archetypes:
553
+
554
+ - **Fixes that Fail** - Short-term fixes with unintended consequences
555
+ - **Shifting the Burden** - Symptomatic vs fundamental solutions
556
+ - **Limits to Growth** - Growth hitting constraints
557
+ - **Success to the Successful** - Winner-take-all dynamics
558
+ - **Tragedy of the Commons** - Shared resource depletion
559
+ - **Escalation** - Competitive escalation spirals
560
+ - **Accidental Adversaries** - Alliance deterioration
561
+ - **Growth and Underinvestment** - Capacity constraints
562
+
563
+ #### Socratic Question Framework
564
+
565
+ CritiqueHandler uses Richard Paul's 6 categories:
566
+
567
+ - **Clarification** - "What do you mean by...?"
568
+ - **Assumptions** - "What are you assuming?"
569
+ - **Evidence** - "What evidence supports this?"
570
+ - **Perspectives** - "Are there alternative viewpoints?"
571
+ - **Implications** - "What are the consequences?"
572
+ - **Meta** - "Why is this question important?"
573
+
574
+
575
+ ## Proof Decomposition
576
+
577
+ **New in v7.0.0!** The proof decomposition system provides advanced mathematical reasoning capabilities:
578
+
579
+ ### Components
580
+
581
+ | Component | Purpose |
582
+ |-----------|---------|
583
+ | **ProofDecomposer** | Breaks proofs into atomic statements with dependency tracking |
584
+ | **GapAnalyzer** | Detects missing steps, unjustified leaps, and implicit assumptions |
585
+ | **AssumptionTracker** | Traces conclusions back to their supporting assumptions |
586
+ | **InconsistencyDetector** | Detects circular dependencies and contradictions |
587
+ | **MathematicsReasoningEngine** | Integrated proof analysis with improvement suggestions |
588
+
589
+ ### Features
590
+
591
+ - **Atomic Statement Types**: axiom, hypothesis, definition, derived, lemma, conclusion
592
+ - **Inference Rules**: algebraic_manipulation, substitution, modus_ponens, universal_instantiation, etc.
593
+ - **Gap Detection**: Identify missing steps with severity levels (minor, significant, critical)
594
+ - **Rigor Levels**: informal, textbook, rigorous, formal
595
+ - **Visual Export**: Mermaid, DOT, ASCII, and native SVG formats
596
+
597
+ ### Example: Proof Analysis
598
+
599
+ ```json
600
+ {
601
+ "tool": "deepthinking_mathematics",
602
+ "arguments": {
603
+ "mode": "mathematics",
604
+ "thought": "Analyzing the proof that n² is even when n is even",
605
+ "thoughtNumber": 1,
606
+ "totalThoughts": 3,
607
+ "nextThoughtNeeded": true,
608
+ "proofDecomposition": {
609
+ "theorem": "If n is even, then n² is even",
610
+ "atoms": [
611
+ {"id": "a1", "content": "n is an even integer", "type": "hypothesis"},
612
+ {"id": "a2", "content": "n = 2k for some integer k", "type": "definition"},
613
+ {"id": "a3", "content": "n² = 4k² = 2(2k²)", "type": "derived"},
614
+ {"id": "a4", "content": "n² is even", "type": "conclusion"}
615
+ ],
616
+ "dependencies": {
617
+ "nodes": ["a1", "a2", "a3", "a4"],
618
+ "edges": [
619
+ {"from": "a1", "to": "a2"},
620
+ {"from": "a2", "to": "a3"},
621
+ {"from": "a3", "to": "a4"}
622
+ ]
623
+ }
624
+ }
625
+ }
626
+ }
627
+ ```
628
+
629
+ ### Visual Export Formats
630
+
631
+ Export proof decompositions to multiple visual formats:
632
+
633
+ ```typescript
634
+ // Native SVG (no external tools required)
635
+ exportProofDecomposition(decomposition, {
636
+ format: 'svg',
637
+ colorScheme: 'default', // 'default' | 'pastel' | 'monochrome'
638
+ includeMetrics: true,
639
+ svgWidth: 1200,
640
+ svgHeight: 800
641
+ });
642
+
643
+ // Mermaid diagram
644
+ exportProofDecomposition(decomposition, { format: 'mermaid' });
645
+
646
+ // GraphViz DOT
647
+ exportProofDecomposition(decomposition, { format: 'dot' });
648
+
649
+ // ASCII text
650
+ exportProofDecomposition(decomposition, { format: 'ascii' });
651
+ ```
652
+
653
+ ## Usage Examples
654
+
655
+ ### Example 1: Debugging with Abductive Reasoning
656
+
657
+ ```json
658
+ // Step 1: Start with observation
659
+ {
660
+ "tool": "deepthinking_core",
661
+ "arguments": {
662
+ "mode": "abductive",
663
+ "thought": "Observed: Users report intermittent 500 errors on checkout during high traffic periods",
664
+ "thoughtNumber": 1,
665
+ "totalThoughts": 4,
666
+ "nextThoughtNeeded": true,
667
+ "observations": ["Errors occur during high traffic", "Checkout page affected", "Intermittent pattern"]
668
+ }
669
+ }
670
+
671
+ // Step 2: Generate hypothesis
672
+ {
673
+ "tool": "deepthinking_core",
674
+ "arguments": {
675
+ "sessionId": "session-from-step-1",
676
+ "mode": "abductive",
677
+ "thought": "Hypothesis: Database connection pool exhaustion under load",
678
+ "thoughtNumber": 2,
679
+ "totalThoughts": 4,
680
+ "nextThoughtNeeded": true,
681
+ "hypotheses": [{
682
+ "id": "h1",
683
+ "explanation": "Connection pool exhausted",
684
+ "assumptions": ["Fixed pool size", "No connection recycling"],
685
+ "predictions": ["Errors correlate with traffic spikes"],
686
+ "score": 0.8
687
+ }]
688
+ }
689
+ }
690
+ ```
691
+
692
+ ### Example 2: Impact Analysis with Causal Reasoning
693
+
694
+ ```json
695
+ {
696
+ "tool": "deepthinking_causal",
697
+ "arguments": {
698
+ "mode": "causal",
699
+ "thought": "Analyzing impact of increasing API rate limits on system behavior",
700
+ "thoughtNumber": 1,
701
+ "totalThoughts": 3,
702
+ "nextThoughtNeeded": true,
703
+ "causalGraph": {
704
+ "nodes": [
705
+ {"id": "rate_limit", "name": "Rate Limit", "type": "cause", "description": "API rate limit setting"},
706
+ {"id": "server_load", "name": "Server Load", "type": "mediator", "description": "CPU/Memory usage"},
707
+ {"id": "response_time", "name": "Response Time", "type": "effect", "description": "API latency"},
708
+ {"id": "satisfaction", "name": "User Satisfaction", "type": "effect", "description": "User experience"}
709
+ ],
710
+ "edges": [
711
+ {"from": "rate_limit", "to": "server_load", "strength": 0.9, "confidence": 0.85},
712
+ {"from": "server_load", "to": "response_time", "strength": 0.85, "confidence": 0.9},
713
+ {"from": "response_time", "to": "satisfaction", "strength": -0.7, "confidence": 0.8}
714
+ ]
715
+ }
716
+ }
717
+ }
718
+ ```
719
+
720
+ ### Example 3: Strategic Analysis with Game Theory
721
+
722
+ ```json
723
+ {
724
+ "tool": "deepthinking_strategic",
725
+ "arguments": {
726
+ "mode": "gametheory",
727
+ "thought": "Analyzing pricing strategy in competitive market using game theory",
728
+ "thoughtNumber": 1,
729
+ "totalThoughts": 3,
730
+ "nextThoughtNeeded": true,
731
+ "game": {
732
+ "type": "strategic",
733
+ "players": ["Company A", "Company B"],
734
+ "strategies": {
735
+ "Company A": ["premium", "competitive", "discount"],
736
+ "Company B": ["premium", "competitive", "discount"]
737
+ },
738
+ "payoffMatrix": [
739
+ [{"A": 10, "B": 10}, {"A": 5, "B": 15}, {"A": 2, "B": 12}],
740
+ [{"A": 15, "B": 5}, {"A": 8, "B": 8}, {"A": 4, "B": 10}],
741
+ [{"A": 12, "B": 2}, {"A": 10, "B": 4}, {"A": 6, "B": 6}]
742
+ ]
743
+ }
744
+ }
745
+ }
746
+ ```
747
+
748
+ ## Production Features
749
+
750
+ > **Note**: DeepThinking MCP is an MCP server, not a library. These features are accessed through MCP tools and internal architecture. The examples below describe the internal capabilities.
751
+
752
+ ### Proof Decomposition (v7.0.0)
753
+
754
+ Advanced mathematical reasoning with proof analysis:
755
+
756
+ - **ProofDecomposer**: Break proofs into atomic statements with dependency graphs
757
+ - **GapAnalyzer**: Detect missing steps, unjustified leaps, implicit assumptions
758
+ - **AssumptionTracker**: Trace conclusions to their supporting assumptions
759
+ - **InconsistencyDetector**: Find circular dependencies and contradictions
760
+ - **Native SVG Export**: Generate proof visualizations without external tools
761
+
762
+ ### Search Engine
763
+
764
+ Full-text search with faceted filtering and relevance ranking. Used internally to search across reasoning sessions by mode, tags, date ranges, and content.
765
+
766
+ ### Template System
767
+
768
+ Pre-built templates for common reasoning patterns, accessible through session creation.
769
+
770
+ ### File Export System
771
+
772
+ Export reasoning sessions directly to files with automatic directory organization:
773
+
774
+ - **Automatic File Output** - Configure `MCP_EXPORT_PATH` to write exports to disk instead of returning content
775
+ - **Session Subdirectories** - Files organized by session ID for easy management
776
+ - **Export Profiles** - Pre-configured bundles: `academic` (LaTeX+Markdown+JSON), `presentation` (Mermaid+HTML+ASCII), `documentation`, `archive`, `minimal`
777
+ - **8 Export Formats** - Markdown, LaTeX, JSON, HTML, Jupyter, Mermaid, DOT, ASCII
778
+ - **Overwrite Protection** - Files won't be overwritten unless `overwrite: true` or `MCP_EXPORT_OVERWRITE=true`
779
+
780
+ ```json
781
+ // Export single format
782
+ { "action": "export", "sessionId": "...", "exportFormat": "mermaid" }
783
+
784
+ // Export with profile
785
+ { "action": "export", "sessionId": "...", "exportProfile": "academic" }
786
+
787
+ // Export all 8 formats
788
+ { "action": "export_all", "sessionId": "..." }
789
+ ```
790
+
791
+ ### Security & Validation
792
+
793
+ Enterprise-grade security features built into the MCP server:
794
+
795
+ - **Input Validation** - Zod schemas validate all 33 mode inputs
796
+ - **Rate Limiting** - Sliding window rate limiter for API protection
797
+ - **Path Sanitization** - Prevents directory traversal attacks
798
+ - **PII Redaction** - GDPR-compliant log sanitization
799
+
800
+ ### Taxonomy Classifier
801
+
802
+ Intelligent classification of reasoning tasks using 69 reasoning types across 12 categories. Use the `recommend_mode` action in `deepthinking_session` to get mode recommendations based on problem characteristics.
803
+
804
+ ## API Documentation
805
+
806
+ ### MCP Tool Interface
807
+
808
+ All reasoning is done through MCP tools. Each tool accepts arguments and returns JSON responses.
809
+
810
+ #### Common Parameters (all thinking tools)
811
+
812
+ | Parameter | Type | Required | Description |
813
+ |-----------|------|----------|-------------|
814
+ | `sessionId` | string | No | Session ID (auto-created if omitted) |
815
+ | `thought` | string | Yes | The reasoning content |
816
+ | `thoughtNumber` | integer | Yes | Current thought number (1-based) |
817
+ | `totalThoughts` | integer | Yes | Estimated total thoughts |
818
+ | `nextThoughtNeeded` | boolean | Yes | Whether more reasoning needed |
819
+ | `mode` | string | Yes | The reasoning mode |
820
+
821
+ #### Session Actions (`deepthinking_session`)
822
+
823
+ | Action | Parameters | Description |
824
+ |--------|------------|-------------|
825
+ | `summarize` | `sessionId` | Generate session summary |
826
+ | `export` | `sessionId`, `exportFormat` | Export to format (json, markdown, latex, html, jupyter, mermaid, dot, ascii, svg) |
827
+ | `get_session` | `sessionId` | Get session details |
828
+ | `switch_mode` | `sessionId`, `newMode` | Switch reasoning mode |
829
+ | `recommend_mode` | `problemType` or `problemCharacteristics` | Get mode recommendations |
830
+
831
+ #### Example Response
832
+
833
+ ```json
834
+ {
835
+ "sessionId": "session-abc123",
836
+ "thoughtId": "thought-xyz789",
837
+ "thoughtNumber": 1,
838
+ "mode": "sequential",
839
+ "nextThoughtNeeded": true,
840
+ "sessionComplete": false,
841
+ "totalThoughts": 3
842
+ }
843
+ ```
844
+
845
+ For architecture details, see [docs/architecture/](docs/architecture/).
846
+
847
+ ## Project Stats
848
+
849
+ | Metric | Value |
850
+ |--------|-------|
851
+ | TypeScript Files | 237 |
852
+ | Lines of Code | ~102,500 |
853
+ | Test Files | 181 |
854
+ | Passing Tests | 5,048 |
855
+ | Thinking Modes | 34 (30 with thought types) |
856
+ | ModeHandlers | 37 specialized handlers |
857
+ | MCP Tools | 13 focused tools |
858
+ | Export Formats | 8 + native SVG |
859
+ | Visual Exporters | 42 files (24 mode-specific) |
860
+ | Builder Classes | 14 fluent APIs |
861
+ | Reasoning Types | 69 (110 planned) |
862
+ | Modules | 15 |
863
+ | Total Exports | 1,275 (571 re-exports) |
864
+
865
+
866
+ ## Architecture
867
+
868
+ The codebase is organized into 15 modules with clean separation of concerns. See [docs/architecture/DEPENDENCY_GRAPH.md](docs/architecture/DEPENDENCY_GRAPH.md) for the complete dependency graph.
869
+
870
+ ### Core Structure
871
+
872
+ ```
873
+ src/
874
+ ├── index.ts # MCP server entry point (tool handlers)
875
+ ├── types/ # Type definitions including 33 mode types (36 files)
876
+ │ ├── core.ts # ThinkingMode enum, Thought union type
877
+ │ └── modes/ # One file per reasoning mode
878
+ ├── services/ # Business logic layer (2 files)
879
+ │ ├── ThoughtFactory.ts # Thought creation with handler integration
880
+ │ └── ExportService.ts # Multi-format export handling
881
+ ├── session/ # SessionManager, persistence, storage (4 files)
882
+ ├── modes/ # ModeHandler architecture (v9.x) - 52 files
883
+ │ ├── handlers/ # 38 specialized handlers (all modes covered)
884
+ │ │ ├── CausalHandler.ts # Graph validation, cycle detection
885
+ │ │ ├── BayesianHandler.ts # Auto posterior calculation
886
+ │ │ ├── GameTheoryHandler.ts # Nash equilibria detection
887
+ │ │ ├── CounterfactualHandler.ts # World state tracking
888
+ │ │ ├── SynthesisHandler.ts # Source coverage tracking
889
+ │ │ ├── SystemsThinkingHandler.ts # 8 Systems Archetypes
890
+ │ │ ├── CritiqueHandler.ts # 6 Socratic categories
891
+ │ │ └── [+ 31 more specialized handlers]
892
+ │ └── registry.ts # ModeHandlerRegistry singleton
893
+ ├── proof/ # Proof decomposition system (13 files)
894
+ │ ├── decomposer.ts # ProofDecomposer class
895
+ │ ├── gap-analyzer.ts # GapAnalyzer class
896
+ │ └── assumption-tracker.ts # AssumptionTracker class
897
+ └── tools/ # MCP tool definitions and schemas (18 files)
898
+ ```
899
+
900
+ ### ModeHandler Architecture (v9.x)
901
+
902
+ The ModeHandler pattern (Strategy pattern) provides mode-specific processing, with **all 33 modes fully covered**:
903
+
904
+ ```typescript
905
+ // Handler interface
906
+ interface ModeHandler {
907
+ mode: ThinkingMode;
908
+ validate(input: ThinkingToolInput): ValidationResult;
909
+ enhance(thought: Thought, context: SessionContext): Thought;
910
+ getSuggestions(thought: Thought): string[];
911
+ }
912
+
913
+ // Registry manages all 38 handlers
914
+ const registry = ModeHandlerRegistry.getInstance();
915
+ registry.hasSpecializedHandler('causal'); // true for ALL 33 modes
916
+ ```
917
+
918
+ **Benefits:**
919
+ - All 33 modes have specialized validation logic
920
+ - Automatic enhancements (posteriors, equilibria, archetypes)
921
+ - Mode-specific suggestions and warnings
922
+ - Clean separation from ThoughtFactory
923
+ - 38 total handlers (33 modes + GenericModeHandler + CustomHandler + utilities)
924
+
925
+ ### Feature Modules
926
+
927
+ ```
928
+ src/
929
+ ├── taxonomy/ # 69 reasoning types, classifier, suggestion engine (5 files)
930
+ │ ├── reasoning-types.ts # Full taxonomy definitions
931
+ │ ├── classifier.ts # Task classification
932
+ │ └── suggestion-engine.ts # Mode recommendations
933
+ ├── export/ # Visual and document exporters (44 files)
934
+ │ ├── visual/ # Mode-specific visual exporters + native SVG
935
+ │ │ ├── proof-decomposition.ts # Proof visualization
936
+ │ │ ├── utils/ # 14 builder classes
937
+ │ │ └── modes/ # 22 mode-specific exporters
938
+ │ └── latex.ts # LaTeX document generation
939
+ ├── search/ # Full-text search with TF-IDF (3 files)
940
+ ├── cache/ # LRU caching strategies (3 files)
941
+ ├── validation/ # Zod schemas (44 files, 35 validators)
942
+ └── utils/ # Utility functions (6 files)
943
+ ```
944
+
945
+ ### Security Features
946
+
947
+ Security is built into multiple modules:
948
+
949
+ - **validation/** - Input validation with Zod schemas for all 33 modes (35 validators)
950
+ - **utils/sanitization.ts** - Path sanitization & traversal prevention
951
+ - **utils/log-sanitizer.ts** - PII redaction for GDPR compliance
952
+ - **utils/errors.ts** - Standardized error hierarchy with context
953
+
954
+ ## Contributing
955
+
956
+ We welcome contributions! Please open an issue or pull request on [GitHub](https://github.com/danielsimonjr/deepthinking-mcp).
957
+
958
+ ### Adding New Reasoning Modes
959
+
960
+ Want to add a new reasoning mode? We've made it easy:
961
+
962
+ 📖 **[Complete Guide: Adding a New Mode](docs/ADDING_NEW_MODE.md)**
963
+
964
+ This guide includes:
965
+ - Step-by-step instructions for all 8 required files
966
+ - Template files in `templates/mode-scaffolding/`
967
+ - Code examples and common patterns
968
+ - Complete checklist to ensure nothing is missed
969
+ - Testing guidelines
970
+
971
+ **Quick Start**:
972
+ ```bash
973
+ # Copy template files
974
+ cp templates/mode-scaffolding/example-mode.type.ts src/types/modes/yourmode.ts
975
+ cp templates/mode-scaffolding/example-mode.validator.ts src/validation/validators/modes/yourmode.ts
976
+
977
+ # Follow the guide
978
+ cat docs/ADDING_NEW_MODE.md
979
+ ```
980
+
981
+ ### Development Setup
982
+
983
+ ```bash
984
+ # Clone repository
985
+ git clone https://github.com/danielsimonjr/deepthinking-mcp.git
986
+ cd deepthinking-mcp
987
+
988
+ # Install dependencies
989
+ npm install
990
+
991
+ # Run tests
992
+ npm test
993
+
994
+ # Run type checking
995
+ npm run typecheck
996
+
997
+ # Build
998
+ npm run build
999
+ ```
1000
+
1001
+ ### Running Tests
1002
+
1003
+ ```bash
1004
+ # Run all tests
1005
+ npm test
1006
+
1007
+ # Run specific test file
1008
+ npm test -- path/to/test.test.ts
1009
+
1010
+ # Run with coverage
1011
+ npm run test:coverage
1012
+ ```
1013
+
1014
+ ## License
1015
+
1016
+ MIT License - see [LICENSE](LICENSE) file for details.
1017
+
1018
+ ## Acknowledgments
1019
+
1020
+ This project builds upon foundational work from the MCP community:
1021
+
1022
+ - **[Anthropic's sequential-thinking MCP](https://github.com/modelcontextprotocol/servers/tree/main/src/sequentialthinking)** - The original sequential thinking server that inspired this project's core architecture
1023
+ - **[olaservo's shannon-thinking MCP](https://github.com/olaservo/shannon-thinking)** - Introduced the Shannon 5-stage methodology that became one of our core reasoning modes
1024
+
1025
+ Additional acknowledgments:
1026
+ - Built on the [Model Context Protocol](https://modelcontextprotocol.io)
1027
+ - Inspired by research in cognitive science and AI reasoning
1028
+ - Community contributions from researchers and practitioners
1029
+
1030
+ ## Support
1031
+
1032
+ - 📚 [Documentation](docs/)
1033
+ - 🐛 [Issue Tracker](https://github.com/danielsimonjr/deepthinking-mcp/issues)
1034
+ - 💬 [Discussions](https://github.com/danielsimonjr/deepthinking-mcp/discussions)
1035
+
1036
+ ---
1037
+
1038
+ Made with ❤️ by the DeepThinking MCP team