@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.
Files changed (2) hide show
  1. package/README.md +68 -321
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,366 +1,113 @@
1
- # ๐Ÿš€ Intelligent Agent MCP Server
1
+ # ๐Ÿง  Mathinking MCP Server (The Brain & The Body)
2
2
 
3
- A powerful Model Context Protocol (MCP) server featuring two core capabilities:
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
- ## ๐Ÿ“‹ Overview
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
- This MCP server enables AI agents to:
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
- โ”‚ Intelligent Agent Flow โ”‚
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
- ## ๐Ÿ› ๏ธ Installation
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
- ```bash
33
- # Clone or create the project
34
- cd intelligent-agent-mcp
27
+ ---
35
28
 
36
- # Install dependencies
37
- npm install
29
+ ## ๐Ÿ› ๏ธ Installation
38
30
 
39
- # Build TypeScript
40
- npm run build
31
+ You can run Mathinking immediately without manual cloning using `npx`:
41
32
 
42
- # Run the server
43
- npm start
33
+ ```bash
34
+ npx -y @gotza02/mathinking
44
35
  ```
45
36
 
37
+ ---
38
+
46
39
  ## โš™๏ธ Configuration
47
40
 
48
- Add to your MCP client configuration (e.g., Claude Desktop):
41
+ ### 1. Gemini CLI
42
+ Add to your `~/.gemini/settings.json`:
49
43
 
50
44
  ```json
51
45
  {
52
46
  "mcpServers": {
53
- "intelligent-agent": {
54
- "command": "node",
55
- "args": ["/path/to/intelligent-agent-mcp/dist/index.js"]
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
- ### Built-in Tools
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
- "action": "execute_plan",
191
- "plan": {
192
- "planId": "data-pipeline-001",
193
- "name": "Parallel Data Pipeline",
194
- "tasks": [
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
- ## ๐Ÿ”— Integration Workflow
265
-
266
- The recommended pattern for complex tasks:
77
+ ## ๐Ÿค– Orchestrator Built-in Tools
267
78
 
268
- ```
269
- 1. User: "Analyze competitors and create a market report"
270
-
271
- 2. AI calls sequential_thinking:
272
- - start_session: "Analyze competitors and create market report"
273
- - add_thought: "Need to gather data from multiple sources"
274
- - add_thought: "Identify key competitors: A, B, C"
275
- - set_hypothesis: "Competitor A leads in market share"
276
- - add_thought: "Data sources: financial reports, social media, reviews"
277
- - conclude: "Plan: Fetch data in parallel, then synthesize"
278
-
279
- 3. AI creates execution plan from thinking output
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
- ## ๐Ÿ“Š Error Handling
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
- ### Orchestrator
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
- ```typescript
305
- // Example error response
98
+ ```json
306
99
  {
307
- "success": false,
308
- "status": "completed_with_errors",
309
- "errors": [
310
- {
311
- "taskId": "fetch_data",
312
- "taskName": "Fetch External Data",
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gotza02/mathinking",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "MCP Server with sequential thinking (The Brain) and orchestrator (The Body) capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",