@gotza02/mathinking 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 +366 -0
- package/dist/dag.d.ts +39 -0
- package/dist/dag.d.ts.map +1 -0
- package/dist/dag.js +241 -0
- package/dist/dag.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +300 -0
- package/dist/index.js.map +1 -0
- package/dist/orchestrator.d.ts +65 -0
- package/dist/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator.js +485 -0
- package/dist/orchestrator.js.map +1 -0
- package/dist/sequential-thinking.d.ts +70 -0
- package/dist/sequential-thinking.d.ts.map +1 -0
- package/dist/sequential-thinking.js +602 -0
- package/dist/sequential-thinking.js.map +1 -0
- package/dist/test-all.d.ts +2 -0
- package/dist/test-all.d.ts.map +1 -0
- package/dist/test-all.js +158 -0
- package/dist/test-all.js.map +1 -0
- package/dist/tools/orchestrator.d.ts +65 -0
- package/dist/tools/orchestrator.d.ts.map +1 -0
- package/dist/tools/orchestrator.js +486 -0
- package/dist/tools/orchestrator.js.map +1 -0
- package/dist/tools/sequential-thinking.d.ts +70 -0
- package/dist/tools/sequential-thinking.d.ts.map +1 -0
- package/dist/tools/sequential-thinking.js +602 -0
- package/dist/tools/sequential-thinking.js.map +1 -0
- package/dist/types/index.d.ts +142 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/dag.d.ts +39 -0
- package/dist/utils/dag.d.ts.map +1 -0
- package/dist/utils/dag.js +241 -0
- package/dist/utils/dag.js.map +1 -0
- package/package.json +45 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
#!/usr/bin/env node
|
|
3
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
4
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
5
|
+
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
6
|
+
import { thinkingManager } from './tools/sequential-thinking.js';
|
|
7
|
+
import { orchestratorManager } from './tools/orchestrator.js';
|
|
8
|
+
// ============================================
|
|
9
|
+
// Tool Definitions
|
|
10
|
+
// ============================================
|
|
11
|
+
const SEQUENTIAL_THINKING_TOOL = {
|
|
12
|
+
name: 'sequential_thinking',
|
|
13
|
+
description: `🧠The Brain - Deep Reasoning & Planning Tool
|
|
14
|
+
|
|
15
|
+
A powerful iterative thinking system for complex problem-solving with:
|
|
16
|
+
• Step-by-step reasoning with adjustable depth
|
|
17
|
+
• Branching for exploring alternative approaches
|
|
18
|
+
• Revision capability to correct previous thoughts
|
|
19
|
+
• Hypothesis formulation and verification
|
|
20
|
+
• Confidence tracking and synthesis
|
|
21
|
+
|
|
22
|
+
ACTIONS:
|
|
23
|
+
- start_session: Begin a new thinking session
|
|
24
|
+
- add_thought: Add a reasoning step
|
|
25
|
+
- create_branch: Explore alternative paths
|
|
26
|
+
- revise_thought: Correct previous thinking
|
|
27
|
+
- set_hypothesis: Propose a testable theory
|
|
28
|
+
- verify_hypothesis: Confirm/refute with evidence
|
|
29
|
+
- adjust_total_thoughts: Change thinking depth
|
|
30
|
+
- conclude: Synthesize final answer
|
|
31
|
+
- get_status: Check session progress
|
|
32
|
+
- get_history: Review all thoughts
|
|
33
|
+
|
|
34
|
+
Use this BEFORE orchestrator to plan complex tasks.`,
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: 'object',
|
|
37
|
+
properties: {
|
|
38
|
+
action: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
enum: [
|
|
41
|
+
'start_session',
|
|
42
|
+
'add_thought',
|
|
43
|
+
'create_branch',
|
|
44
|
+
'revise_thought',
|
|
45
|
+
'set_hypothesis',
|
|
46
|
+
'verify_hypothesis',
|
|
47
|
+
'adjust_total_thoughts',
|
|
48
|
+
'conclude',
|
|
49
|
+
'get_status',
|
|
50
|
+
'get_history'
|
|
51
|
+
],
|
|
52
|
+
description: 'The thinking action to perform'
|
|
53
|
+
},
|
|
54
|
+
sessionId: {
|
|
55
|
+
type: 'string',
|
|
56
|
+
description: 'Session ID (required for all actions except start_session)'
|
|
57
|
+
},
|
|
58
|
+
problemStatement: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
description: 'The problem to analyze (required for start_session)'
|
|
61
|
+
},
|
|
62
|
+
thought: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
description: 'The thought content'
|
|
65
|
+
},
|
|
66
|
+
thoughtType: {
|
|
67
|
+
type: 'string',
|
|
68
|
+
enum: [
|
|
69
|
+
'initial_analysis',
|
|
70
|
+
'decomposition',
|
|
71
|
+
'hypothesis',
|
|
72
|
+
'verification',
|
|
73
|
+
'branch_exploration',
|
|
74
|
+
'synthesis',
|
|
75
|
+
'revision',
|
|
76
|
+
'conclusion'
|
|
77
|
+
],
|
|
78
|
+
description: 'Type of thought being added'
|
|
79
|
+
},
|
|
80
|
+
totalThoughts: {
|
|
81
|
+
type: 'number',
|
|
82
|
+
description: 'Total number of thinking steps (for start_session or adjust_total_thoughts)'
|
|
83
|
+
},
|
|
84
|
+
branchFromThoughtId: {
|
|
85
|
+
type: 'string',
|
|
86
|
+
description: 'ID of thought to branch from'
|
|
87
|
+
},
|
|
88
|
+
branchLabel: {
|
|
89
|
+
type: 'string',
|
|
90
|
+
description: 'Label for the new branch (e.g., "Option A")'
|
|
91
|
+
},
|
|
92
|
+
reviseThoughtId: {
|
|
93
|
+
type: 'string',
|
|
94
|
+
description: 'ID of thought to revise'
|
|
95
|
+
},
|
|
96
|
+
hypothesis: {
|
|
97
|
+
type: 'string',
|
|
98
|
+
description: 'Hypothesis statement to test'
|
|
99
|
+
},
|
|
100
|
+
verificationEvidence: {
|
|
101
|
+
type: 'string',
|
|
102
|
+
description: 'Evidence supporting verification decision'
|
|
103
|
+
},
|
|
104
|
+
verificationStatus: {
|
|
105
|
+
type: 'string',
|
|
106
|
+
enum: ['verified', 'refuted', 'partially_verified', 'needs_more_evidence'],
|
|
107
|
+
description: 'Result of hypothesis verification'
|
|
108
|
+
},
|
|
109
|
+
confidence: {
|
|
110
|
+
type: 'number',
|
|
111
|
+
minimum: 0,
|
|
112
|
+
maximum: 100,
|
|
113
|
+
description: 'Confidence level (0-100)'
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
required: ['action']
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const ORCHESTRATOR_TOOL = {
|
|
120
|
+
name: 'orchestrator',
|
|
121
|
+
description: `🤖 The Body - Parallel Task Execution Engine
|
|
122
|
+
|
|
123
|
+
A DAG-based orchestration system for executing complex task plans with:
|
|
124
|
+
• Topological sorting for dependency resolution
|
|
125
|
+
• Parallel execution of independent tasks
|
|
126
|
+
• Tool chaining with output references
|
|
127
|
+
• Graceful error handling with retries
|
|
128
|
+
• Result aggregation
|
|
129
|
+
|
|
130
|
+
ACTIONS:
|
|
131
|
+
- validate_plan: Check plan validity and view execution order
|
|
132
|
+
- execute_plan: Run the full plan with parallel processing
|
|
133
|
+
- get_execution_status: Check results of previous execution
|
|
134
|
+
|
|
135
|
+
PLAN FORMAT:
|
|
136
|
+
{
|
|
137
|
+
"planId": "unique-id",
|
|
138
|
+
"name": "Plan Name",
|
|
139
|
+
"tasks": [
|
|
140
|
+
{
|
|
141
|
+
"id": "task1",
|
|
142
|
+
"name": "First Task",
|
|
143
|
+
"toolName": "echo|delay|transform|aggregate|fetch|compute",
|
|
144
|
+
"toolInput": { "key": "value" },
|
|
145
|
+
"dependencies": [],
|
|
146
|
+
"timeout": 5000,
|
|
147
|
+
"retryCount": 2
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"id": "task2",
|
|
151
|
+
"name": "Second Task",
|
|
152
|
+
"toolName": "transform",
|
|
153
|
+
"toolInput": { "data": "\${task1.result}" },
|
|
154
|
+
"dependencies": ["task1"]
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
Use \${taskId} or \${taskId.property} to reference previous task outputs.
|
|
160
|
+
|
|
161
|
+
BUILT-IN TOOLS:
|
|
162
|
+
- echo: Returns input as-is
|
|
163
|
+
- delay: Waits specified milliseconds
|
|
164
|
+
- transform: uppercase/lowercase/reverse/length/double
|
|
165
|
+
- aggregate: sum/concat/array/count
|
|
166
|
+
- fetch: Simulated HTTP fetch
|
|
167
|
+
- compute: Math expressions with variables`,
|
|
168
|
+
inputSchema: {
|
|
169
|
+
type: 'object',
|
|
170
|
+
properties: {
|
|
171
|
+
action: {
|
|
172
|
+
type: 'string',
|
|
173
|
+
enum: ['execute_plan', 'validate_plan', 'get_execution_status'],
|
|
174
|
+
description: 'The orchestration action to perform'
|
|
175
|
+
},
|
|
176
|
+
plan: {
|
|
177
|
+
type: 'object',
|
|
178
|
+
description: 'The execution plan (required for execute_plan and validate_plan)',
|
|
179
|
+
properties: {
|
|
180
|
+
planId: { type: 'string' },
|
|
181
|
+
name: { type: 'string' },
|
|
182
|
+
description: { type: 'string' },
|
|
183
|
+
tasks: {
|
|
184
|
+
type: 'array',
|
|
185
|
+
items: {
|
|
186
|
+
type: 'object',
|
|
187
|
+
properties: {
|
|
188
|
+
id: { type: 'string' },
|
|
189
|
+
name: { type: 'string' },
|
|
190
|
+
description: { type: 'string' },
|
|
191
|
+
toolName: { type: 'string' },
|
|
192
|
+
toolInput: { type: 'object' },
|
|
193
|
+
dependencies: { type: 'array', items: { type: 'string' } },
|
|
194
|
+
timeout: { type: 'number' },
|
|
195
|
+
retryCount: { type: 'number' },
|
|
196
|
+
retryDelay: { type: 'number' }
|
|
197
|
+
},
|
|
198
|
+
required: ['id', 'name', 'toolName', 'toolInput', 'dependencies']
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
required: ['planId', 'name', 'tasks']
|
|
203
|
+
},
|
|
204
|
+
planId: {
|
|
205
|
+
type: 'string',
|
|
206
|
+
description: 'Plan ID (required for get_execution_status)'
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
required: ['action']
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
// ============================================
|
|
213
|
+
// Server Setup
|
|
214
|
+
// ============================================
|
|
215
|
+
const server = new Server({
|
|
216
|
+
name: 'intelligent-agent-mcp',
|
|
217
|
+
version: '1.0.0'
|
|
218
|
+
}, {
|
|
219
|
+
capabilities: {
|
|
220
|
+
tools: {}
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
// ============================================
|
|
224
|
+
// Request Handlers
|
|
225
|
+
// ============================================
|
|
226
|
+
// List available tools
|
|
227
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
228
|
+
return {
|
|
229
|
+
tools: [SEQUENTIAL_THINKING_TOOL, ORCHESTRATOR_TOOL]
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
// Handle tool calls
|
|
233
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
234
|
+
const { name, arguments: args } = request.params;
|
|
235
|
+
try {
|
|
236
|
+
switch (name) {
|
|
237
|
+
case 'sequential_thinking': {
|
|
238
|
+
const input = args;
|
|
239
|
+
const result = await thinkingManager.process(input);
|
|
240
|
+
return {
|
|
241
|
+
content: [
|
|
242
|
+
{
|
|
243
|
+
type: 'text',
|
|
244
|
+
text: JSON.stringify(result, null, 2)
|
|
245
|
+
}
|
|
246
|
+
]
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
case 'orchestrator': {
|
|
250
|
+
const input = args;
|
|
251
|
+
const result = await orchestratorManager.process(input);
|
|
252
|
+
return {
|
|
253
|
+
content: [
|
|
254
|
+
{
|
|
255
|
+
type: 'text',
|
|
256
|
+
text: JSON.stringify(result, null, 2)
|
|
257
|
+
}
|
|
258
|
+
]
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
default:
|
|
262
|
+
return {
|
|
263
|
+
content: [
|
|
264
|
+
{
|
|
265
|
+
type: 'text',
|
|
266
|
+
text: `Unknown tool: ${name}`
|
|
267
|
+
}
|
|
268
|
+
],
|
|
269
|
+
isError: true
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
275
|
+
return {
|
|
276
|
+
content: [
|
|
277
|
+
{
|
|
278
|
+
type: 'text',
|
|
279
|
+
text: `Error executing ${name}: ${errorMessage}`
|
|
280
|
+
}
|
|
281
|
+
],
|
|
282
|
+
isError: true
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
// ============================================
|
|
287
|
+
// Main Entry Point
|
|
288
|
+
// ============================================
|
|
289
|
+
async function main() {
|
|
290
|
+
console.error('🚀 Intelligent Agent MCP Server starting...');
|
|
291
|
+
console.error('📦 Tools: sequential_thinking (The Brain), orchestrator (The Body)');
|
|
292
|
+
const transport = new StdioServerTransport();
|
|
293
|
+
await server.connect(transport);
|
|
294
|
+
console.error('✅ Server connected and ready!');
|
|
295
|
+
}
|
|
296
|
+
main().catch((error) => {
|
|
297
|
+
console.error('Fatal error:', error);
|
|
298
|
+
process.exit(1);
|
|
299
|
+
});
|
|
300
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EAEvB,MAAM,oCAAoC,CAAC;AAG5C,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAO9D,+CAA+C;AAC/C,mBAAmB;AACnB,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OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,+CAA+C;AAC/C,mBAAmB;AACnB,+CAA+C;AAE/C,KAAK,UAAU,IAAI;IACjB,OAAO,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAC7D,OAAO,CAAC,KAAK,CAAC,oEAAoE,CAAC,CAAC;IAEpF,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;AACjD,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { OrchestratorInput, OrchestratorOutput, ToolDefinition } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Orchestrator Manager (The Body)
|
|
4
|
+
*
|
|
5
|
+
* Provides DAG-based task execution with:
|
|
6
|
+
* - Topological sorting for dependency resolution
|
|
7
|
+
* - Parallel execution of independent tasks
|
|
8
|
+
* - Tool orchestration via registry
|
|
9
|
+
* - Graceful error handling
|
|
10
|
+
* - Result aggregation
|
|
11
|
+
*/
|
|
12
|
+
export declare class OrchestratorManager {
|
|
13
|
+
private toolRegistry;
|
|
14
|
+
private executionHistory;
|
|
15
|
+
constructor();
|
|
16
|
+
/**
|
|
17
|
+
* Register built-in tools for testing and common operations
|
|
18
|
+
*/
|
|
19
|
+
private registerBuiltInTools;
|
|
20
|
+
/**
|
|
21
|
+
* Register a custom tool
|
|
22
|
+
*/
|
|
23
|
+
registerTool(tool: ToolDefinition): void;
|
|
24
|
+
/**
|
|
25
|
+
* Get list of registered tools
|
|
26
|
+
*/
|
|
27
|
+
getRegisteredTools(): string[];
|
|
28
|
+
/**
|
|
29
|
+
* Process an orchestrator action
|
|
30
|
+
*/
|
|
31
|
+
process(input: OrchestratorInput): Promise<OrchestratorOutput>;
|
|
32
|
+
/**
|
|
33
|
+
* Validate an execution plan
|
|
34
|
+
*/
|
|
35
|
+
private validatePlan;
|
|
36
|
+
/**
|
|
37
|
+
* Execute a plan with parallel processing
|
|
38
|
+
*/
|
|
39
|
+
private executePlan;
|
|
40
|
+
/**
|
|
41
|
+
* Execute a single task with error handling and retries
|
|
42
|
+
*/
|
|
43
|
+
private executeTask;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve input placeholders with outputs from previous tasks
|
|
46
|
+
* Supports syntax: "${taskId.property}" or "${taskId}"
|
|
47
|
+
*/
|
|
48
|
+
private resolveInput;
|
|
49
|
+
private resolveValue;
|
|
50
|
+
private resolvePlaceholder;
|
|
51
|
+
/**
|
|
52
|
+
* Execute a promise with timeout
|
|
53
|
+
*/
|
|
54
|
+
private executeWithTimeout;
|
|
55
|
+
/**
|
|
56
|
+
* Get execution status for a plan
|
|
57
|
+
*/
|
|
58
|
+
private getExecutionStatus;
|
|
59
|
+
/**
|
|
60
|
+
* Format execution summary for display
|
|
61
|
+
*/
|
|
62
|
+
private formatExecutionSummary;
|
|
63
|
+
}
|
|
64
|
+
export declare const orchestratorManager: OrchestratorManager;
|
|
65
|
+
//# sourceMappingURL=orchestrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../src/orchestrator.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAMV,iBAAiB,EACjB,kBAAkB,EAElB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;GASG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,gBAAgB,CAA2C;;IAMnE;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAmH5B;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;IAIxC;;OAEG;IACH,kBAAkB,IAAI,MAAM,EAAE;IAI9B;;OAEG;IACG,OAAO,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAgBpE;;OAEG;IACH,OAAO,CAAC,YAAY;IAsCpB;;OAEG;YACW,WAAW;IAmGzB;;OAEG;YACW,WAAW;IAsGzB;;;OAGG;IACH,OAAO,CAAC,YAAY;IAapB,OAAO,CAAC,YAAY;IA6BpB,OAAO,CAAC,kBAAkB;IA0B1B;;OAEG;YACW,kBAAkB;IAShC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAuB1B;;OAEG;IACH,OAAO,CAAC,sBAAsB;CA4B/B;AAGD,eAAO,MAAM,mBAAmB,qBAA4B,CAAC"}
|