@jieshe/mcp-sequentialthinking-tools 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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Scott Spence
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,264 @@
1
+ # mcp-sequentialthinking-tools
2
+
3
+ An adaptation of the
4
+ [MCP Sequential Thinking Server](https://github.com/modelcontextprotocol/servers/blob/main/src/sequentialthinking/index.ts)
5
+ designed to guide tool usage in problem-solving. This server helps
6
+ break down complex problems into manageable steps and provides
7
+ recommendations for which MCP tools would be most effective at each
8
+ stage.
9
+
10
+ <a href="https://glama.ai/mcp/servers/zl990kfusy">
11
+ <img width="380" height="200" src="https://glama.ai/mcp/servers/zl990kfusy/badge" />
12
+ </a>
13
+
14
+ A Model Context Protocol (MCP) server that combines sequential
15
+ thinking with intelligent tool suggestions. For each step in the
16
+ problem-solving process, it provides confidence-scored recommendations
17
+ for which tools to use, along with rationale for why each tool would
18
+ be appropriate.
19
+
20
+ ## Features
21
+
22
+ - 🤔 Dynamic and reflective problem-solving through sequential
23
+ thoughts
24
+ - 🔄 Flexible thinking process that adapts and evolves
25
+ - 🌳 Support for branching and revision of thoughts
26
+ - 🛠️ LLM-driven intelligent tool recommendations for each step
27
+ - 📊 Confidence scoring for tool suggestions
28
+ - 🔍 Detailed rationale for tool recommendations
29
+ - 📝 Step tracking with expected outcomes
30
+ - 🔄 Progress monitoring with previous and remaining steps
31
+ - 🎯 Alternative tool suggestions for each step
32
+ - 🧠 Memory management with configurable history limits
33
+ - 🗑️ Manual history cleanup capabilities
34
+
35
+ ## How It Works
36
+
37
+ This server facilitates sequential thinking with MCP tool coordination. The LLM analyzes available tools and their descriptions to make intelligent recommendations, which are then tracked and organized by this server.
38
+
39
+ The workflow:
40
+ 1. LLM provides available MCP tools to the sequential thinking server
41
+ 2. LLM analyzes each thought step and recommends appropriate tools
42
+ 3. Server tracks recommendations, maintains context, and manages memory
43
+ 4. LLM executes recommended tools and continues the thinking process
44
+
45
+ Each recommendation includes:
46
+ - A confidence score (0-1) indicating how well the tool matches the need
47
+ - A clear rationale explaining why the tool would be helpful
48
+ - A priority level to suggest tool execution order
49
+ - Suggested input parameters for the tool
50
+ - Alternative tools that could also be used
51
+
52
+ The server works with any MCP tools available in your environment and automatically manages memory to prevent unbounded growth.
53
+
54
+ ## Example Usage
55
+
56
+ Here's an example of how the server guides tool usage:
57
+
58
+ ```json
59
+ {
60
+ "thought": "Initial research step to understand what universal reactivity means in Svelte 5",
61
+ "current_step": {
62
+ "step_description": "Gather initial information about Svelte 5's universal reactivity",
63
+ "expected_outcome": "Clear understanding of universal reactivity concept",
64
+ "recommended_tools": [
65
+ {
66
+ "tool_name": "search_docs",
67
+ "confidence": 0.9,
68
+ "rationale": "Search Svelte documentation for official information",
69
+ "priority": 1
70
+ },
71
+ {
72
+ "tool_name": "tavily_search",
73
+ "confidence": 0.8,
74
+ "rationale": "Get additional context from reliable sources",
75
+ "priority": 2
76
+ }
77
+ ],
78
+ "next_step_conditions": [
79
+ "Verify information accuracy",
80
+ "Look for implementation details"
81
+ ]
82
+ },
83
+ "thought_number": 1,
84
+ "total_thoughts": 5,
85
+ "next_thought_needed": true
86
+ }
87
+ ```
88
+
89
+ The server tracks your progress and supports:
90
+
91
+ - Creating branches to explore different approaches
92
+ - Revising previous thoughts with new information
93
+ - Maintaining context across multiple steps
94
+ - Suggesting next steps based on current findings
95
+
96
+ ## Configuration
97
+
98
+ This server requires configuration through your MCP client. Here are
99
+ examples for different environments:
100
+
101
+ ### Cline Configuration
102
+
103
+ Add this to your Cline MCP settings:
104
+
105
+ ```json
106
+ {
107
+ "mcpServers": {
108
+ "mcp-sequentialthinking-tools": {
109
+ "command": "npx",
110
+ "args": ["-y", "mcp-sequentialthinking-tools"],
111
+ "env": {
112
+ "MAX_HISTORY_SIZE": "1000"
113
+ }
114
+ }
115
+ }
116
+ }
117
+ ```
118
+
119
+ ### Claude Desktop with WSL Configuration
120
+
121
+ For WSL environments, add this to your Claude Desktop configuration:
122
+
123
+ ```json
124
+ {
125
+ "mcpServers": {
126
+ "mcp-sequentialthinking-tools": {
127
+ "command": "wsl.exe",
128
+ "args": [
129
+ "bash",
130
+ "-c",
131
+ "MAX_HISTORY_SIZE=1000 source ~/.nvm/nvm.sh && /home/username/.nvm/versions/node/v20.12.1/bin/npx mcp-sequentialthinking-tools"
132
+ ]
133
+ }
134
+ }
135
+ }
136
+ ```
137
+
138
+ ## API
139
+
140
+ The server implements a single MCP tool with configurable parameters:
141
+
142
+ ### sequentialthinking_tools
143
+
144
+ A tool for dynamic and reflective problem-solving through thoughts,
145
+ with intelligent tool recommendations.
146
+
147
+ Parameters:
148
+
149
+ - `available_mcp_tools` (array, required): Array of MCP tool names available for use (e.g., ["mcp-omnisearch", "mcp-turso-cloud"])
150
+ - `thought` (string, required): Your current thinking step
151
+ - `next_thought_needed` (boolean, required): Whether another thought
152
+ step is needed
153
+ - `thought_number` (integer, required): Current thought number
154
+ - `total_thoughts` (integer, required): Estimated total thoughts
155
+ needed
156
+ - `is_revision` (boolean, optional): Whether this revises previous
157
+ thinking
158
+ - `revises_thought` (integer, optional): Which thought is being
159
+ reconsidered
160
+ - `branch_from_thought` (integer, optional): Branching point thought
161
+ number
162
+ - `branch_id` (string, optional): Branch identifier
163
+ - `needs_more_thoughts` (boolean, optional): If more thoughts are
164
+ needed
165
+ - `current_step` (object, optional): Current step recommendation with:
166
+ - `step_description`: What needs to be done
167
+ - `recommended_tools`: Array of tool recommendations with confidence
168
+ scores
169
+ - `expected_outcome`: What to expect from this step
170
+ - `next_step_conditions`: Conditions for next step
171
+ - `previous_steps` (array, optional): Steps already recommended
172
+ - `remaining_steps` (array, optional): High-level descriptions of
173
+ upcoming steps
174
+
175
+ ## Memory Management
176
+
177
+ The server includes built-in memory management to prevent unbounded growth:
178
+
179
+ - **History Limit**: Configurable maximum number of thoughts to retain (default: 1000)
180
+ - **Automatic Trimming**: History automatically trims when limit is exceeded
181
+ - **Manual Cleanup**: Server provides methods to clear history when needed
182
+
183
+ ### Configuring History Size
184
+
185
+ You can configure the history size by setting the `MAX_HISTORY_SIZE` environment variable:
186
+
187
+ ```json
188
+ {
189
+ "mcpServers": {
190
+ "mcp-sequentialthinking-tools": {
191
+ "command": "npx",
192
+ "args": ["-y", "mcp-sequentialthinking-tools"],
193
+ "env": {
194
+ "MAX_HISTORY_SIZE": "500"
195
+ }
196
+ }
197
+ }
198
+ }
199
+ ```
200
+
201
+ Or for local development:
202
+ ```bash
203
+ MAX_HISTORY_SIZE=2000 npx mcp-sequentialthinking-tools
204
+ ```
205
+
206
+ ## Development
207
+
208
+ ### Setup
209
+
210
+ 1. Clone the repository
211
+ 2. Install dependencies:
212
+
213
+ ```bash
214
+ pnpm install
215
+ ```
216
+
217
+ 3. Build the project:
218
+
219
+ ```bash
220
+ pnpm build
221
+ ```
222
+
223
+ 4. Run in development mode:
224
+
225
+ ```bash
226
+ pnpm dev
227
+ ```
228
+
229
+ ### Publishing
230
+
231
+ The project uses changesets for version management. To publish:
232
+
233
+ 1. Create a changeset:
234
+
235
+ ```bash
236
+ pnpm changeset
237
+ ```
238
+
239
+ 2. Version the package:
240
+
241
+ ```bash
242
+ pnpm changeset version
243
+ ```
244
+
245
+ 3. Publish to npm:
246
+
247
+ ```bash
248
+ pnpm release
249
+ ```
250
+
251
+ ## Contributing
252
+
253
+ Contributions are welcome! Please feel free to submit a Pull Request.
254
+
255
+ ## License
256
+
257
+ MIT License - see the [LICENSE](LICENSE) file for details.
258
+
259
+ ## Acknowledgments
260
+
261
+ - Built on the
262
+ [Model Context Protocol](https://github.com/modelcontextprotocol)
263
+ - Adapted from the
264
+ [MCP Sequential Thinking Server](https://github.com/modelcontextprotocol/servers/blob/main/src/sequentialthinking/index.ts)
@@ -0,0 +1,11 @@
1
+ import type { ThoughtData, StepRecommendation } from './types.js';
2
+ /**
3
+ * Formats a step recommendation into a human-readable string.
4
+ */
5
+ export declare function formatRecommendation(step: StepRecommendation): string;
6
+ /**
7
+ * Formats a thought for terminal display with box-drawing characters.
8
+ * Properly handles ANSI escape codes and multi-line content for accurate border widths.
9
+ */
10
+ export declare function formatThought(thoughtData: ThoughtData): string;
11
+ //# sourceMappingURL=formatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGlE;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,CAkBrE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAsD9D"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Output formatting for sequential thinking thoughts.
3
+ * Handles ANSI-safe border calculation and multi-line content.
4
+ */
5
+ import chalk from 'chalk';
6
+ import { visualLength, maxLineWidth } from './utils.js';
7
+ /**
8
+ * Formats a step recommendation into a human-readable string.
9
+ */
10
+ export function formatRecommendation(step) {
11
+ const tools = step.recommended_tools
12
+ .map((tool) => {
13
+ const alternatives = tool.alternatives?.length
14
+ ? ` (alternatives: ${tool.alternatives.join(', ')})`
15
+ : '';
16
+ const inputs = tool.suggested_inputs
17
+ ? `\n Suggested inputs: ${JSON.stringify(tool.suggested_inputs)}`
18
+ : '';
19
+ return ` - ${tool.tool_name} (priority: ${tool.priority})${alternatives}\n Rationale: ${tool.rationale}${inputs}`;
20
+ })
21
+ .join('\n');
22
+ const conditions = step.next_step_conditions
23
+ ? `\nConditions for next step:\n - ${step.next_step_conditions.join('\n - ')}`
24
+ : '';
25
+ return `Step: ${step.step_description}\nRecommended Tools:\n${tools}\nExpected Outcome: ${step.expected_outcome}${conditions}`;
26
+ }
27
+ /**
28
+ * Formats a thought for terminal display with box-drawing characters.
29
+ * Properly handles ANSI escape codes and multi-line content for accurate border widths.
30
+ */
31
+ export function formatThought(thoughtData) {
32
+ const { thought_number, total_thoughts, thought, is_revision, revises_thought, branch_from_thought, branch_id, current_step, } = thoughtData;
33
+ let prefix = '';
34
+ let context = '';
35
+ if (is_revision) {
36
+ prefix = chalk.yellow('🔄 Revision');
37
+ context = ` (revising thought ${revises_thought})`;
38
+ }
39
+ else if (branch_from_thought) {
40
+ prefix = chalk.green('🌿 Branch');
41
+ context = ` (from thought ${branch_from_thought}, ID: ${branch_id})`;
42
+ }
43
+ else {
44
+ prefix = chalk.blue('💭 Thought');
45
+ context = '';
46
+ }
47
+ const header = `${prefix} ${thought_number}/${total_thoughts}${context}`;
48
+ let content = thought;
49
+ if (current_step) {
50
+ content = `${thought}\n\nRecommendation:\n${formatRecommendation(current_step)}`;
51
+ }
52
+ // Use ANSI-stripped widths for accurate border calculation
53
+ const headerWidth = visualLength(header);
54
+ const contentWidth = maxLineWidth(content);
55
+ const borderLen = Math.max(headerWidth, contentWidth) + 4;
56
+ const border = '─'.repeat(borderLen);
57
+ // Pad each content line individually for proper box alignment
58
+ const contentLines = content.split('\n').map((line) => {
59
+ const padding = borderLen - 2 - visualLength(line);
60
+ return `│ ${line}${' '.repeat(Math.max(0, padding))} │`;
61
+ });
62
+ const headerPadding = borderLen - 2 - visualLength(header);
63
+ return [
64
+ `┌${border}┐`,
65
+ `│ ${header}${' '.repeat(Math.max(0, headerPadding))} │`,
66
+ `├${border}┤`,
67
+ ...contentLines,
68
+ `└${border}┘`,
69
+ ].join('\n');
70
+ }
71
+ //# sourceMappingURL=formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.js","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAExD;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAwB;IAC5D,MAAM,KAAK,GAAG,IAAI,CAAC,iBAAiB;SAClC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACb,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM;YAC7C,CAAC,CAAC,mBAAmB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;YACpD,CAAC,CAAC,EAAE,CAAC;QACN,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB;YACnC,CAAC,CAAC,2BAA2B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE;YACpE,CAAC,CAAC,EAAE,CAAC;QACN,OAAO,OAAO,IAAI,CAAC,SAAS,eAAe,IAAI,CAAC,QAAQ,IAAI,YAAY,oBAAoB,IAAI,CAAC,SAAS,GAAG,MAAM,EAAE,CAAC;IACvH,CAAC,CAAC;S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A2D;IAC3D,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;IAC1D,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAErC,8DAA8D;IAC9D,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACrD,MAAM,OAAO,GAAG,SAAS,GAAG,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QACnD,OAAO,KAAK,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,SAAS,GAAG,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IAE3D,OAAO;QACN,IAAI,MAAM,GAAG;QACb,KAAK,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,IAAI;QACxD,IAAI,MAAM,GAAG;QACb,GAAG,YAAY;QACf,IAAI,MAAM,GAAG;KACb,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC"}
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * MCP Sequential Thinking Server — Entry Point
4
+ *
5
+ * A slim bootstrap that wires up the server, registers the tool,
6
+ * and starts listening on stdio transport.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;GAKG"}
package/dist/index.js ADDED
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * MCP Sequential Thinking Server — Entry Point
4
+ *
5
+ * A slim bootstrap that wires up the server, registers the tool,
6
+ * and starts listening on stdio transport.
7
+ */
8
+ import { McpServer } from 'tmcp';
9
+ import { ValibotJsonSchemaAdapter } from '@tmcp/adapter-valibot';
10
+ import { StdioTransport } from '@tmcp/transport-stdio';
11
+ import { readFileSync } from 'node:fs';
12
+ import { dirname, join } from 'node:path';
13
+ import { fileURLToPath } from 'node:url';
14
+ import { SequentialThinkingSchema, SEQUENTIAL_THINKING_TOOL } from './schema.js';
15
+ import { ToolAwareSequentialThinkingServer } from './server.js';
16
+ // ---------------------------------------------------------------------------
17
+ // Package metadata
18
+ // ---------------------------------------------------------------------------
19
+ const __filename = fileURLToPath(import.meta.url);
20
+ const __dirname = dirname(__filename);
21
+ const packageJson = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf-8'));
22
+ const { name, version } = packageJson;
23
+ // ---------------------------------------------------------------------------
24
+ // MCP server setup
25
+ // ---------------------------------------------------------------------------
26
+ const adapter = new ValibotJsonSchemaAdapter();
27
+ const server = new McpServer({
28
+ name,
29
+ version,
30
+ description: 'MCP server for Sequential Thinking Tools',
31
+ }, {
32
+ adapter,
33
+ capabilities: {
34
+ tools: { listChanged: true },
35
+ },
36
+ });
37
+ // ---------------------------------------------------------------------------
38
+ // Core thinking server
39
+ // ---------------------------------------------------------------------------
40
+ const maxHistorySize = parseInt(process.env.MAX_HISTORY_SIZE || '1000');
41
+ const thinkingServer = new ToolAwareSequentialThinkingServer({
42
+ available_tools: [],
43
+ maxHistorySize,
44
+ });
45
+ // ---------------------------------------------------------------------------
46
+ // Register the sequential thinking tool
47
+ // ---------------------------------------------------------------------------
48
+ server.tool({
49
+ name: 'sequentialthinking_tools',
50
+ description: SEQUENTIAL_THINKING_TOOL.description,
51
+ schema: SequentialThinkingSchema,
52
+ }, async (input) => {
53
+ return thinkingServer.processThought(input);
54
+ });
55
+ // ---------------------------------------------------------------------------
56
+ // Start
57
+ // ---------------------------------------------------------------------------
58
+ async function main() {
59
+ const transport = new StdioTransport(server);
60
+ transport.listen();
61
+ console.error(`Sequential Thinking MCP Server v${version} running on stdio`);
62
+ }
63
+ main().catch((error) => {
64
+ console.error('Fatal error running server:', error);
65
+ process.exit(1);
66
+ });
67
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAEhE,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAC9E,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACtC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAC7B,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,EAAE,OAAO,CAAC,CACzD,CAAC;AACF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC;AAEtC,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAC9E,MAAM,OAAO,GAAG,IAAI,w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from './types.js';
3
+ export declare const ToolRecommendationSchema: v.ObjectSchema<{
4
+ readonly tool_name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "Name of the tool being recommended">]>;
5
+ readonly confidence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>, v.DescriptionAction<number, "0-1 indicating confidence in recommendation">]>;
6
+ readonly rationale: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "Why this tool is recommended">]>;
7
+ readonly priority: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.DescriptionAction<number, "Order in the recommendation sequence">]>;
8
+ readonly suggested_inputs: v.OptionalSchema<v.SchemaWithPipe<readonly [v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.DescriptionAction<{
9
+ [x: string]: unknown;
10
+ }, "Optional suggested parameters">]>, undefined>;
11
+ readonly alternatives: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.DescriptionAction<string[], "Alternative tools that could be used">]>, undefined>;
12
+ }, undefined>;
13
+ export declare const StepRecommendationSchema: v.ObjectSchema<{
14
+ readonly step_description: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "What needs to be done">]>;
15
+ readonly recommended_tools: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
16
+ readonly tool_name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "Name of the tool being recommended">]>;
17
+ readonly confidence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>, v.DescriptionAction<number, "0-1 indicating confidence in recommendation">]>;
18
+ readonly rationale: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "Why this tool is recommended">]>;
19
+ readonly priority: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.DescriptionAction<number, "Order in the recommendation sequence">]>;
20
+ readonly suggested_inputs: v.OptionalSchema<v.SchemaWithPipe<readonly [v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.DescriptionAction<{
21
+ [x: string]: unknown;
22
+ }, "Optional suggested parameters">]>, undefined>;
23
+ readonly alternatives: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.DescriptionAction<string[], "Alternative tools that could be used">]>, undefined>;
24
+ }, undefined>, undefined>, v.DescriptionAction<{
25
+ tool_name: string;
26
+ confidence: number;
27
+ rationale: string;
28
+ priority: number;
29
+ suggested_inputs?: {
30
+ [x: string]: unknown;
31
+ } | undefined;
32
+ alternatives?: string[] | undefined;
33
+ }[], "Tools recommended for this step">]>;
34
+ readonly expected_outcome: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "What to expect from this step">]>;
35
+ readonly next_step_conditions: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.DescriptionAction<string[], "Conditions to consider for the next step">]>, undefined>;
36
+ }, undefined>;
37
+ export declare const SequentialThinkingSchema: v.ObjectSchema<{
38
+ readonly available_mcp_tools: v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.DescriptionAction<string[], "Array of MCP tool names available for use (e.g., [\"mcp-omnisearch\", \"mcp-turso-cloud\"])">]>;
39
+ readonly thought: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "Your current thinking step">]>;
40
+ readonly next_thought_needed: v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "Whether another thought step is needed">]>;
41
+ readonly thought_number: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>, v.DescriptionAction<number, "Current thought number">]>;
42
+ readonly total_thoughts: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>, v.DescriptionAction<number, "Estimated total thoughts needed">]>;
43
+ readonly is_revision: v.OptionalSchema<v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "Whether this revises previous thinking">]>, undefined>;
44
+ readonly revises_thought: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>, v.DescriptionAction<number, "Which thought is being reconsidered">]>, undefined>;
45
+ readonly branch_from_thought: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>, v.DescriptionAction<number, "Branching point thought number">]>, undefined>;
46
+ readonly branch_id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "Branch identifier">]>, undefined>;
47
+ readonly needs_more_thoughts: v.OptionalSchema<v.SchemaWithPipe<readonly [v.BooleanSchema<undefined>, v.DescriptionAction<boolean, "If more thoughts are needed">]>, undefined>;
48
+ readonly current_step: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
49
+ readonly step_description: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "What needs to be done">]>;
50
+ readonly recommended_tools: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
51
+ readonly tool_name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "Name of the tool being recommended">]>;
52
+ readonly confidence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>, v.DescriptionAction<number, "0-1 indicating confidence in recommendation">]>;
53
+ readonly rationale: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "Why this tool is recommended">]>;
54
+ readonly priority: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.DescriptionAction<number, "Order in the recommendation sequence">]>;
55
+ readonly suggested_inputs: v.OptionalSchema<v.SchemaWithPipe<readonly [v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.DescriptionAction<{
56
+ [x: string]: unknown;
57
+ }, "Optional suggested parameters">]>, undefined>;
58
+ readonly alternatives: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.DescriptionAction<string[], "Alternative tools that could be used">]>, undefined>;
59
+ }, undefined>, undefined>, v.DescriptionAction<{
60
+ tool_name: string;
61
+ confidence: number;
62
+ rationale: string;
63
+ priority: number;
64
+ suggested_inputs?: {
65
+ [x: string]: unknown;
66
+ } | undefined;
67
+ alternatives?: string[] | undefined;
68
+ }[], "Tools recommended for this step">]>;
69
+ readonly expected_outcome: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "What to expect from this step">]>;
70
+ readonly next_step_conditions: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.DescriptionAction<string[], "Conditions to consider for the next step">]>, undefined>;
71
+ }, undefined>, v.DescriptionAction<{
72
+ step_description: string;
73
+ recommended_tools: {
74
+ tool_name: string;
75
+ confidence: number;
76
+ rationale: string;
77
+ priority: number;
78
+ suggested_inputs?: {
79
+ [x: string]: unknown;
80
+ } | undefined;
81
+ alternatives?: string[] | undefined;
82
+ }[];
83
+ expected_outcome: string;
84
+ next_step_conditions?: string[] | undefined;
85
+ }, "Current step recommendation">]>, undefined>;
86
+ readonly previous_steps: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
87
+ readonly step_description: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "What needs to be done">]>;
88
+ readonly recommended_tools: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
89
+ readonly tool_name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "Name of the tool being recommended">]>;
90
+ readonly confidence: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>, v.DescriptionAction<number, "0-1 indicating confidence in recommendation">]>;
91
+ readonly rationale: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "Why this tool is recommended">]>;
92
+ readonly priority: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.DescriptionAction<number, "Order in the recommendation sequence">]>;
93
+ readonly suggested_inputs: v.OptionalSchema<v.SchemaWithPipe<readonly [v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.DescriptionAction<{
94
+ [x: string]: unknown;
95
+ }, "Optional suggested parameters">]>, undefined>;
96
+ readonly alternatives: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.DescriptionAction<string[], "Alternative tools that could be used">]>, undefined>;
97
+ }, undefined>, undefined>, v.DescriptionAction<{
98
+ tool_name: string;
99
+ confidence: number;
100
+ rationale: string;
101
+ priority: number;
102
+ suggested_inputs?: {
103
+ [x: string]: unknown;
104
+ } | undefined;
105
+ alternatives?: string[] | undefined;
106
+ }[], "Tools recommended for this step">]>;
107
+ readonly expected_outcome: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "What to expect from this step">]>;
108
+ readonly next_step_conditions: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.DescriptionAction<string[], "Conditions to consider for the next step">]>, undefined>;
109
+ }, undefined>, undefined>, v.DescriptionAction<{
110
+ step_description: string;
111
+ recommended_tools: {
112
+ tool_name: string;
113
+ confidence: number;
114
+ rationale: string;
115
+ priority: number;
116
+ suggested_inputs?: {
117
+ [x: string]: unknown;
118
+ } | undefined;
119
+ alternatives?: string[] | undefined;
120
+ }[];
121
+ expected_outcome: string;
122
+ next_step_conditions?: string[] | undefined;
123
+ }[], "Steps already recommended">]>, undefined>;
124
+ readonly remaining_steps: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.DescriptionAction<string[], "High-level descriptions of upcoming steps">]>, undefined>;
125
+ }, undefined>;
126
+ export declare const SEQUENTIAL_THINKING_TOOL: Tool;
127
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAC7B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AA2EvC,eAAO,MAAM,wBAAwB;;;;;;;;;aA2BnC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;aAiBnC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAyDnC,CAAC;AAEH,eAAO,MAAM,wBAAwB,EAAE,IAItC,CAAC"}
package/dist/schema.js ADDED
@@ -0,0 +1,108 @@
1
+ import * as v from 'valibot';
2
+ const TOOL_DESCRIPTION = `A detailed tool for dynamic and reflective problem-solving through thoughts.
3
+ This tool helps analyze problems through a flexible thinking process that can adapt and evolve.
4
+ Each thought can build on, question, or revise previous insights as understanding deepens.
5
+
6
+ IMPORTANT: This server facilitates sequential thinking with MCP tool coordination. The LLM analyzes available tools and their descriptions to make intelligent recommendations, which are then tracked and organized by this server.
7
+
8
+ When to use this tool:
9
+ - Breaking down complex problems into steps
10
+ - Planning and design with room for revision
11
+ - Analysis that might need course correction
12
+ - Problems where the full scope might not be clear initially
13
+ - Problems that require a multi-step solution
14
+ - Tasks that need to maintain context over multiple steps
15
+ - Situations where irrelevant information needs to be filtered out
16
+ - When you need guidance on which tools to use and in what order
17
+
18
+ Key features:
19
+ - You can adjust total_thoughts up or down as you progress
20
+ - You can question or revise previous thoughts
21
+ - You can add more thoughts even after reaching what seemed like the end
22
+ - You can express uncertainty and explore alternative approaches
23
+ - Not every thought needs to build linearly - you can branch or backtrack
24
+ - Generates a solution hypothesis
25
+ - Verifies the hypothesis based on the Chain of Thought steps
26
+ - Recommends appropriate tools for each step
27
+ - Provides rationale for tool recommendations
28
+ - Suggests tool execution order and parameters
29
+ - Tracks previous recommendations and remaining steps
30
+
31
+ Parameters explained:
32
+ - available_mcp_tools: Array of MCP tool names that are available for use (e.g., ["mcp-omnisearch", "mcp-turso-cloud"])
33
+ - thought: Your current thinking step, which can include:
34
+ * Regular analytical steps
35
+ * Revisions of previous thoughts
36
+ * Questions about previous decisions
37
+ * Realizations about needing more analysis
38
+ * Changes in approach
39
+ * Hypothesis generation
40
+ * Hypothesis verification
41
+ * Tool recommendations and rationale
42
+ - next_thought_needed: True if you need more thinking, even if at what seemed like the end
43
+ - thought_number: Current number in sequence (can go beyond initial total if needed)
44
+ - total_thoughts: Current estimate of thoughts needed (can be adjusted up/down)
45
+ - is_revision: A boolean indicating if this thought revises previous thinking
46
+ - revises_thought: If is_revision is true, which thought number is being reconsidered
47
+ - branch_from_thought: If branching, which thought number is the branching point
48
+ - branch_id: Identifier for the current branch (if any)
49
+ - needs_more_thoughts: If reaching end but realizing more thoughts needed
50
+ - current_step: Current step recommendation, including:
51
+ * step_description: What needs to be done
52
+ * recommended_tools: Tools recommended for this step
53
+ * expected_outcome: What to expect from this step
54
+ * next_step_conditions: Conditions to consider for the next step
55
+ - previous_steps: Steps already recommended
56
+ - remaining_steps: High-level descriptions of upcoming steps
57
+
58
+ You should:
59
+ 1. Start with an initial estimate of needed thoughts, but be ready to adjust
60
+ 2. Feel free to question or revise previous thoughts
61
+ 3. Don't hesitate to add more thoughts if needed, even at the "end"
62
+ 4. Express uncertainty when present
63
+ 5. Mark thoughts that revise previous thinking or branch into new paths
64
+ 6. Ignore information that is irrelevant to the current step
65
+ 7. Generate a solution hypothesis when appropriate
66
+ 8. Verify the hypothesis based on the Chain of Thought steps
67
+ 9. Consider available tools that could help with the current step
68
+ 10. Provide clear rationale for tool recommendations
69
+ 11. Suggest specific tool parameters when appropriate
70
+ 12. Consider alternative tools for each step
71
+ 13. Track progress through the recommended steps
72
+ 14. Provide a single, ideally correct answer as the final output
73
+ 15. Only set next_thought_needed to false when truly done and a satisfactory answer is reached`;
74
+ export const ToolRecommendationSchema = v.object({
75
+ tool_name: v.pipe(v.string(), v.description('Name of the tool being recommended')),
76
+ confidence: v.pipe(v.number(), v.minValue(0), v.maxValue(1), v.description('0-1 indicating confidence in recommendation')),
77
+ rationale: v.pipe(v.string(), v.description('Why this tool is recommended')),
78
+ priority: v.pipe(v.number(), v.description('Order in the recommendation sequence')),
79
+ suggested_inputs: v.optional(v.pipe(v.record(v.string(), v.unknown()), v.description('Optional suggested parameters'))),
80
+ alternatives: v.optional(v.pipe(v.array(v.string()), v.description('Alternative tools that could be used')))
81
+ });
82
+ export const StepRecommendationSchema = v.object({
83
+ step_description: v.pipe(v.string(), v.description('What needs to be done')),
84
+ recommended_tools: v.pipe(v.array(ToolRecommendationSchema), v.description('Tools recommended for this step')),
85
+ expected_outcome: v.pipe(v.string(), v.description('What to expect from this step')),
86
+ next_step_conditions: v.optional(v.pipe(v.array(v.string()), v.description('Conditions to consider for the next step')))
87
+ });
88
+ export const SequentialThinkingSchema = v.object({
89
+ available_mcp_tools: v.pipe(v.array(v.string()), v.description('Array of MCP tool names available for use (e.g., ["mcp-omnisearch", "mcp-turso-cloud"])')),
90
+ thought: v.pipe(v.string(), v.description('Your current thinking step')),
91
+ next_thought_needed: v.pipe(v.boolean(), v.description('Whether another thought step is needed')),
92
+ thought_number: v.pipe(v.number(), v.minValue(1), v.description('Current thought number')),
93
+ total_thoughts: v.pipe(v.number(), v.minValue(1), v.description('Estimated total thoughts needed')),
94
+ is_revision: v.optional(v.pipe(v.boolean(), v.description('Whether this revises previous thinking'))),
95
+ revises_thought: v.optional(v.pipe(v.number(), v.minValue(1), v.description('Which thought is being reconsidered'))),
96
+ branch_from_thought: v.optional(v.pipe(v.number(), v.minValue(1), v.description('Branching point thought number'))),
97
+ branch_id: v.optional(v.pipe(v.string(), v.description('Branch identifier'))),
98
+ needs_more_thoughts: v.optional(v.pipe(v.boolean(), v.description('If more thoughts are needed'))),
99
+ current_step: v.optional(v.pipe(StepRecommendationSchema, v.description('Current step recommendation'))),
100
+ previous_steps: v.optional(v.pipe(v.array(StepRecommendationSchema), v.description('Steps already recommended'))),
101
+ remaining_steps: v.optional(v.pipe(v.array(v.string()), v.description('High-level descriptions of upcoming steps')))
102
+ });
103
+ export const SEQUENTIAL_THINKING_TOOL = {
104
+ name: 'sequentialthinking_tools',
105
+ description: TOOL_DESCRIPTION,
106
+ inputSchema: {} // This will be handled by tmcp with the schema above
107
+ };
108
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAG7B,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+FAuEsE,CAAC;AAEhG,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,SAAS,EAAE,CAAC,CAAC,IAAI,CAChB,CAAC,CAAC,MAAM,EAAE,EACV,CAAC,CAAC,WAAW,CAAC,oCAAoC,CAAC,CACnD;IACD,UAAU,EAAE,CAAC,CAAC,IAAI,CACjB,CAAC,CAAC,MAAM,EAAE,EACV,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EACb,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EACb,CAAC,CAAC,WAAW,CAAC,6CAA6C,CAAC,CAC5D;IACD,SAAS,EAAE,CAAC,CAAC,IAAI,CAChB,CAAC,CAAC,MAAM,EAAE,EACV,CAAC,CA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AC;IACF,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAC3B,CAAC,CAAC,MAAM,EAAE,EACV,CAAC,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAClC,CAAC;IACF,mBAAmB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CACrC,CAAC,CAAC,OAAO,EAAE,EACX,CAAC,CAAC,WAAW,CAAC,6BAA6B,CAAC,CAC5C,CAAC;IACF,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAC9B,wBAAwB,EACxB,CAAC,CAAC,WAAW,CAAC,6BAA6B,CAAC,CAC5C,CAAC;IACF,cAAc,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAChC,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC,EACjC,CAAC,CAAC,WAAW,CAAC,2BAA2B,CAAC,CAC1C,CAAC;IACF,eAAe,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CACjC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EACnB,CAAC,CAAC,WAAW,CAAC,2CAA2C,CAAC,CAC1D,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAS;IAC7C,IAAI,EAAE,0BAA0B;IAChC,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EAAE,EAAE,CAAC,qDAAqD;CACrE,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Core Sequential Thinking Server with tool-aware capabilities.
3
+ *
4
+ * Responsibilities:
5
+ * - Process and store thought chains with branching/revision support
6
+ * - Track tool recommendations per step
7
+ * - Manage memory with configurable history limits
8
+ */
9
+ import type * as v from 'valibot';
10
+ import type { SequentialThinkingSchema } from './schema.js';
11
+ import type { Tool, ServerOptions } from './types.js';
12
+ export declare class ToolAwareSequentialThinkingServer {
13
+ private thoughtHistory;
14
+ private branches;
15
+ private availableTools;
16
+ private readonly maxHistorySize;
17
+ constructor(options?: ServerOptions);
18
+ /** Returns a snapshot of all registered tools. */
19
+ getAvailableTools(): Tool[];
20
+ /** Returns the current thought history length. */
21
+ getHistoryLength(): number;
22
+ /** Returns the current branch IDs. */
23
+ getBranchIds(): string[];
24
+ /** Clears all thought history and branches. */
25
+ clearHistory(): void;
26
+ /** Registers a new tool. Rejects duplicates. */
27
+ addTool(tool: Tool): void;
28
+ /**
29
+ * Processes a single thought step.
30
+ *
31
+ * Key behaviors:
32
+ * - Auto-adjusts total_thoughts if thought_number exceeds it
33
+ * - Deep-clones input before mutation to prevent side effects
34
+ * - Trims history when maxHistorySize is exceeded
35
+ * - Tracks branch membership for branched thoughts
36
+ */
37
+ processThought(input: v.InferInput<typeof SequentialThinkingSchema>): Promise<{
38
+ content: {
39
+ type: "text";
40
+ text: string;
41
+ }[];
42
+ isError?: undefined;
43
+ } | {
44
+ content: {
45
+ type: "text";
46
+ text: string;
47
+ }[];
48
+ isError: boolean;
49
+ }>;
50
+ }
51
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,KAAK,CAAC,MAAM,SAAS,CAAC;AAClC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAe,IAAI,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAKnE,qBAAa,iCAAiC;IAC7C,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,QAAQ,CAAqC;IACrD,OAAO,CAAC,cAAc,CAAgC;IACtD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;gBAE5B,OAAO,GAAE,aAAkB;IAyBvC,kDAAkD;IAC3C,iBAAiB,IAAI,IAAI,EAAE;IAIlC,kDAAkD;IAC3C,gBAAgB,IAAI,MAAM;IAIjC,sCAAsC;IAC/B,YAAY,IAAI,MAAM,EAAE;IAI/B,+CAA+C;IACxC,YAAY,IAAI,IAAI;IAM3B,gDAAgD;IACzC,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAShC;;;;;;;;OAQG;IACU,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,UAAU,CAAC,OAAO,wBAAwB,CAAC;;;;;;;;;;;;;CAmFhF"}
package/dist/server.js ADDED
@@ -0,0 +1,130 @@
1
+ import { SEQUENTIAL_THINKING_TOOL } from './schema.js';
2
+ import { formatThought } from './formatter.js';
3
+ import { deepClone } from './utils.js';
4
+ export class ToolAwareSequentialThinkingServer {
5
+ thoughtHistory = [];
6
+ branches = {};
7
+ availableTools = new Map();
8
+ maxHistorySize;
9
+ constructor(options = {}) {
10
+ this.maxHistorySize = options.maxHistorySize || 1000;
11
+ // Always include the sequential thinking tool itself
12
+ const tools = [
13
+ SEQUENTIAL_THINKING_TOOL,
14
+ ...(options.available_tools || []),
15
+ ];
16
+ for (const tool of tools) {
17
+ if (this.availableTools.has(tool.name)) {
18
+ console.error(`Warning: Duplicate tool name '${tool.name}' - using first occurrence`);
19
+ continue;
20
+ }
21
+ this.availableTools.set(tool.name, tool);
22
+ }
23
+ console.error('Available tools:', Array.from(this.availableTools.keys()));
24
+ }
25
+ /** Returns a snapshot of all registered tools. */
26
+ getAvailableTools() {
27
+ return Array.from(this.availableTools.values());
28
+ }
29
+ /** Returns the current thought history length. */
30
+ getHistoryLength() {
31
+ return this.thoughtHistory.length;
32
+ }
33
+ /** Returns the current branch IDs. */
34
+ getBranchIds() {
35
+ return Object.keys(this.branches);
36
+ }
37
+ /** Clears all thought history and branches. */
38
+ clearHistory() {
39
+ this.thoughtHistory = [];
40
+ this.branches = {};
41
+ console.error('History cleared');
42
+ }
43
+ /** Registers a new tool. Rejects duplicates. */
44
+ addTool(tool) {
45
+ if (this.availableTools.has(tool.name)) {
46
+ console.error(`Warning: Tool '${tool.name}' already exists`);
47
+ return;
48
+ }
49
+ this.availableTools.set(tool.name, tool);
50
+ console.error(`Added tool: ${tool.name}`);
51
+ }
52
+ /**
53
+ * Processes a single thought step.
54
+ *
55
+ * Key behaviors:
56
+ * - Auto-adjusts total_thoughts if thought_number exceeds it
57
+ * - Deep-clones input before mutation to prevent side effects
58
+ * - Trims history when maxHistorySize is exceeded
59
+ * - Tracks branch membership for branched thoughts
60
+ */
61
+ async processThought(input) {
62
+ try {
63
+ // Deep clone to prevent mutation of the caller's input object
64
+ const thoughtData = deepClone(input);
65
+ // Auto-adjust total if thought_number exceeds estimate
66
+ if (thoughtData.thought_number > thoughtData.total_thoughts) {
67
+ thoughtData.total_thoughts = thoughtData.thought_number;
68
+ }
69
+ // Accumulate current step into previous_steps history
70
+ if (thoughtData.current_step) {
71
+ if (!thoughtData.previous_steps) {
72
+ thoughtData.previous_steps = [];
73
+ }
74
+ thoughtData.previous_steps.push(deepClone(thoughtData.current_step));
75
+ }
76
+ // Store in history
77
+ this.thoughtHistory.push(thoughtData);
78
+ // Prevent memory leaks by trimming oldest entries
79
+ if (this.thoughtHistory.length > this.maxHistorySize) {
80
+ this.thoughtHistory = this.thoughtHistory.slice(-this.maxHistorySize);
81
+ console.error(`History trimmed to ${this.maxHistorySize} items`);
82
+ }
83
+ // Track branch membership
84
+ if (thoughtData.branch_from_thought && thoughtData.branch_id) {
85
+ if (!this.branches[thoughtData.branch_id]) {
86
+ this.branches[thoughtData.branch_id] = [];
87
+ }
88
+ this.branches[thoughtData.branch_id].push(thoughtData);
89
+ }
90
+ // Format and log to stderr for debugging
91
+ const formattedThought = formatThought(thoughtData);
92
+ console.error(formattedThought);
93
+ return {
94
+ content: [
95
+ {
96
+ type: 'text',
97
+ text: JSON.stringify({
98
+ thought_number: thoughtData.thought_number,
99
+ total_thoughts: thoughtData.total_thoughts,
100
+ next_thought_needed: thoughtData.next_thought_needed,
101
+ branches: Object.keys(this.branches),
102
+ thought_history_length: this.thoughtHistory.length,
103
+ available_mcp_tools: thoughtData.available_mcp_tools,
104
+ current_step: thoughtData.current_step,
105
+ previous_steps: thoughtData.previous_steps,
106
+ remaining_steps: thoughtData.remaining_steps,
107
+ }, null, 2),
108
+ },
109
+ ],
110
+ };
111
+ }
112
+ catch (error) {
113
+ return {
114
+ content: [
115
+ {
116
+ type: 'text',
117
+ text: JSON.stringify({
118
+ error: error instanceof Error
119
+ ? error.message
120
+ : String(error),
121
+ status: 'failed',
122
+ }, null, 2),
123
+ },
124
+ ],
125
+ isError: true,
126
+ };
127
+ }
128
+ }
129
+ }
130
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,OAAO,iCAAiC;IACrC,cAAc,GAAkB,EAAE,CAAC;IACnC,QAAQ,GAAkC,EAAE,CAAC;IAC7C,cAAc,GAAsB,IAAI,GAAG,EAAE,CAAC;IACrC,cAAc,CAAS;IAExC,YAAY,UAAyB,EAAE;QACtC,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,IAAI,CAAC;QAErD,qDAAqD;QACrD,MAAM,KAAK,GAAG;YACb,wBAAwB;YACxB,GAAG,CAAC,OAAO,CAAC,eAAe,IAAI,EAAE,CAAC;SAClC,CAAC;QAEF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YAC1B,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxC,OAAO,CAAC,KAAK,CACZ,iCAAiC,IAAI,CAAC,IAAI,4BAA4B,CACtE,CAAC;gBACF,SAAS;YACV,CAAC;YACD,IAAI,CAAC,cAAc,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AC,gBAAgB,CAAC,CAAC;YAEhC,OAAO;gBACN,OAAO,EAAE;oBACR;wBACC,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CACnB;4BACC,cAAc,EAAE,WAAW,CAAC,cAAc;4BAC1C,cAAc,EAAE,WAAW,CAAC,cAAc;4BAC1C,mBAAmB,EAAE,WAAW,CAAC,mBAAmB;4BACpD,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;4BACpC,sBAAsB,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM;4BAClD,mBAAmB,EAAE,WAAW,CAAC,mBAAmB;4BACpD,YAAY,EAAE,WAAW,CAAC,YAAY;4BACtC,cAAc,EAAE,WAAW,CAAC,cAAc;4BAC1C,eAAe,EAAE,WAAW,CAAC,eAAe;yBAC5C,EACD,IAAI,EACJ,CAAC,CACD;qBACD;iBACD;aACD,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO;gBACN,OAAO,EAAE;oBACR;wBACC,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CACnB;4BACC,KAAK,EACJ,KAAK,YAAY,KAAK;gCACrB,CAAC,CAAC,KAAK,CAAC,OAAO;gCACf,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;4BACjB,MAAM,EAAE,QAAQ;yBAChB,EACD,IAAI,EACJ,CAAC,CACD;qBACD;iBACD;gBACD,OAAO,EAAE,IAAI;aACb,CAAC;QACH,CAAC;IACF,CAAC;CACD"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Type definitions derived from Valibot schemas (Single Source of Truth).
3
+ * Manual interface definitions are eliminated to avoid duplication.
4
+ */
5
+ import type * as v from 'valibot';
6
+ import type { ToolRecommendationSchema, StepRecommendationSchema, SequentialThinkingSchema } from './schema.js';
7
+ /** A tool recommendation with confidence scoring */
8
+ export type ToolRecommendation = v.InferOutput<typeof ToolRecommendationSchema>;
9
+ /** A step recommendation with tool suggestions */
10
+ export type StepRecommendation = v.InferOutput<typeof StepRecommendationSchema>;
11
+ /** The full thought data structure */
12
+ export type ThoughtData = v.InferOutput<typeof SequentialThinkingSchema>;
13
+ /** MCP tool definition */
14
+ export interface Tool {
15
+ name: string;
16
+ description: string;
17
+ inputSchema: Record<string, unknown>;
18
+ }
19
+ /** Options for constructing the SequentialThinking server */
20
+ export interface ServerOptions {
21
+ available_tools?: Tool[];
22
+ maxHistorySize?: number;
23
+ }
24
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,KAAK,CAAC,MAAM,SAAS,CAAC;AAClC,OAAO,KAAK,EACX,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACxB,MAAM,aAAa,CAAC;AAErB,oDAAoD;AACpD,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEhF,kDAAkD;AAClD,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEhF,sCAAsC;AACtC,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEzE,0BAA0B;AAC1B,MAAM,WAAW,IAAI;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED,6DAA6D;AAC7D,MAAM,WAAW,aAAa;IAC7B,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Utility functions for the Sequential Thinking server.
3
+ */
4
+ /**
5
+ * Deep clones a value using structured clone.
6
+ * Used to prevent mutation side effects when modifying input data.
7
+ */
8
+ export declare function deepClone<T>(value: T): T;
9
+ /**
10
+ * Strips ANSI escape codes from a string.
11
+ * Used to get accurate character widths for terminal border formatting.
12
+ */
13
+ export declare function stripAnsi(str: string): string;
14
+ /**
15
+ * Gets the visual display width of a string, ignoring ANSI codes.
16
+ */
17
+ export declare function visualLength(str: string): number;
18
+ /**
19
+ * Returns the maximum visual line width from a potentially multi-line string.
20
+ */
21
+ export declare function maxLineWidth(str: string): number;
22
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAExC;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI7C;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGhD"}
package/dist/utils.js ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Utility functions for the Sequential Thinking server.
3
+ */
4
+ /**
5
+ * Deep clones a value using structured clone.
6
+ * Used to prevent mutation side effects when modifying input data.
7
+ */
8
+ export function deepClone(value) {
9
+ return structuredClone(value);
10
+ }
11
+ /**
12
+ * Strips ANSI escape codes from a string.
13
+ * Used to get accurate character widths for terminal border formatting.
14
+ */
15
+ export function stripAnsi(str) {
16
+ // Matches all ANSI escape sequences (colors, cursor, etc.)
17
+ // eslint-disable-next-line no-control-regex
18
+ return str.replace(/\u001B\[[0-9;]*[a-zA-Z]/g, '');
19
+ }
20
+ /**
21
+ * Gets the visual display width of a string, ignoring ANSI codes.
22
+ */
23
+ export function visualLength(str) {
24
+ return stripAnsi(str).length;
25
+ }
26
+ /**
27
+ * Returns the maximum visual line width from a potentially multi-line string.
28
+ */
29
+ export function maxLineWidth(str) {
30
+ const lines = str.split('\n');
31
+ return Math.max(...lines.map(visualLength));
32
+ }
33
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAI,KAAQ;IACpC,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW;IACpC,2DAA2D;IAC3D,4CAA4C;IAC5C,OAAO,GAAG,CAAC,OAAO,CAAC,0BAA0B,EAAE,EAAE,CAAC,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACvC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACvC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;AAC7C,CAAC"}
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@jieshe/mcp-sequentialthinking-tools",
3
+ "version": "1.0.0",
4
+ "description": "MCP server for Sequential Thinking Tools",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "mcp-sequentialthinking-tools": "./dist/index.js"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public",
13
+ "registry": "https://registry.npmjs.org"
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc",
22
+ "start": "node dist/index.js",
23
+ "dev": "npx @modelcontextprotocol/inspector dist/index.js",
24
+ "test": "vitest run",
25
+ "test:watch": "vitest",
26
+ "changeset": "changeset",
27
+ "version": "changeset version",
28
+ "release": "pnpm run build && changeset publish"
29
+ },
30
+ "keywords": [
31
+ "mcp",
32
+ "model-context-protocol",
33
+ "sequential-thinking",
34
+ "problem-solving",
35
+ "tool-recommendation",
36
+ "decision-making",
37
+ "thought-process",
38
+ "step-by-step",
39
+ "llm",
40
+ "ai",
41
+ "branching-thoughts",
42
+ "thought-revision",
43
+ "tool-analysis",
44
+ "problem-breakdown",
45
+ "solution-planning",
46
+ "adaptive-thinking",
47
+ "reflective-analysis",
48
+ "tool-confidence"
49
+ ],
50
+ "author": "Scott Spence",
51
+ "license": "MIT",
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "https://github.com/JIEeshe/mcp-sequentialthinking-tools.git"
55
+ },
56
+ "bugs": {
57
+ "url": "https://github.com/spences10/mcp-sequentialthinking-tools/issues"
58
+ },
59
+ "homepage": "https://github.com/spences10/mcp-sequentialthinking-tools#readme",
60
+ "dependencies": {
61
+ "@tmcp/adapter-valibot": "^0.1.5",
62
+ "@tmcp/transport-stdio": "^0.4.2",
63
+ "chalk": "^5.6.2",
64
+ "tmcp": "^1.19.3",
65
+ "valibot": "^1.3.1"
66
+ },
67
+ "devDependencies": {
68
+ "@changesets/cli": "^2.30.0",
69
+ "@types/node": "^25.5.0",
70
+ "typescript": "^6.0.2",
71
+ "vitest": "^4.1.1"
72
+ }
73
+ }