@gotza02/mathinking 1.2.0 โ 1.2.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.
- package/README.md +68 -321
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,366 +1,113 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ๐ง Mathinking MCP Server (The Brain & The Body)
|
|
2
2
|
|
|
3
|
-
A powerful Model Context Protocol (MCP) server
|
|
4
|
-
- **๐ง The Brain** (`sequential_thinking`) - Deep reasoning and planning
|
|
5
|
-
- **๐ค The Body** (`orchestrator`) - Parallel task execution
|
|
3
|
+
A powerful, autonomous Model Context Protocol (MCP) server that empowers AI agents with structured reasoning and real-world execution capabilities.
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
- **๐ง The Brain** (`sequential_thinking`) - Deep iterative reasoning with persistent memory.
|
|
6
|
+
- **๐ค The Body** (`orchestrator`) - Real-world task execution with parallel processing, conditional logic, and tool orchestration.
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
1. Think through complex problems step-by-step with branching and revision
|
|
11
|
-
2. Execute multi-step task plans with parallel processing and dependency management
|
|
8
|
+
## ๐ Features
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
โ User Query โ [sequential_thinking] โ Plan โ [orchestrator] โ
|
|
19
|
-
โ (Analysis) (Execution) โ
|
|
20
|
-
โ โ โ โ
|
|
21
|
-
โ Thought Steps Parallel Tasks โ
|
|
22
|
-
โ Branching/Revision DAG Resolution โ
|
|
23
|
-
โ Hypothesis Testing Result Aggregation โ
|
|
24
|
-
โ โ โ โ
|
|
25
|
-
โ Final Plan Final Results โ
|
|
26
|
-
โ โ
|
|
27
|
-
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
28
|
-
```
|
|
10
|
+
### ๐ง The Brain (Sequential Thinking)
|
|
11
|
+
- **Iterative Reasoning:** Think step-by-step with adjustable depth.
|
|
12
|
+
- **Persistent Memory:** Sessions and thoughts are saved automatically to `~/.mathinking/sessions.json`.
|
|
13
|
+
- **Branching & Revision:** Explore alternative paths and correct previous thoughts.
|
|
14
|
+
- **Hypothesis Testing:** Formulate and verify theories with evidence.
|
|
29
15
|
|
|
30
|
-
|
|
16
|
+
### ๐ค The Body (Orchestrator)
|
|
17
|
+
- **Real-World Execution:**
|
|
18
|
+
- **Web Search:** Integrated search capabilities (Scraping/API).
|
|
19
|
+
- **Real Fetch:** Fetch real data from URLs (JSON/Text).
|
|
20
|
+
- **File System:** Read, write, and list local files and directories.
|
|
21
|
+
- **Shell Execute:** Run bash commands directly.
|
|
22
|
+
- **Conditional Logic (`runIf`):** Tasks can run conditionally based on previous results (e.g., `"${task1.results.length} === 0"`).
|
|
23
|
+
- **Parallel Processing:** Group independent tasks into layers for concurrent execution.
|
|
24
|
+
- **Dependency Resolution:** Automatic DAG (Directed Acyclic Graph) management.
|
|
25
|
+
- **Long-term Memory:** Save and query facts/preferences via `memory_save` and `memory_query`.
|
|
31
26
|
|
|
32
|
-
|
|
33
|
-
# Clone or create the project
|
|
34
|
-
cd intelligent-agent-mcp
|
|
27
|
+
---
|
|
35
28
|
|
|
36
|
-
|
|
37
|
-
npm install
|
|
29
|
+
## ๐ ๏ธ Installation
|
|
38
30
|
|
|
39
|
-
|
|
40
|
-
npm run build
|
|
31
|
+
You can run Mathinking immediately without manual cloning using `npx`:
|
|
41
32
|
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
```bash
|
|
34
|
+
npx -y @gotza02/mathinking
|
|
44
35
|
```
|
|
45
36
|
|
|
37
|
+
---
|
|
38
|
+
|
|
46
39
|
## โ๏ธ Configuration
|
|
47
40
|
|
|
48
|
-
|
|
41
|
+
### 1. Gemini CLI
|
|
42
|
+
Add to your `~/.gemini/settings.json`:
|
|
49
43
|
|
|
50
44
|
```json
|
|
51
45
|
{
|
|
52
46
|
"mcpServers": {
|
|
53
|
-
"
|
|
54
|
-
"command": "
|
|
55
|
-
"args": ["
|
|
47
|
+
"mathinking": {
|
|
48
|
+
"command": "npx",
|
|
49
|
+
"args": ["-y", "@gotza02/mathinking"],
|
|
50
|
+
"env": {
|
|
51
|
+
"BRAVE_SEARCH_API_KEY": "your_key_here"
|
|
52
|
+
}
|
|
56
53
|
}
|
|
57
54
|
}
|
|
58
55
|
}
|
|
59
56
|
```
|
|
60
57
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
## ๐ง Tool 1: Sequential Thinking (The Brain)
|
|
64
|
-
|
|
65
|
-
A sophisticated reasoning system for complex problem-solving.
|
|
66
|
-
|
|
67
|
-
### Features
|
|
68
|
-
|
|
69
|
-
| Feature | Description |
|
|
70
|
-
|---------|-------------|
|
|
71
|
-
| **Iterative Thinking** | Step-by-step reasoning with adjustable depth |
|
|
72
|
-
| **Dynamic Adjustment** | Modify thinking steps on-the-fly |
|
|
73
|
-
| **Branching** | Explore alternative solution paths |
|
|
74
|
-
| **Revision** | Correct previous thoughts when errors found |
|
|
75
|
-
| **Hypothesis Testing** | Formulate and verify theories |
|
|
76
|
-
| **Confidence Tracking** | Monitor certainty levels |
|
|
77
|
-
|
|
78
|
-
### Actions
|
|
79
|
-
|
|
80
|
-
| Action | Description | Required Params |
|
|
81
|
-
|--------|-------------|-----------------|
|
|
82
|
-
| `start_session` | Begin new thinking session | `problemStatement` |
|
|
83
|
-
| `add_thought` | Add a reasoning step | `sessionId`, `thought` |
|
|
84
|
-
| `create_branch` | Explore alternative | `sessionId`, `branchFromThoughtId` |
|
|
85
|
-
| `revise_thought` | Correct previous thought | `sessionId`, `reviseThoughtId`, `thought` |
|
|
86
|
-
| `set_hypothesis` | Propose testable theory | `sessionId`, `hypothesis` |
|
|
87
|
-
| `verify_hypothesis` | Confirm/refute theory | `sessionId`, `verificationStatus` |
|
|
88
|
-
| `adjust_total_thoughts` | Change thinking depth | `sessionId`, `totalThoughts` |
|
|
89
|
-
| `conclude` | Synthesize final answer | `sessionId`, `thought` |
|
|
90
|
-
| `get_status` | Check session progress | `sessionId` |
|
|
91
|
-
| `get_history` | Review all thoughts | `sessionId` |
|
|
92
|
-
|
|
93
|
-
### Example Usage
|
|
94
|
-
|
|
95
|
-
```typescript
|
|
96
|
-
// 1. Start a thinking session
|
|
97
|
-
{
|
|
98
|
-
"action": "start_session",
|
|
99
|
-
"problemStatement": "Design a scalable microservices architecture for an e-commerce platform",
|
|
100
|
-
"totalThoughts": 6
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// 2. Add initial analysis
|
|
104
|
-
{
|
|
105
|
-
"action": "add_thought",
|
|
106
|
-
"sessionId": "abc-123",
|
|
107
|
-
"thought": "The core domains are: User Management, Product Catalog, Order Processing, Payment, and Inventory",
|
|
108
|
-
"thoughtType": "initial_analysis",
|
|
109
|
-
"confidence": 85
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// 3. Set a hypothesis
|
|
113
|
-
{
|
|
114
|
-
"action": "set_hypothesis",
|
|
115
|
-
"sessionId": "abc-123",
|
|
116
|
-
"hypothesis": "Event-driven architecture with Kafka will handle peak loads better than synchronous REST"
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// 4. Create a branch to explore alternatives
|
|
120
|
-
{
|
|
121
|
-
"action": "create_branch",
|
|
122
|
-
"sessionId": "abc-123",
|
|
123
|
-
"branchFromThoughtId": "thought-456",
|
|
124
|
-
"branchLabel": "Option B: GraphQL Federation",
|
|
125
|
-
"thought": "Alternative approach using GraphQL for unified API layer"
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// 5. Verify the hypothesis
|
|
129
|
-
{
|
|
130
|
-
"action": "verify_hypothesis",
|
|
131
|
-
"sessionId": "abc-123",
|
|
132
|
-
"verificationStatus": "verified",
|
|
133
|
-
"verificationEvidence": "Benchmark shows 3x throughput improvement under load"
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// 6. Conclude
|
|
137
|
-
{
|
|
138
|
-
"action": "conclude",
|
|
139
|
-
"sessionId": "abc-123",
|
|
140
|
-
"thought": "Recommended architecture: Event-driven microservices with Kafka, using CQRS pattern for read-heavy services",
|
|
141
|
-
"confidence": 90
|
|
142
|
-
}
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
---
|
|
146
|
-
|
|
147
|
-
## ๐ค Tool 2: Orchestrator (The Body)
|
|
148
|
-
|
|
149
|
-
A DAG-based execution engine for parallel task processing.
|
|
150
|
-
|
|
151
|
-
### Features
|
|
152
|
-
|
|
153
|
-
| Feature | Description |
|
|
154
|
-
|---------|-------------|
|
|
155
|
-
| **DAG Execution** | Topological sorting for dependency resolution |
|
|
156
|
-
| **Parallel Processing** | Independent tasks run concurrently |
|
|
157
|
-
| **Tool Chaining** | Reference outputs from previous tasks |
|
|
158
|
-
| **Error Handling** | Graceful degradation with retries |
|
|
159
|
-
| **Result Aggregation** | Combine all task outputs |
|
|
58
|
+
### 2. Claude Desktop
|
|
59
|
+
Add to your `claude_desktop_config.json`:
|
|
160
60
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
| Tool | Description | Input |
|
|
164
|
-
|------|-------------|-------|
|
|
165
|
-
| `echo` | Returns input as-is | `{ any: "value" }` |
|
|
166
|
-
| `delay` | Waits specified ms | `{ milliseconds: 1000 }` |
|
|
167
|
-
| `transform` | Text/number transforms | `{ data: "text", operation: "uppercase" }` |
|
|
168
|
-
| `aggregate` | Combine values | `{ values: [...], operation: "sum" }` |
|
|
169
|
-
| `fetch` | HTTP request (simulated) | `{ url: "https://..." }` |
|
|
170
|
-
| `compute` | Math expressions | `{ expression: "a + b", variables: { a: 1, b: 2 } }` |
|
|
171
|
-
|
|
172
|
-
### Transform Operations
|
|
173
|
-
- `uppercase` / `lowercase` / `reverse` / `length` / `double`
|
|
174
|
-
|
|
175
|
-
### Aggregate Operations
|
|
176
|
-
- `sum` / `concat` / `array` / `count`
|
|
177
|
-
|
|
178
|
-
### Actions
|
|
179
|
-
|
|
180
|
-
| Action | Description | Required Params |
|
|
181
|
-
|--------|-------------|-----------------|
|
|
182
|
-
| `validate_plan` | Check plan validity | `plan` |
|
|
183
|
-
| `execute_plan` | Run the full plan | `plan` |
|
|
184
|
-
| `get_execution_status` | Check previous results | `planId` |
|
|
185
|
-
|
|
186
|
-
### Example: Parallel Data Processing
|
|
187
|
-
|
|
188
|
-
```typescript
|
|
61
|
+
```json
|
|
189
62
|
{
|
|
190
|
-
"
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
"id": "fetch_users",
|
|
197
|
-
"name": "Fetch Users",
|
|
198
|
-
"toolName": "fetch",
|
|
199
|
-
"toolInput": { "url": "https://api.example.com/users" },
|
|
200
|
-
"dependencies": []
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
"id": "fetch_orders",
|
|
204
|
-
"name": "Fetch Orders",
|
|
205
|
-
"toolName": "fetch",
|
|
206
|
-
"toolInput": { "url": "https://api.example.com/orders" },
|
|
207
|
-
"dependencies": []
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
"id": "fetch_products",
|
|
211
|
-
"name": "Fetch Products",
|
|
212
|
-
"toolName": "fetch",
|
|
213
|
-
"toolInput": { "url": "https://api.example.com/products" },
|
|
214
|
-
"dependencies": []
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
"id": "transform_users",
|
|
218
|
-
"name": "Process Users",
|
|
219
|
-
"toolName": "transform",
|
|
220
|
-
"toolInput": {
|
|
221
|
-
"data": "${fetch_users.body}",
|
|
222
|
-
"operation": "uppercase"
|
|
223
|
-
},
|
|
224
|
-
"dependencies": ["fetch_users"]
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
"id": "aggregate_all",
|
|
228
|
-
"name": "Combine Results",
|
|
229
|
-
"toolName": "aggregate",
|
|
230
|
-
"toolInput": {
|
|
231
|
-
"values": [
|
|
232
|
-
"${fetch_users}",
|
|
233
|
-
"${fetch_orders}",
|
|
234
|
-
"${fetch_products}"
|
|
235
|
-
],
|
|
236
|
-
"operation": "array"
|
|
237
|
-
},
|
|
238
|
-
"dependencies": ["fetch_users", "fetch_orders", "fetch_products"]
|
|
63
|
+
"mcpServers": {
|
|
64
|
+
"mathinking": {
|
|
65
|
+
"command": "npx",
|
|
66
|
+
"args": ["-y", "@gotza02/mathinking"],
|
|
67
|
+
"env": {
|
|
68
|
+
"BRAVE_SEARCH_API_KEY": "your_key_here"
|
|
239
69
|
}
|
|
240
|
-
|
|
70
|
+
}
|
|
241
71
|
}
|
|
242
72
|
}
|
|
243
73
|
```
|
|
244
74
|
|
|
245
|
-
### Execution Visualization
|
|
246
|
-
|
|
247
|
-
```
|
|
248
|
-
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
249
|
-
โ DAG Execution Visualization โ
|
|
250
|
-
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
|
251
|
-
โ Layer 1 (Parallel): โ
|
|
252
|
-
โ โโโ Fetch Users (no deps) โ
|
|
253
|
-
โ โโโ Fetch Orders (no deps) โ
|
|
254
|
-
โ โโโ Fetch Products (no deps) โ
|
|
255
|
-
โ โ โ
|
|
256
|
-
โ Layer 2 (Parallel): โ
|
|
257
|
-
โ โโโ Process Users โ [fetch_users] โ
|
|
258
|
-
โ โโโ Combine Results โ [fetch_users, ...] โ
|
|
259
|
-
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
260
|
-
```
|
|
261
|
-
|
|
262
75
|
---
|
|
263
76
|
|
|
264
|
-
##
|
|
265
|
-
|
|
266
|
-
The recommended pattern for complex tasks:
|
|
77
|
+
## ๐ค Orchestrator Built-in Tools
|
|
267
78
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
4. AI calls orchestrator:
|
|
282
|
-
- execute_plan with parallel fetch tasks
|
|
283
|
-
- Aggregate results
|
|
284
|
-
- Generate final report
|
|
285
|
-
|
|
286
|
-
5. Return synthesized results to user
|
|
287
|
-
```
|
|
79
|
+
| Tool | Description | Input Examples |
|
|
80
|
+
|------|-------------|-------|
|
|
81
|
+
| `fetch` | Real HTTP request | `{ "url": "https://api.github.com/repos/..." }` |
|
|
82
|
+
| `web_search` | Search the web | `{ "query": "latest news on MCP" }` |
|
|
83
|
+
| `shell_execute` | Run bash commands | `{ "command": "ls -la" }` |
|
|
84
|
+
| `read_file` | Read local file | `{ "path": "./config.json" }` |
|
|
85
|
+
| `write_file` | Write local file | `{ "path": "notes.txt", "content": "hello" }` |
|
|
86
|
+
| `memory_save` | Save fact to memory | `{ "key": "user_pref", "value": "likes rust" }` |
|
|
87
|
+
| `memory_query` | Query memory | `{ "query": "preference" }` |
|
|
88
|
+
| `compute` | Math evaluation | `{ "expression": "a * 2", "variables": { "a": 10 } }` |
|
|
89
|
+
| `transform` | Text transforms | `uppercase`, `lowercase`, `reverse`, `length` |
|
|
90
|
+
| `aggregate` | Combine results | `sum`, `concat`, `array`, `count` |
|
|
288
91
|
|
|
289
92
|
---
|
|
290
93
|
|
|
291
|
-
##
|
|
292
|
-
|
|
293
|
-
### Sequential Thinking
|
|
294
|
-
- Invalid sessions return helpful error messages
|
|
295
|
-
- Unverified hypotheses block conclusion
|
|
296
|
-
- Revision history maintained for audit
|
|
94
|
+
## ๐ก Advanced Example: Conditional Logic
|
|
297
95
|
|
|
298
|
-
|
|
299
|
-
- Failed tasks don't crash the pipeline
|
|
300
|
-
- Retry support with configurable delays
|
|
301
|
-
- Skipped tasks for unmet dependencies
|
|
302
|
-
- Comprehensive error reporting
|
|
96
|
+
You can define tasks that only run if a certain condition is met:
|
|
303
97
|
|
|
304
|
-
```
|
|
305
|
-
// Example error response
|
|
98
|
+
```json
|
|
306
99
|
{
|
|
307
|
-
"
|
|
308
|
-
"
|
|
309
|
-
"
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
"error": "Task timed out after 5000ms",
|
|
314
|
-
"timestamp": "2024-01-15T10:30:00Z"
|
|
315
|
-
}
|
|
316
|
-
]
|
|
100
|
+
"id": "backup_plan",
|
|
101
|
+
"name": "Run if primary fails",
|
|
102
|
+
"toolName": "shell_execute",
|
|
103
|
+
"toolInput": { "command": "./fix_script.sh" },
|
|
104
|
+
"runIf": "${primary_task.status} === 'failed' || ${primary_task.data.length} === 0",
|
|
105
|
+
"dependencies": ["primary_task"]
|
|
317
106
|
}
|
|
318
107
|
```
|
|
319
108
|
|
|
320
109
|
---
|
|
321
110
|
|
|
322
|
-
## ๐งช Testing
|
|
323
|
-
|
|
324
|
-
```bash
|
|
325
|
-
# Run in development mode
|
|
326
|
-
npm run dev
|
|
327
|
-
|
|
328
|
-
# Build and run
|
|
329
|
-
npm run build && npm start
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
---
|
|
333
|
-
|
|
334
|
-
## ๐ Project Structure
|
|
335
|
-
|
|
336
|
-
```
|
|
337
|
-
intelligent-agent-mcp/
|
|
338
|
-
โโโ package.json
|
|
339
|
-
โโโ tsconfig.json
|
|
340
|
-
โโโ src/
|
|
341
|
-
โ โโโ index.ts # MCP Server entry point
|
|
342
|
-
โ โโโ tools/
|
|
343
|
-
โ โ โโโ sequential-thinking.ts # The Brain
|
|
344
|
-
โ โ โโโ orchestrator.ts # The Body
|
|
345
|
-
โ โโโ types/
|
|
346
|
-
โ โ โโโ index.ts # TypeScript interfaces
|
|
347
|
-
โ โโโ utils/
|
|
348
|
-
โ โโโ dag.ts # DAG utilities
|
|
349
|
-
โโโ README.md
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
---
|
|
353
|
-
|
|
354
111
|
## ๐ License
|
|
355
112
|
|
|
356
|
-
MIT
|
|
357
|
-
|
|
358
|
-
---
|
|
359
|
-
|
|
360
|
-
## ๐ค Contributing
|
|
361
|
-
|
|
362
|
-
Contributions welcome! Areas of interest:
|
|
363
|
-
- Additional built-in tools for orchestrator
|
|
364
|
-
- Persistent session storage for thinking
|
|
365
|
-
- WebSocket transport support
|
|
366
|
-
- Visualization dashboard
|
|
113
|
+
MIT - Created by @gotza02
|