deepthinking-mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +269 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +629 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
# DeepThinking MCP
|
|
2
|
+
|
|
3
|
+
A unified Model Context Protocol (MCP) server that combines **sequential thinking**, **Shannon's systematic methodology**, and **mathematical reasoning** with specialized support for physics and tensor mathematics.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
DeepThinking MCP merges the best approaches from:
|
|
8
|
+
- **Sequential-thinking** (Anthropic): Iterative refinement and revision
|
|
9
|
+
- **Shannon-thinking**: 5-stage systematic problem-solving
|
|
10
|
+
- **Mathematical reasoning**: Theorem proving and symbolic computation
|
|
11
|
+
- **Physics support**: Tensor mathematics and field theory
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
### Multiple Thinking Modes
|
|
16
|
+
- **Sequential**: Iterative refinement with revision capabilities
|
|
17
|
+
- **Shannon**: Systematic 5-stage problem-solving (problem definition → constraints → model → proof → implementation)
|
|
18
|
+
- **Mathematics**: Theorem proving, lemma derivation, symbolic computation
|
|
19
|
+
- **Physics**: Tensor formulation, dimensional analysis, conservation laws
|
|
20
|
+
- **Hybrid**: Intelligently combines modes based on problem characteristics
|
|
21
|
+
|
|
22
|
+
### Mathematical Enhancements
|
|
23
|
+
- **Symbolic computation** support with LaTeX and symbolic formats
|
|
24
|
+
- **Theorem and proof** structures
|
|
25
|
+
- **Lemma derivation** and corollary tracking
|
|
26
|
+
- **Algebraic manipulation** and numerical analysis
|
|
27
|
+
- **Logical form** with premises, conclusions, and inference rules
|
|
28
|
+
|
|
29
|
+
### Physics Capabilities
|
|
30
|
+
- **Tensor mathematics** with rank, symmetries, and invariants
|
|
31
|
+
- **Dimensional analysis** for unit consistency
|
|
32
|
+
- **Conservation law** verification
|
|
33
|
+
- **Field theory** context (Lagrangian, Hamiltonian, gauge symmetries)
|
|
34
|
+
- **Physical interpretation** with units and observables
|
|
35
|
+
|
|
36
|
+
### Session Management
|
|
37
|
+
- Persistent thinking sessions
|
|
38
|
+
- Automatic metrics tracking
|
|
39
|
+
- Mode switching during problem-solving
|
|
40
|
+
- Export to multiple formats (Markdown, LaTeX, JSON)
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install deepthinking-mcp
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Configuration
|
|
49
|
+
|
|
50
|
+
Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS or `%APPDATA%\Claude\claude_desktop_config.json` on Windows):
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"mcpServers": {
|
|
55
|
+
"deepthinking": {
|
|
56
|
+
"command": "npx",
|
|
57
|
+
"args": ["-y", "deepthinking-mcp"]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Usage
|
|
64
|
+
|
|
65
|
+
### Basic Sequential Thinking
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
Use the deepthinking tool to help me think through this step by step...
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The tool will automatically create a session and track your thoughts.
|
|
72
|
+
|
|
73
|
+
### Mathematical Reasoning
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
Use deepthinking in mathematics mode to prove the Pythagorean theorem...
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Physics Problems
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
Use deepthinking in physics mode to derive the electromagnetic tensor formulation...
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Hybrid Mode (Default)
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
Use deepthinking to solve this complex problem...
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The hybrid mode automatically selects the best features from each mode.
|
|
92
|
+
|
|
93
|
+
## Tool Parameters
|
|
94
|
+
|
|
95
|
+
### Core Parameters
|
|
96
|
+
- `thought` (string, required): The thought content
|
|
97
|
+
- `thoughtNumber` (number, required): Position in sequence
|
|
98
|
+
- `totalThoughts` (number, required): Estimated total thoughts needed
|
|
99
|
+
- `nextThoughtNeeded` (boolean, required): Whether to continue thinking
|
|
100
|
+
- `mode` (string, optional): `sequential`, `shannon`, `mathematics`, `physics`, or `hybrid` (default)
|
|
101
|
+
|
|
102
|
+
### Mode-Specific Parameters
|
|
103
|
+
|
|
104
|
+
#### Sequential Mode
|
|
105
|
+
- `isRevision`: Whether this revises a previous thought
|
|
106
|
+
- `revisesThought`: ID of thought being revised
|
|
107
|
+
- `revisionReason`: Why the revision was needed
|
|
108
|
+
|
|
109
|
+
#### Shannon Mode
|
|
110
|
+
- `stage`: Which Shannon stage (problem_definition, constraints, model, proof, implementation)
|
|
111
|
+
- `uncertainty`: Confidence level (0-1)
|
|
112
|
+
- `dependencies`: IDs of dependent thoughts
|
|
113
|
+
- `assumptions`: Explicit assumptions
|
|
114
|
+
|
|
115
|
+
#### Mathematics Mode
|
|
116
|
+
- `thoughtType`: Specific type (axiom_definition, theorem_statement, proof_construction, etc.)
|
|
117
|
+
- `mathematicalModel`: LaTeX and symbolic representation
|
|
118
|
+
- `proofStrategy`: Type and steps of proof
|
|
119
|
+
- `logicalForm`: Premises, conclusion, inference rules
|
|
120
|
+
|
|
121
|
+
#### Physics Mode
|
|
122
|
+
- `thoughtType`: Specific type (tensor_formulation, symmetry_analysis, etc.)
|
|
123
|
+
- `tensorProperties`: Rank, components, symmetries, invariants
|
|
124
|
+
- `physicalInterpretation`: Quantity, units, conservation laws
|
|
125
|
+
- `dimensionalAnalysis`: Unit consistency checking
|
|
126
|
+
|
|
127
|
+
### Actions
|
|
128
|
+
- `add_thought` (default): Add a new thought to session
|
|
129
|
+
- `summarize`: Generate session summary
|
|
130
|
+
- `export`: Export session (requires `exportFormat`)
|
|
131
|
+
- `switch_mode`: Change thinking mode (requires `newMode`)
|
|
132
|
+
- `get_session`: Get session metadata
|
|
133
|
+
|
|
134
|
+
## Examples
|
|
135
|
+
|
|
136
|
+
### Example 1: Sequential Problem Solving
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
Thought 1: "Let me break down this optimization problem..."
|
|
140
|
+
- mode: sequential
|
|
141
|
+
- thoughtNumber: 1
|
|
142
|
+
- nextThoughtNeeded: true
|
|
143
|
+
|
|
144
|
+
Thought 2: "Building on my previous thought, I realize..."
|
|
145
|
+
- mode: sequential
|
|
146
|
+
- thoughtNumber: 2
|
|
147
|
+
- buildUpon: [thought1_id]
|
|
148
|
+
- nextThoughtNeeded: true
|
|
149
|
+
|
|
150
|
+
Thought 3: "Actually, let me revise my first approach..."
|
|
151
|
+
- mode: sequential
|
|
152
|
+
- isRevision: true
|
|
153
|
+
- revisesThought: thought1_id
|
|
154
|
+
- revisionReason: "Found a more efficient approach"
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Example 2: Mathematical Proof
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
Thought 1: "State the theorem: For all right triangles..."
|
|
161
|
+
- mode: mathematics
|
|
162
|
+
- thoughtType: theorem_statement
|
|
163
|
+
- mathematicalModel: { latex: "a^2 + b^2 = c^2", symbolic: "a**2 + b**2 == c**2" }
|
|
164
|
+
|
|
165
|
+
Thought 2: "Proof by construction..."
|
|
166
|
+
- mode: mathematics
|
|
167
|
+
- thoughtType: proof_construction
|
|
168
|
+
- proofStrategy: { type: "construction", steps: ["Draw square on each side", ...] }
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Example 3: Physics Tensor Analysis
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
Thought 1: "Define the electromagnetic field tensor"
|
|
175
|
+
- mode: physics
|
|
176
|
+
- thoughtType: tensor_formulation
|
|
177
|
+
- tensorProperties: {
|
|
178
|
+
rank: [2, 0],
|
|
179
|
+
components: "F^{μν} = ∂^μ A^ν - ∂^ν A^μ",
|
|
180
|
+
latex: "F^{\\mu\\nu}",
|
|
181
|
+
symmetries: ["antisymmetric"],
|
|
182
|
+
invariants: ["F_{μν}F^{μν}"],
|
|
183
|
+
transformation: "contravariant"
|
|
184
|
+
}
|
|
185
|
+
- physicalInterpretation: {
|
|
186
|
+
quantity: "Electromagnetic field strength",
|
|
187
|
+
units: "GeV^2",
|
|
188
|
+
conservationLaws: ["Energy-momentum", "Charge"]
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Development
|
|
193
|
+
|
|
194
|
+
### Building
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
npm install
|
|
198
|
+
npm run build
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Testing
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
npm test
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Type Checking
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
npm run typecheck
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Architecture
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
deepthinking-mcp/
|
|
217
|
+
├── src/
|
|
218
|
+
│ ├── types/ # Type definitions
|
|
219
|
+
│ │ ├── core.ts # Core thought types
|
|
220
|
+
│ │ └── session.ts # Session management types
|
|
221
|
+
│ ├── tools/ # MCP tool definitions
|
|
222
|
+
│ ├── session/ # Session manager
|
|
223
|
+
│ ├── modes/ # Mode implementations
|
|
224
|
+
│ ├── validation/ # Validation logic
|
|
225
|
+
│ └── index.ts # Main MCP server
|
|
226
|
+
├── tests/ # Test suite
|
|
227
|
+
├── docs/ # Documentation
|
|
228
|
+
└── examples/ # Usage examples
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Roadmap
|
|
232
|
+
|
|
233
|
+
### Phase 1 (Current)
|
|
234
|
+
- ✅ Core type system
|
|
235
|
+
- ✅ Session management
|
|
236
|
+
- ✅ Unified thinking tool
|
|
237
|
+
- ✅ Multiple mode support
|
|
238
|
+
|
|
239
|
+
### Phase 2 (Next)
|
|
240
|
+
- [ ] Validation engine
|
|
241
|
+
- [ ] Export to LaTeX/Jupyter
|
|
242
|
+
- [ ] Visualization (Mermaid diagrams)
|
|
243
|
+
- [ ] Math-MCP integration
|
|
244
|
+
|
|
245
|
+
### Phase 3 (Future)
|
|
246
|
+
- [ ] Persistence layer
|
|
247
|
+
- [ ] Collaborative thinking
|
|
248
|
+
- [ ] Pattern learning
|
|
249
|
+
- [ ] Plugin system
|
|
250
|
+
|
|
251
|
+
## Contributing
|
|
252
|
+
|
|
253
|
+
Contributions welcome! Please read our contributing guidelines and submit PRs.
|
|
254
|
+
|
|
255
|
+
## License
|
|
256
|
+
|
|
257
|
+
MIT
|
|
258
|
+
|
|
259
|
+
## Credits
|
|
260
|
+
|
|
261
|
+
Built upon:
|
|
262
|
+
- [sequential-thinking](https://github.com/modelcontextprotocol/servers/tree/main/src/sequentialthinking) by Anthropic
|
|
263
|
+
- [shannon-thinking](https://github.com/olaservo/shannon-thinking) by olaservo
|
|
264
|
+
- Enhanced for mathematical and physics reasoning by Daniel Simon Jr.
|
|
265
|
+
|
|
266
|
+
## Support
|
|
267
|
+
|
|
268
|
+
- GitHub Issues: [Report bugs or request features](https://github.com/danielsimonjr/deepthinking-mcp/issues)
|
|
269
|
+
- Documentation: [Full docs](https://github.com/danielsimonjr/deepthinking-mcp/tree/main/docs)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,629 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { randomUUID } from 'crypto';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
|
|
8
|
+
var ThinkingToolSchema = z.object({
|
|
9
|
+
sessionId: z.string().optional(),
|
|
10
|
+
mode: z.enum(["sequential", "shannon", "mathematics", "physics", "hybrid"]).default("hybrid"),
|
|
11
|
+
thought: z.string(),
|
|
12
|
+
thoughtNumber: z.number().int().positive(),
|
|
13
|
+
totalThoughts: z.number().int().positive(),
|
|
14
|
+
nextThoughtNeeded: z.boolean(),
|
|
15
|
+
isRevision: z.boolean().optional(),
|
|
16
|
+
revisesThought: z.string().optional(),
|
|
17
|
+
revisionReason: z.string().optional(),
|
|
18
|
+
branchFrom: z.string().optional(),
|
|
19
|
+
branchId: z.string().optional(),
|
|
20
|
+
stage: z.enum(["problem_definition", "constraints", "model", "proof", "implementation"]).optional(),
|
|
21
|
+
uncertainty: z.number().min(0).max(1).optional(),
|
|
22
|
+
dependencies: z.array(z.string()).optional(),
|
|
23
|
+
assumptions: z.array(z.string()).optional(),
|
|
24
|
+
thoughtType: z.string().optional(),
|
|
25
|
+
mathematicalModel: z.object({
|
|
26
|
+
latex: z.string(),
|
|
27
|
+
symbolic: z.string(),
|
|
28
|
+
ascii: z.string().optional()
|
|
29
|
+
}).optional(),
|
|
30
|
+
proofStrategy: z.object({
|
|
31
|
+
type: z.enum(["direct", "contradiction", "induction", "construction", "contrapositive"]),
|
|
32
|
+
steps: z.array(z.string())
|
|
33
|
+
}).optional(),
|
|
34
|
+
tensorProperties: z.object({
|
|
35
|
+
rank: z.tuple([z.number(), z.number()]),
|
|
36
|
+
components: z.string(),
|
|
37
|
+
latex: z.string(),
|
|
38
|
+
symmetries: z.array(z.string()),
|
|
39
|
+
invariants: z.array(z.string()),
|
|
40
|
+
transformation: z.enum(["covariant", "contravariant", "mixed"])
|
|
41
|
+
}).optional(),
|
|
42
|
+
physicalInterpretation: z.object({
|
|
43
|
+
quantity: z.string(),
|
|
44
|
+
units: z.string(),
|
|
45
|
+
conservationLaws: z.array(z.string())
|
|
46
|
+
}).optional(),
|
|
47
|
+
action: z.enum(["add_thought", "summarize", "export", "switch_mode", "get_session"]).default("add_thought"),
|
|
48
|
+
exportFormat: z.enum(["markdown", "latex", "json", "html", "jupyter"]).optional(),
|
|
49
|
+
newMode: z.enum(["sequential", "shannon", "mathematics", "physics", "hybrid"]).optional()
|
|
50
|
+
});
|
|
51
|
+
var thinkingTool = {
|
|
52
|
+
name: "deepthinking",
|
|
53
|
+
description: `Advanced deep thinking tool supporting multiple reasoning modes:
|
|
54
|
+
- sequential: Iterative refinement and exploration
|
|
55
|
+
- shannon: Systematic 5-stage problem-solving
|
|
56
|
+
- mathematics: Theorem proving and symbolic reasoning
|
|
57
|
+
- physics: Tensor mathematics and field theory
|
|
58
|
+
- hybrid: Intelligently combines multiple approaches
|
|
59
|
+
|
|
60
|
+
Choose the mode that best fits your problem type.`,
|
|
61
|
+
inputSchema: {
|
|
62
|
+
type: "object",
|
|
63
|
+
properties: {
|
|
64
|
+
sessionId: {
|
|
65
|
+
type: "string",
|
|
66
|
+
description: "Session ID (creates new if omitted)"
|
|
67
|
+
},
|
|
68
|
+
mode: {
|
|
69
|
+
type: "string",
|
|
70
|
+
enum: ["sequential", "shannon", "mathematics", "physics", "hybrid"],
|
|
71
|
+
description: "Thinking mode to use"
|
|
72
|
+
},
|
|
73
|
+
thought: {
|
|
74
|
+
type: "string",
|
|
75
|
+
description: "The thought content"
|
|
76
|
+
},
|
|
77
|
+
thoughtNumber: {
|
|
78
|
+
type: "integer",
|
|
79
|
+
minimum: 1,
|
|
80
|
+
description: "Position in sequence"
|
|
81
|
+
},
|
|
82
|
+
totalThoughts: {
|
|
83
|
+
type: "integer",
|
|
84
|
+
minimum: 1,
|
|
85
|
+
description: "Estimated total thoughts"
|
|
86
|
+
},
|
|
87
|
+
nextThoughtNeeded: {
|
|
88
|
+
type: "boolean",
|
|
89
|
+
description: "Should thinking continue?"
|
|
90
|
+
},
|
|
91
|
+
isRevision: {
|
|
92
|
+
type: "boolean",
|
|
93
|
+
description: "Whether this revises previous thinking"
|
|
94
|
+
},
|
|
95
|
+
revisesThought: {
|
|
96
|
+
type: "string",
|
|
97
|
+
description: "Which thought is being reconsidered"
|
|
98
|
+
},
|
|
99
|
+
revisionReason: {
|
|
100
|
+
type: "string",
|
|
101
|
+
description: "Reason for revision"
|
|
102
|
+
},
|
|
103
|
+
branchFrom: {
|
|
104
|
+
type: "string",
|
|
105
|
+
description: "Branching point thought"
|
|
106
|
+
},
|
|
107
|
+
branchId: {
|
|
108
|
+
type: "string",
|
|
109
|
+
description: "Branch identifier"
|
|
110
|
+
},
|
|
111
|
+
stage: {
|
|
112
|
+
type: "string",
|
|
113
|
+
enum: ["problem_definition", "constraints", "model", "proof", "implementation"],
|
|
114
|
+
description: "Shannon methodology stage"
|
|
115
|
+
},
|
|
116
|
+
uncertainty: {
|
|
117
|
+
type: "number",
|
|
118
|
+
minimum: 0,
|
|
119
|
+
maximum: 1,
|
|
120
|
+
description: "Uncertainty level (0-1)"
|
|
121
|
+
},
|
|
122
|
+
dependencies: {
|
|
123
|
+
type: "array",
|
|
124
|
+
items: { type: "string" },
|
|
125
|
+
description: "Dependencies on other thoughts"
|
|
126
|
+
},
|
|
127
|
+
assumptions: {
|
|
128
|
+
type: "array",
|
|
129
|
+
items: { type: "string" },
|
|
130
|
+
description: "Assumptions made"
|
|
131
|
+
},
|
|
132
|
+
thoughtType: {
|
|
133
|
+
type: "string",
|
|
134
|
+
description: "Type of mathematical thought"
|
|
135
|
+
},
|
|
136
|
+
mathematicalModel: {
|
|
137
|
+
type: "object",
|
|
138
|
+
properties: {
|
|
139
|
+
latex: { type: "string", description: "LaTeX representation" },
|
|
140
|
+
symbolic: { type: "string", description: "Symbolic representation" },
|
|
141
|
+
ascii: { type: "string", description: "ASCII representation" }
|
|
142
|
+
},
|
|
143
|
+
required: ["latex", "symbolic"]
|
|
144
|
+
},
|
|
145
|
+
proofStrategy: {
|
|
146
|
+
type: "object",
|
|
147
|
+
properties: {
|
|
148
|
+
type: {
|
|
149
|
+
type: "string",
|
|
150
|
+
enum: ["direct", "contradiction", "induction", "construction", "contrapositive"]
|
|
151
|
+
},
|
|
152
|
+
steps: {
|
|
153
|
+
type: "array",
|
|
154
|
+
items: { type: "string" }
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
required: ["type", "steps"]
|
|
158
|
+
},
|
|
159
|
+
tensorProperties: {
|
|
160
|
+
type: "object",
|
|
161
|
+
properties: {
|
|
162
|
+
rank: {
|
|
163
|
+
type: "array",
|
|
164
|
+
items: { type: "number" },
|
|
165
|
+
minItems: 2,
|
|
166
|
+
maxItems: 2
|
|
167
|
+
},
|
|
168
|
+
components: { type: "string" },
|
|
169
|
+
latex: { type: "string" },
|
|
170
|
+
symmetries: {
|
|
171
|
+
type: "array",
|
|
172
|
+
items: { type: "string" }
|
|
173
|
+
},
|
|
174
|
+
invariants: {
|
|
175
|
+
type: "array",
|
|
176
|
+
items: { type: "string" }
|
|
177
|
+
},
|
|
178
|
+
transformation: {
|
|
179
|
+
type: "string",
|
|
180
|
+
enum: ["covariant", "contravariant", "mixed"]
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
required: ["rank", "components", "latex", "symmetries", "invariants", "transformation"]
|
|
184
|
+
},
|
|
185
|
+
physicalInterpretation: {
|
|
186
|
+
type: "object",
|
|
187
|
+
properties: {
|
|
188
|
+
quantity: { type: "string" },
|
|
189
|
+
units: { type: "string" },
|
|
190
|
+
conservationLaws: {
|
|
191
|
+
type: "array",
|
|
192
|
+
items: { type: "string" }
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
required: ["quantity", "units", "conservationLaws"]
|
|
196
|
+
},
|
|
197
|
+
action: {
|
|
198
|
+
type: "string",
|
|
199
|
+
enum: ["add_thought", "summarize", "export", "switch_mode", "get_session"],
|
|
200
|
+
description: "Action to perform"
|
|
201
|
+
},
|
|
202
|
+
exportFormat: {
|
|
203
|
+
type: "string",
|
|
204
|
+
enum: ["markdown", "latex", "json", "html", "jupyter"],
|
|
205
|
+
description: "Export format"
|
|
206
|
+
},
|
|
207
|
+
newMode: {
|
|
208
|
+
type: "string",
|
|
209
|
+
enum: ["sequential", "shannon", "mathematics", "physics", "hybrid"],
|
|
210
|
+
description: "New mode for switch_mode action"
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
required: ["thought", "thoughtNumber", "totalThoughts", "nextThoughtNeeded"]
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
var DEFAULT_CONFIG = {
|
|
217
|
+
modeConfig: {
|
|
218
|
+
mode: "hybrid" /* HYBRID */,
|
|
219
|
+
strictValidation: false,
|
|
220
|
+
allowModeSwitch: true
|
|
221
|
+
},
|
|
222
|
+
enableAutoSave: true,
|
|
223
|
+
enableValidation: true,
|
|
224
|
+
enableVisualization: true,
|
|
225
|
+
integrations: {},
|
|
226
|
+
exportFormats: ["markdown", "latex", "json"],
|
|
227
|
+
autoExportOnComplete: false,
|
|
228
|
+
maxThoughtsInMemory: 1e3,
|
|
229
|
+
compressionThreshold: 500
|
|
230
|
+
};
|
|
231
|
+
var SessionManager = class {
|
|
232
|
+
activeSessions;
|
|
233
|
+
config;
|
|
234
|
+
constructor(config) {
|
|
235
|
+
this.activeSessions = /* @__PURE__ */ new Map();
|
|
236
|
+
this.config = config || {};
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Create a new thinking session
|
|
240
|
+
*/
|
|
241
|
+
async createSession(options = {}) {
|
|
242
|
+
const sessionId = randomUUID();
|
|
243
|
+
const now = /* @__PURE__ */ new Date();
|
|
244
|
+
const session = {
|
|
245
|
+
id: sessionId,
|
|
246
|
+
title: options.title || "Untitled Session",
|
|
247
|
+
mode: options.mode || "hybrid" /* HYBRID */,
|
|
248
|
+
domain: options.domain,
|
|
249
|
+
config: this.mergeConfig(options.config),
|
|
250
|
+
thoughts: [],
|
|
251
|
+
createdAt: now,
|
|
252
|
+
updatedAt: now,
|
|
253
|
+
author: options.author,
|
|
254
|
+
currentThoughtNumber: 0,
|
|
255
|
+
isComplete: false,
|
|
256
|
+
metrics: this.initializeMetrics(),
|
|
257
|
+
tags: [],
|
|
258
|
+
collaborators: options.author ? [options.author] : []
|
|
259
|
+
};
|
|
260
|
+
this.activeSessions.set(sessionId, session);
|
|
261
|
+
return session;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Get a session by ID
|
|
265
|
+
*/
|
|
266
|
+
async getSession(sessionId) {
|
|
267
|
+
return this.activeSessions.get(sessionId) || null;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Add a thought to a session
|
|
271
|
+
*/
|
|
272
|
+
async addThought(sessionId, thought) {
|
|
273
|
+
const session = this.activeSessions.get(sessionId);
|
|
274
|
+
if (!session) {
|
|
275
|
+
throw new Error(`Session ${sessionId} not found`);
|
|
276
|
+
}
|
|
277
|
+
thought.sessionId = sessionId;
|
|
278
|
+
thought.timestamp = /* @__PURE__ */ new Date();
|
|
279
|
+
session.thoughts.push(thought);
|
|
280
|
+
session.currentThoughtNumber = thought.thoughtNumber;
|
|
281
|
+
session.updatedAt = /* @__PURE__ */ new Date();
|
|
282
|
+
this.updateMetrics(session, thought);
|
|
283
|
+
if (!thought.nextThoughtNeeded) {
|
|
284
|
+
session.isComplete = true;
|
|
285
|
+
}
|
|
286
|
+
return session;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Update session mode
|
|
290
|
+
*/
|
|
291
|
+
async switchMode(sessionId, newMode, reason) {
|
|
292
|
+
const session = this.activeSessions.get(sessionId);
|
|
293
|
+
if (!session) {
|
|
294
|
+
throw new Error(`Session ${sessionId} not found`);
|
|
295
|
+
}
|
|
296
|
+
session.mode;
|
|
297
|
+
session.mode = newMode;
|
|
298
|
+
session.config.modeConfig.mode = newMode;
|
|
299
|
+
session.updatedAt = /* @__PURE__ */ new Date();
|
|
300
|
+
return session;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* List all sessions
|
|
304
|
+
*/
|
|
305
|
+
async listSessions() {
|
|
306
|
+
return Array.from(this.activeSessions.values()).map((session) => ({
|
|
307
|
+
id: session.id,
|
|
308
|
+
title: session.title,
|
|
309
|
+
createdAt: session.createdAt,
|
|
310
|
+
updatedAt: session.updatedAt,
|
|
311
|
+
thoughtCount: session.thoughts.length,
|
|
312
|
+
mode: session.mode,
|
|
313
|
+
isComplete: session.isComplete
|
|
314
|
+
}));
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Delete a session
|
|
318
|
+
*/
|
|
319
|
+
async deleteSession(sessionId) {
|
|
320
|
+
this.activeSessions.delete(sessionId);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Generate summary of session
|
|
324
|
+
*/
|
|
325
|
+
async generateSummary(sessionId) {
|
|
326
|
+
const session = this.activeSessions.get(sessionId);
|
|
327
|
+
if (!session) {
|
|
328
|
+
throw new Error(`Session ${sessionId} not found`);
|
|
329
|
+
}
|
|
330
|
+
let summary = `# ${session.title}
|
|
331
|
+
|
|
332
|
+
`;
|
|
333
|
+
summary += `Mode: ${session.mode}
|
|
334
|
+
`;
|
|
335
|
+
summary += `Total Thoughts: ${session.thoughts.length}
|
|
336
|
+
`;
|
|
337
|
+
summary += `Status: ${session.isComplete ? "Complete" : "In Progress"}
|
|
338
|
+
|
|
339
|
+
`;
|
|
340
|
+
summary += `## Key Thoughts:
|
|
341
|
+
|
|
342
|
+
`;
|
|
343
|
+
for (const thought of session.thoughts) {
|
|
344
|
+
summary += `${thought.thoughtNumber}. ${thought.content.substring(0, 100)}...
|
|
345
|
+
`;
|
|
346
|
+
}
|
|
347
|
+
return summary;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Merge configurations
|
|
351
|
+
*/
|
|
352
|
+
mergeConfig(userConfig) {
|
|
353
|
+
return {
|
|
354
|
+
...DEFAULT_CONFIG,
|
|
355
|
+
...this.config,
|
|
356
|
+
...userConfig
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Initialize metrics
|
|
361
|
+
*/
|
|
362
|
+
initializeMetrics() {
|
|
363
|
+
return {
|
|
364
|
+
totalThoughts: 0,
|
|
365
|
+
thoughtsByType: {},
|
|
366
|
+
averageUncertainty: 0,
|
|
367
|
+
revisionCount: 0,
|
|
368
|
+
timeSpent: 0,
|
|
369
|
+
dependencyDepth: 0
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Update session metrics
|
|
374
|
+
*/
|
|
375
|
+
updateMetrics(session, thought) {
|
|
376
|
+
const metrics = session.metrics;
|
|
377
|
+
metrics.totalThoughts = session.thoughts.length;
|
|
378
|
+
if (thought.isRevision) {
|
|
379
|
+
metrics.revisionCount++;
|
|
380
|
+
}
|
|
381
|
+
metrics.timeSpent = session.updatedAt.getTime() - session.createdAt.getTime();
|
|
382
|
+
if ("uncertainty" in thought) {
|
|
383
|
+
const totalUncertainty = session.thoughts.filter((t) => "uncertainty" in t).reduce((sum, t) => sum + t.uncertainty, 0);
|
|
384
|
+
const thoughtsWithUncertainty = session.thoughts.filter((t) => "uncertainty" in t).length;
|
|
385
|
+
metrics.averageUncertainty = thoughtsWithUncertainty > 0 ? totalUncertainty / thoughtsWithUncertainty : 0;
|
|
386
|
+
}
|
|
387
|
+
if ("dependencies" in thought) {
|
|
388
|
+
const deps = thought.dependencies;
|
|
389
|
+
if (deps.length > metrics.dependencyDepth) {
|
|
390
|
+
metrics.dependencyDepth = deps.length;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
// src/index.ts
|
|
397
|
+
var server = new Server(
|
|
398
|
+
{
|
|
399
|
+
name: "deepthinking-mcp",
|
|
400
|
+
version: "1.0.0"
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
capabilities: {
|
|
404
|
+
tools: {}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
);
|
|
408
|
+
var sessionManager = new SessionManager();
|
|
409
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
410
|
+
return {
|
|
411
|
+
tools: [thinkingTool]
|
|
412
|
+
};
|
|
413
|
+
});
|
|
414
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
415
|
+
const { name, arguments: args } = request.params;
|
|
416
|
+
if (name === "deepthinking") {
|
|
417
|
+
try {
|
|
418
|
+
const input = ThinkingToolSchema.parse(args);
|
|
419
|
+
switch (input.action) {
|
|
420
|
+
case "add_thought":
|
|
421
|
+
return await handleAddThought(input);
|
|
422
|
+
case "summarize":
|
|
423
|
+
return await handleSummarize(input);
|
|
424
|
+
case "export":
|
|
425
|
+
return await handleExport(input);
|
|
426
|
+
case "switch_mode":
|
|
427
|
+
return await handleSwitchMode(input);
|
|
428
|
+
case "get_session":
|
|
429
|
+
return await handleGetSession(input);
|
|
430
|
+
default:
|
|
431
|
+
throw new Error(`Unknown action: ${input.action}`);
|
|
432
|
+
}
|
|
433
|
+
} catch (error) {
|
|
434
|
+
return {
|
|
435
|
+
content: [
|
|
436
|
+
{
|
|
437
|
+
type: "text",
|
|
438
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
439
|
+
}
|
|
440
|
+
],
|
|
441
|
+
isError: true
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
446
|
+
});
|
|
447
|
+
async function handleAddThought(input) {
|
|
448
|
+
let sessionId = input.sessionId;
|
|
449
|
+
if (!sessionId) {
|
|
450
|
+
const session2 = await sessionManager.createSession({
|
|
451
|
+
mode: input.mode,
|
|
452
|
+
title: `Thinking Session ${(/* @__PURE__ */ new Date()).toISOString()}`
|
|
453
|
+
});
|
|
454
|
+
sessionId = session2.id;
|
|
455
|
+
}
|
|
456
|
+
const thought = createThought(input, sessionId);
|
|
457
|
+
const session = await sessionManager.addThought(sessionId, thought);
|
|
458
|
+
return {
|
|
459
|
+
content: [
|
|
460
|
+
{
|
|
461
|
+
type: "text",
|
|
462
|
+
text: JSON.stringify({
|
|
463
|
+
sessionId: session.id,
|
|
464
|
+
thoughtId: thought.id,
|
|
465
|
+
thoughtNumber: thought.thoughtNumber,
|
|
466
|
+
mode: thought.mode,
|
|
467
|
+
nextThoughtNeeded: thought.nextThoughtNeeded,
|
|
468
|
+
sessionComplete: session.isComplete,
|
|
469
|
+
totalThoughts: session.thoughts.length
|
|
470
|
+
}, null, 2)
|
|
471
|
+
}
|
|
472
|
+
]
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
async function handleSummarize(input) {
|
|
476
|
+
if (!input.sessionId) {
|
|
477
|
+
throw new Error("sessionId required for summarize action");
|
|
478
|
+
}
|
|
479
|
+
const summary = await sessionManager.generateSummary(input.sessionId);
|
|
480
|
+
return {
|
|
481
|
+
content: [
|
|
482
|
+
{
|
|
483
|
+
type: "text",
|
|
484
|
+
text: summary
|
|
485
|
+
}
|
|
486
|
+
]
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
async function handleExport(input) {
|
|
490
|
+
if (!input.sessionId) {
|
|
491
|
+
throw new Error("sessionId required for export action");
|
|
492
|
+
}
|
|
493
|
+
const session = await sessionManager.getSession(input.sessionId);
|
|
494
|
+
if (!session) {
|
|
495
|
+
throw new Error(`Session ${input.sessionId} not found`);
|
|
496
|
+
}
|
|
497
|
+
const exported = JSON.stringify(session, null, 2);
|
|
498
|
+
return {
|
|
499
|
+
content: [
|
|
500
|
+
{
|
|
501
|
+
type: "text",
|
|
502
|
+
text: exported
|
|
503
|
+
}
|
|
504
|
+
]
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
async function handleSwitchMode(input) {
|
|
508
|
+
if (!input.sessionId || !input.newMode) {
|
|
509
|
+
throw new Error("sessionId and newMode required for switch_mode action");
|
|
510
|
+
}
|
|
511
|
+
const session = await sessionManager.switchMode(
|
|
512
|
+
input.sessionId,
|
|
513
|
+
input.newMode,
|
|
514
|
+
"User requested mode switch"
|
|
515
|
+
);
|
|
516
|
+
return {
|
|
517
|
+
content: [
|
|
518
|
+
{
|
|
519
|
+
type: "text",
|
|
520
|
+
text: `Switched session ${session.id} to ${session.mode} mode`
|
|
521
|
+
}
|
|
522
|
+
]
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
async function handleGetSession(input) {
|
|
526
|
+
if (!input.sessionId) {
|
|
527
|
+
throw new Error("sessionId required for get_session action");
|
|
528
|
+
}
|
|
529
|
+
const session = await sessionManager.getSession(input.sessionId);
|
|
530
|
+
if (!session) {
|
|
531
|
+
throw new Error(`Session ${input.sessionId} not found`);
|
|
532
|
+
}
|
|
533
|
+
return {
|
|
534
|
+
content: [
|
|
535
|
+
{
|
|
536
|
+
type: "text",
|
|
537
|
+
text: JSON.stringify({
|
|
538
|
+
id: session.id,
|
|
539
|
+
title: session.title,
|
|
540
|
+
mode: session.mode,
|
|
541
|
+
thoughtCount: session.thoughts.length,
|
|
542
|
+
isComplete: session.isComplete,
|
|
543
|
+
metrics: session.metrics
|
|
544
|
+
}, null, 2)
|
|
545
|
+
}
|
|
546
|
+
]
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
function createThought(input, sessionId) {
|
|
550
|
+
const baseThought = {
|
|
551
|
+
id: randomUUID(),
|
|
552
|
+
sessionId,
|
|
553
|
+
thoughtNumber: input.thoughtNumber,
|
|
554
|
+
totalThoughts: input.totalThoughts,
|
|
555
|
+
content: input.thought,
|
|
556
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
557
|
+
nextThoughtNeeded: input.nextThoughtNeeded,
|
|
558
|
+
isRevision: input.isRevision,
|
|
559
|
+
revisesThought: input.revisesThought
|
|
560
|
+
};
|
|
561
|
+
switch (input.mode) {
|
|
562
|
+
case "sequential":
|
|
563
|
+
return {
|
|
564
|
+
...baseThought,
|
|
565
|
+
mode: "sequential" /* SEQUENTIAL */,
|
|
566
|
+
revisionReason: input.revisionReason,
|
|
567
|
+
branchFrom: input.branchFrom,
|
|
568
|
+
branchId: input.branchId
|
|
569
|
+
};
|
|
570
|
+
case "shannon":
|
|
571
|
+
return {
|
|
572
|
+
...baseThought,
|
|
573
|
+
mode: "shannon" /* SHANNON */,
|
|
574
|
+
stage: input.stage || "problem_definition" /* PROBLEM_DEFINITION */,
|
|
575
|
+
uncertainty: input.uncertainty || 0.5,
|
|
576
|
+
dependencies: input.dependencies || [],
|
|
577
|
+
assumptions: input.assumptions || []
|
|
578
|
+
};
|
|
579
|
+
case "mathematics":
|
|
580
|
+
return {
|
|
581
|
+
...baseThought,
|
|
582
|
+
mode: "mathematics" /* MATHEMATICS */,
|
|
583
|
+
thoughtType: input.thoughtType,
|
|
584
|
+
mathematicalModel: input.mathematicalModel,
|
|
585
|
+
proofStrategy: input.proofStrategy,
|
|
586
|
+
dependencies: input.dependencies || [],
|
|
587
|
+
assumptions: input.assumptions || [],
|
|
588
|
+
uncertainty: input.uncertainty || 0.5
|
|
589
|
+
};
|
|
590
|
+
case "physics":
|
|
591
|
+
return {
|
|
592
|
+
...baseThought,
|
|
593
|
+
mode: "physics" /* PHYSICS */,
|
|
594
|
+
thoughtType: input.thoughtType,
|
|
595
|
+
tensorProperties: input.tensorProperties,
|
|
596
|
+
physicalInterpretation: input.physicalInterpretation,
|
|
597
|
+
dependencies: input.dependencies || [],
|
|
598
|
+
assumptions: input.assumptions || [],
|
|
599
|
+
uncertainty: input.uncertainty || 0.5
|
|
600
|
+
};
|
|
601
|
+
case "hybrid":
|
|
602
|
+
default:
|
|
603
|
+
return {
|
|
604
|
+
...baseThought,
|
|
605
|
+
mode: "hybrid" /* HYBRID */,
|
|
606
|
+
thoughtType: input.thoughtType,
|
|
607
|
+
stage: input.stage,
|
|
608
|
+
uncertainty: input.uncertainty,
|
|
609
|
+
dependencies: input.dependencies,
|
|
610
|
+
assumptions: input.assumptions,
|
|
611
|
+
mathematicalModel: input.mathematicalModel,
|
|
612
|
+
tensorProperties: input.tensorProperties,
|
|
613
|
+
physicalInterpretation: input.physicalInterpretation,
|
|
614
|
+
primaryMode: input.mode,
|
|
615
|
+
secondaryFeatures: []
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
async function main() {
|
|
620
|
+
const transport = new StdioServerTransport();
|
|
621
|
+
await server.connect(transport);
|
|
622
|
+
console.error("DeepThinking MCP server running on stdio");
|
|
623
|
+
}
|
|
624
|
+
main().catch((error) => {
|
|
625
|
+
console.error("Fatal error:", error);
|
|
626
|
+
process.exit(1);
|
|
627
|
+
});
|
|
628
|
+
//# sourceMappingURL=index.js.map
|
|
629
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tools/thinking.ts","../src/session/manager.ts","../src/index.ts"],"names":["session","randomUUID"],"mappings":";;;;;;;AAUO,IAAM,kBAAA,GAAqB,EAAE,MAAA,CAAO;AAAA,EACzC,SAAA,EAAW,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EAC/B,IAAA,EAAM,CAAA,CAAE,IAAA,CAAK,CAAC,YAAA,EAAc,SAAA,EAAW,aAAA,EAAe,SAAA,EAAW,QAAQ,CAAC,CAAA,CAAE,OAAA,CAAQ,QAAQ,CAAA;AAAA,EAC5F,OAAA,EAAS,EAAE,MAAA,EAAO;AAAA,EAClB,eAAe,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,QAAA,EAAS;AAAA,EACzC,eAAe,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,QAAA,EAAS;AAAA,EACzC,iBAAA,EAAmB,EAAE,OAAA,EAAQ;AAAA,EAC7B,UAAA,EAAY,CAAA,CAAE,OAAA,EAAQ,CAAE,QAAA,EAAS;A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SAAS,CAAA;AAC9B,EAAA,OAAA,CAAQ,MAAM,0CAA0C,CAAA;AAC1D;AAEA,IAAA,EAAK,CAAE,KAAA,CAAM,CAAC,KAAA,KAAU;AACtB,EAAA,OAAA,CAAQ,KAAA,CAAM,gBAAgB,KAAK,CAAA;AACnC,EAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAChB,CAAC,CAAA","file":"index.js","sourcesContent":["/**\n * Unified thinking tool for DeepThinking MCP\n * Supports all thinking modes in one tool\n */\n\nimport { z } from 'zod';\n\n/**\n * Zod schema for runtime validation (internal use)\n */\nexport const ThinkingToolSchema = z.object({\n sessionId: z.string().optional(),\n mode: z.enum(['sequential', 'shannon', 'mathematics', 'physics', 'hybrid']).default('hybrid'),\n thought: z.string(),\n thoughtNumber: z.number().int().positive(),\n totalThoughts: z.number().int().positive(),\n nextThoughtNeeded: z.boolean(),\n isRevision: z.boolean().optional(),\n revisesThought: z.string().optional(),\n revisionReason: z.string().optional(),\n branchFrom: z.string().optional(),\n branchId: z.string().optional(),\n stage: z.enum(['problem_definition', 'constraints', 'model', 'proof', 'implementation']).optional(),\n uncertainty: z.number().min(0).max(1).optional(),\n dependencies: z.array(z.string()).optional(),\n assumptions: z.array(z.string()).optional(),\n thoughtType: z.string().optional(),\n mathematicalModel: z.object({\n latex: z.string(),\n symbolic: z.string(),\n ascii: z.string().optional(),\n }).optional(),\n proofStrategy: z.object({\n type: z.enum(['direct', 'contradiction', 'induction', 'construction', 'contrapositive']),\n steps: z.array(z.string()),\n }).optional(),\n tensorProperties: z.object({\n rank: z.tuple([z.number(), z.number()]),\n components: z.string(),\n latex: z.string(),\n symmetries: z.array(z.string()),\n invariants: z.array(z.string()),\n transformation: z.enum(['covariant', 'contravariant', 'mixed']),\n }).optional(),\n physicalInterpretation: z.object({\n quantity: z.string(),\n units: z.string(),\n conservationLaws: z.array(z.string()),\n }).optional(),\n action: z.enum(['add_thought', 'summarize', 'export', 'switch_mode', 'get_session']).default('add_thought'),\n exportFormat: z.enum(['markdown', 'latex', 'json', 'html', 'jupyter']).optional(),\n newMode: z.enum(['sequential', 'shannon', 'mathematics', 'physics', 'hybrid']).optional(),\n});\n\nexport type ThinkingToolInput = z.infer<typeof ThinkingToolSchema>;\n\n/**\n * Tool definition using plain JSON Schema (MCP standard format)\n */\nexport const thinkingTool = {\n name: 'deepthinking',\n description: `Advanced deep thinking tool supporting multiple reasoning modes:\n- sequential: Iterative refinement and exploration\n- shannon: Systematic 5-stage problem-solving\n- mathematics: Theorem proving and symbolic reasoning\n- physics: Tensor mathematics and field theory\n- hybrid: Intelligently combines multiple approaches\n\nChoose the mode that best fits your problem type.`,\n inputSchema: {\n type: \"object\",\n properties: {\n sessionId: {\n type: \"string\",\n description: \"Session ID (creates new if omitted)\"\n },\n mode: {\n type: \"string\",\n enum: [\"sequential\", \"shannon\", \"mathematics\", \"physics\", \"hybrid\"],\n description: \"Thinking mode to use\"\n },\n thought: {\n type: \"string\",\n description: \"The thought content\"\n },\n thoughtNumber: {\n type: \"integer\",\n minimum: 1,\n description: \"Position in sequence\"\n },\n totalThoughts: {\n type: \"integer\",\n minimum: 1,\n description: \"Estimated total thoughts\"\n },\n nextThoughtNeeded: {\n type: \"boolean\",\n description: \"Should thinking continue?\"\n },\n isRevision: {\n type: \"boolean\",\n description: \"Whether this revises previous thinking\"\n },\n revisesThought: {\n type: \"string\",\n description: \"Which thought is being reconsidered\"\n },\n revisionReason: {\n type: \"string\",\n description: \"Reason for revision\"\n },\n branchFrom: {\n type: \"string\",\n description: \"Branching point thought\"\n },\n branchId: {\n type: \"string\",\n description: \"Branch identifier\"\n },\n stage: {\n type: \"string\",\n enum: [\"problem_definition\", \"constraints\", \"model\", \"proof\", \"implementation\"],\n description: \"Shannon methodology stage\"\n },\n uncertainty: {\n type: \"number\",\n minimum: 0,\n maximum: 1,\n description: \"Uncertainty level (0-1)\"\n },\n dependencies: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"Dependencies on other thoughts\"\n },\n assumptions: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"Assumptions made\"\n },\n thoughtType: {\n type: \"string\",\n description: \"Type of mathematical thought\"\n },\n mathematicalModel: {\n type: \"object\",\n properties: {\n latex: { type: \"string\", description: \"LaTeX representation\" },\n symbolic: { type: \"string\", description: \"Symbolic representation\" },\n ascii: { type: \"string\", description: \"ASCII representation\" }\n },\n required: [\"latex\", \"symbolic\"]\n },\n proofStrategy: {\n type: \"object\",\n properties: {\n type: {\n type: \"string\",\n enum: [\"direct\", \"contradiction\", \"induction\", \"construction\", \"contrapositive\"]\n },\n steps: {\n type: \"array\",\n items: { type: \"string\" }\n }\n },\n required: [\"type\", \"steps\"]\n },\n tensorProperties: {\n type: \"object\",\n properties: {\n rank: {\n type: \"array\",\n items: { type: \"number\" },\n minItems: 2,\n maxItems: 2\n },\n components: { type: \"string\" },\n latex: { type: \"string\" },\n symmetries: {\n type: \"array\",\n items: { type: \"string\" }\n },\n invariants: {\n type: \"array\",\n items: { type: \"string\" }\n },\n transformation: {\n type: \"string\",\n enum: [\"covariant\", \"contravariant\", \"mixed\"]\n }\n },\n required: [\"rank\", \"components\", \"latex\", \"symmetries\", \"invariants\", \"transformation\"]\n },\n physicalInterpretation: {\n type: \"object\",\n properties: {\n quantity: { type: \"string\" },\n units: { type: \"string\" },\n conservationLaws: {\n type: \"array\",\n items: { type: \"string\" }\n }\n },\n required: [\"quantity\", \"units\", \"conservationLaws\"]\n },\n action: {\n type: \"string\",\n enum: [\"add_thought\", \"summarize\", \"export\", \"switch_mode\", \"get_session\"],\n description: \"Action to perform\"\n },\n exportFormat: {\n type: \"string\",\n enum: [\"markdown\", \"latex\", \"json\", \"html\", \"jupyter\"],\n description: \"Export format\"\n },\n newMode: {\n type: \"string\",\n enum: [\"sequential\", \"shannon\", \"mathematics\", \"physics\", \"hybrid\"],\n description: \"New mode for switch_mode action\"\n }\n },\n required: [\"thought\", \"thoughtNumber\", \"totalThoughts\", \"nextThoughtNeeded\"]\n }\n};\n","/**\n * Session Manager for DeepThinking MCP\n * Manages thinking sessions, persistence, and analytics\n */\n\nimport { randomUUID } from 'crypto';\nimport {\n ThinkingSession,\n SessionConfig,\n SessionMetrics,\n SessionMetadata,\n Thought,\n ThinkingMode,\n ExportFormat\n} from '../types/index.js';\n\n/**\n * Default session configuration\n */\nconst DEFAULT_CONFIG: SessionConfig = {\n modeConfig: {\n mode: ThinkingMode.HYBRID,\n strictValidation: false,\n allowModeSwitch: true\n },\n enableAutoSave: true,\n enableValidation: true,\n enableVisualization: true,\n integrations: {},\n exportFormats: ['markdown', 'latex', 'json'],\n autoExportOnComplete: false,\n maxThoughtsInMemory: 1000,\n compressionThreshold: 500\n};\n\n/**\n * Session Manager\n */\nexport class SessionManager {\n private activeSessions: Map<string, ThinkingSession>;\n private config: Partial<SessionConfig>;\n\n constructor(config?: Partial<SessionConfig>) {\n this.activeSessions = new Map();\n this.config = config || {};\n }\n\n /**\n * Create a new thinking session\n */\n async createSession(options: {\n title?: string;\n mode?: ThinkingMode;\n domain?: string;\n author?: string;\n config?: Partial<SessionConfig>;\n } = {}): Promise<ThinkingSession> {\n const sessionId = randomUUID();\n const now = new Date();\n\n const session: ThinkingSession = {\n id: sessionId,\n title: options.title || 'Untitled Session',\n mode: options.mode || ThinkingMode.HYBRID,\n domain: options.domain,\n config: this.mergeConfig(options.config),\n thoughts: [],\n createdAt: now,\n updatedAt: now,\n author: options.author,\n currentThoughtNumber: 0,\n isComplete: false,\n metrics: this.initializeMetrics(),\n tags: [],\n collaborators: options.author ? [options.author] : []\n };\n\n this.activeSessions.set(sessionId, session);\n return session;\n }\n\n /**\n * Get a session by ID\n */\n async getSession(sessionId: string): Promise<ThinkingSession | null> {\n return this.activeSessions.get(sessionId) || null;\n }\n\n /**\n * Add a thought to a session\n */\n async addThought(sessionId: string, thought: Thought): Promise<ThinkingSession> {\n const session = this.activeSessions.get(sessionId);\n if (!session) {\n throw new Error(`Session ${sessionId} not found`);\n }\n\n // Update thought with session metadata\n thought.sessionId = sessionId;\n thought.timestamp = new Date();\n\n // Add thought to session\n session.thoughts.push(thought);\n session.currentThoughtNumber = thought.thoughtNumber;\n session.updatedAt = new Date();\n\n // Update metrics\n this.updateMetrics(session, thought);\n\n // Check if session is complete\n if (!thought.nextThoughtNeeded) {\n session.isComplete = true;\n }\n\n return session;\n }\n\n /**\n * Update session mode\n */\n async switchMode(\n sessionId: string,\n newMode: ThinkingMode,\n reason?: string\n ): Promise<ThinkingSession> {\n const session = this.activeSessions.get(sessionId);\n if (!session) {\n throw new Error(`Session ${sessionId} not found`);\n }\n\n const oldMode = session.mode;\n session.mode = newMode;\n session.config.modeConfig.mode = newMode;\n session.updatedAt = new Date();\n\n return session;\n }\n\n /**\n * List all sessions\n */\n async listSessions(): Promise<SessionMetadata[]> {\n return Array.from(this.activeSessions.values()).map(session => ({\n id: session.id,\n title: session.title,\n createdAt: session.createdAt,\n updatedAt: session.updatedAt,\n thoughtCount: session.thoughts.length,\n mode: session.mode,\n isComplete: session.isComplete\n }));\n }\n\n /**\n * Delete a session\n */\n async deleteSession(sessionId: string): Promise<void> {\n this.activeSessions.delete(sessionId);\n }\n\n /**\n * Generate summary of session\n */\n async generateSummary(sessionId: string): Promise<string> {\n const session = this.activeSessions.get(sessionId);\n if (!session) {\n throw new Error(`Session ${sessionId} not found`);\n }\n\n let summary = `# ${session.title}\\n\\n`;\n summary += `Mode: ${session.mode}\\n`;\n summary += `Total Thoughts: ${session.thoughts.length}\\n`;\n summary += `Status: ${session.isComplete ? 'Complete' : 'In Progress'}\\n\\n`;\n\n summary += `## Key Thoughts:\\n\\n`;\n for (const thought of session.thoughts) {\n summary += `${thought.thoughtNumber}. ${thought.content.substring(0, 100)}...\\n`;\n }\n\n return summary;\n }\n\n /**\n * Merge configurations\n */\n private mergeConfig(userConfig?: Partial<SessionConfig>): SessionConfig {\n return {\n ...DEFAULT_CONFIG,\n ...this.config,\n ...userConfig\n } as SessionConfig;\n }\n\n /**\n * Initialize metrics\n */\n private initializeMetrics(): SessionMetrics {\n return {\n totalThoughts: 0,\n thoughtsByType: {},\n averageUncertainty: 0,\n revisionCount: 0,\n timeSpent: 0,\n dependencyDepth: 0\n };\n }\n\n /**\n * Update session metrics\n */\n private updateMetrics(session: ThinkingSession, thought: Thought): void {\n const metrics = session.metrics;\n\n // Update total thoughts\n metrics.totalThoughts = session.thoughts.length;\n\n // Update revision count\n if (thought.isRevision) {\n metrics.revisionCount++;\n }\n\n // Update time spent (in milliseconds)\n metrics.timeSpent = session.updatedAt.getTime() - session.createdAt.getTime();\n\n // Update average uncertainty (for modes that have uncertainty)\n if ('uncertainty' in thought) {\n const totalUncertainty = session.thoughts\n .filter(t => 'uncertainty' in t)\n .reduce((sum, t) => sum + (t as any).uncertainty, 0);\n const thoughtsWithUncertainty = session.thoughts.filter(t => 'uncertainty' in t).length;\n metrics.averageUncertainty = thoughtsWithUncertainty > 0\n ? totalUncertainty / thoughtsWithUncertainty\n : 0;\n }\n\n // Update dependency depth\n if ('dependencies' in thought) {\n const deps = (thought as any).dependencies as string[];\n if (deps.length > metrics.dependencyDepth) {\n metrics.dependencyDepth = deps.length;\n }\n }\n }\n}\n","#!/usr/bin/env node\n\n/**\n * DeepThinking MCP Server\n * Unified deep thinking server combining sequential, Shannon, and mathematical reasoning\n */\n\nimport { Server } from '@modelcontextprotocol/sdk/server/index.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n} from '@modelcontextprotocol/sdk/types.js';\nimport { randomUUID } from 'crypto';\n\nimport { thinkingTool, ThinkingToolInput, ThinkingToolSchema } from './tools/thinking.js';\nimport { SessionManager } from './session/index.js';\nimport {\n ThinkingMode,\n ShannonStage,\n SequentialThought,\n ShannonThought,\n MathematicsThought,\n PhysicsThought,\n HybridThought,\n} from './types/index.js';\n\nconst server = new Server(\n {\n name: 'deepthinking-mcp',\n version: '1.0.0',\n },\n {\n capabilities: {\n tools: {},\n },\n }\n);\n\nconst sessionManager = new SessionManager();\n\nserver.setRequestHandler(ListToolsRequestSchema, async () => {\n return {\n tools: [thinkingTool],\n };\n});\n\nserver.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n if (name === 'deepthinking') {\n try {\n const input = ThinkingToolSchema.parse(args) as ThinkingToolInput;\n\n switch (input.action) {\n case 'add_thought':\n return await handleAddThought(input);\n case 'summarize':\n return await handleSummarize(input);\n case 'export':\n return await handleExport(input);\n case 'switch_mode':\n return await handleSwitchMode(input);\n case 'get_session':\n return await handleGetSession(input);\n default:\n throw new Error(`Unknown action: ${input.action}`);\n }\n } catch (error) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: ${error instanceof Error ? error.message : String(error)}`,\n },\n ],\n isError: true,\n };\n }\n }\n\n throw new Error(`Unknown tool: ${name}`);\n});\n\nasync function handleAddThought(input: ThinkingToolInput) {\n let sessionId = input.sessionId;\n if (!sessionId) {\n const session = await sessionManager.createSession({\n mode: input.mode as ThinkingMode,\n title: `Thinking Session ${new Date().toISOString()}`,\n });\n sessionId = session.id;\n }\n\n const thought = createThought(input, sessionId);\n const session = await sessionManager.addThought(sessionId, thought);\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n sessionId: session.id,\n thoughtId: thought.id,\n thoughtNumber: thought.thoughtNumber,\n mode: thought.mode,\n nextThoughtNeeded: thought.nextThoughtNeeded,\n sessionComplete: session.isComplete,\n totalThoughts: session.thoughts.length,\n }, null, 2),\n },\n ],\n };\n}\n\nasync function handleSummarize(input: ThinkingToolInput) {\n if (!input.sessionId) {\n throw new Error('sessionId required for summarize action');\n }\n\n const summary = await sessionManager.generateSummary(input.sessionId);\n\n return {\n content: [\n {\n type: 'text',\n text: summary,\n },\n ],\n };\n}\n\nasync function handleExport(input: ThinkingToolInput) {\n if (!input.sessionId) {\n throw new Error('sessionId required for export action');\n }\n\n const session = await sessionManager.getSession(input.sessionId);\n if (!session) {\n throw new Error(`Session ${input.sessionId} not found`);\n }\n\n const exported = JSON.stringify(session, null, 2);\n\n return {\n content: [\n {\n type: 'text',\n text: exported,\n },\n ],\n };\n}\n\nasync function handleSwitchMode(input: ThinkingToolInput) {\n if (!input.sessionId || !input.newMode) {\n throw new Error('sessionId and newMode required for switch_mode action');\n }\n\n const session = await sessionManager.switchMode(\n input.sessionId,\n input.newMode as ThinkingMode,\n 'User requested mode switch'\n );\n\n return {\n content: [\n {\n type: 'text',\n text: `Switched session ${session.id} to ${session.mode} mode`,\n },\n ],\n };\n}\n\nasync function handleGetSession(input: ThinkingToolInput) {\n if (!input.sessionId) {\n throw new Error('sessionId required for get_session action');\n }\n\n const session = await sessionManager.getSession(input.sessionId);\n if (!session) {\n throw new Error(`Session ${input.sessionId} not found`);\n }\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({\n id: session.id,\n title: session.title,\n mode: session.mode,\n thoughtCount: session.thoughts.length,\n isComplete: session.isComplete,\n metrics: session.metrics,\n }, null, 2),\n },\n ],\n };\n}\n\nfunction createThought(input: ThinkingToolInput, sessionId: string) {\n const baseThought = {\n id: randomUUID(),\n sessionId,\n thoughtNumber: input.thoughtNumber,\n totalThoughts: input.totalThoughts,\n content: input.thought,\n timestamp: new Date(),\n nextThoughtNeeded: input.nextThoughtNeeded,\n isRevision: input.isRevision,\n revisesThought: input.revisesThought,\n };\n\n switch (input.mode) {\n case 'sequential':\n return {\n ...baseThought,\n mode: ThinkingMode.SEQUENTIAL,\n revisionReason: input.revisionReason,\n branchFrom: input.branchFrom,\n branchId: input.branchId,\n } as SequentialThought;\n\n case 'shannon':\n return {\n ...baseThought,\n mode: ThinkingMode.SHANNON,\n stage: (input.stage as ShannonStage) || ShannonStage.PROBLEM_DEFINITION,\n uncertainty: input.uncertainty || 0.5,\n dependencies: input.dependencies || [],\n assumptions: input.assumptions || [],\n } as ShannonThought;\n\n case 'mathematics':\n return {\n ...baseThought,\n mode: ThinkingMode.MATHEMATICS,\n thoughtType: input.thoughtType as any,\n mathematicalModel: input.mathematicalModel,\n proofStrategy: input.proofStrategy,\n dependencies: input.dependencies || [],\n assumptions: input.assumptions || [],\n uncertainty: input.uncertainty || 0.5,\n } as MathematicsThought;\n\n case 'physics':\n return {\n ...baseThought,\n mode: ThinkingMode.PHYSICS,\n thoughtType: input.thoughtType as any,\n tensorProperties: input.tensorProperties,\n physicalInterpretation: input.physicalInterpretation,\n dependencies: input.dependencies || [],\n assumptions: input.assumptions || [],\n uncertainty: input.uncertainty || 0.5,\n } as PhysicsThought;\n\n case 'hybrid':\n default:\n return {\n ...baseThought,\n mode: ThinkingMode.HYBRID,\n thoughtType: input.thoughtType as any,\n stage: input.stage as ShannonStage,\n uncertainty: input.uncertainty,\n dependencies: input.dependencies,\n assumptions: input.assumptions,\n mathematicalModel: input.mathematicalModel,\n tensorProperties: input.tensorProperties,\n physicalInterpretation: input.physicalInterpretation,\n primaryMode: input.mode as any,\n secondaryFeatures: [],\n } as HybridThought;\n }\n}\n\nasync function main() {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n console.error('DeepThinking MCP server running on stdio');\n}\n\nmain().catch((error) => {\n console.error('Fatal error:', error);\n process.exit(1);\n});\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "deepthinking-mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Unified deep thinking MCP server combining sequential, Shannon, and mathematical reasoning with physics support",
|
|
5
|
+
"author": "Daniel Simon Jr.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"bin": {
|
|
9
|
+
"deepthinking-mcp": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"files": [
|
|
14
|
+
"dist/",
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsup",
|
|
20
|
+
"dev": "tsup --watch",
|
|
21
|
+
"test": "vitest",
|
|
22
|
+
"test:coverage": "vitest --coverage",
|
|
23
|
+
"lint": "eslint src/",
|
|
24
|
+
"format": "prettier --write src/",
|
|
25
|
+
"typecheck": "tsc --noEmit",
|
|
26
|
+
"prepublishOnly": "npm run build && npm test"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@modelcontextprotocol/sdk": "^1.0.4",
|
|
30
|
+
"zod": "^3.22.4",
|
|
31
|
+
"zod-to-json-schema": "^3.24.6"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^20.11.0",
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
|
36
|
+
"@typescript-eslint/parser": "^6.19.0",
|
|
37
|
+
"@vitest/coverage-v8": "^1.2.0",
|
|
38
|
+
"eslint": "^8.56.0",
|
|
39
|
+
"prettier": "^3.2.4",
|
|
40
|
+
"tsup": "^8.0.1",
|
|
41
|
+
"typescript": "^5.3.3",
|
|
42
|
+
"vitest": "^1.2.0"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"mcp",
|
|
46
|
+
"model-context-protocol",
|
|
47
|
+
"thinking",
|
|
48
|
+
"reasoning",
|
|
49
|
+
"sequential-thinking",
|
|
50
|
+
"shannon-thinking",
|
|
51
|
+
"physics",
|
|
52
|
+
"mathematics",
|
|
53
|
+
"tensor",
|
|
54
|
+
"deep-thinking",
|
|
55
|
+
"mathematical-reasoning"
|
|
56
|
+
],
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "https://github.com/danielsimonjr/deepthinking-mcp"
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=18.0.0"
|
|
63
|
+
}
|
|
64
|
+
}
|