@gotza02/sequential-thinking 2026.1.31 → 2026.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 +182 -247
- package/dist/index.js +11 -555
- package/dist/tools/filesystem.js +152 -0
- package/dist/tools/graph.js +79 -0
- package/dist/tools/notes.js +55 -0
- package/dist/tools/thinking.js +113 -0
- package/dist/tools/web.js +137 -0
- package/dist/utils.js +35 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,302 +1,237 @@
|
|
|
1
|
-
# Sequential Thinking MCP Server
|
|
1
|
+
# Sequential Thinking MCP Server (Extended Edition) 🧠✨
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**MCP Server ที่ช่วยให้ AI "คิดก่อนทำ" อย่างเป็นระบบ พร้อมความสามารถในการค้นหาเว็บ, วิเคราะห์โค้ด และจดจำข้อมูลระยะยาว**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
โปรเจกต์นี้คือส่วนขยายของ Sequential Thinking ที่เพิ่มเครื่องมือสำคัญเพื่อให้ AI ทำงานเป็น "Autonomous Agent" ได้อย่างสมบูรณ์แบบ ทั้งการวางแผน (Planning), การหาข้อมูล (Research), และการลงมือทำ (Execution)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- **Iterative Reasoning**: Think step-by-step in a structured manner, refining insights in loops.
|
|
9
|
-
- **Tree of Thoughts**: Generate and evaluate multiple options, exploring Conservative, Balanced, and Aggressive strategies.
|
|
10
|
-
- **Self-Critique**: Actively check for risks, biases, and potential errors in the thinking process.
|
|
11
|
-
- **Branch Merging**: Synthesize and combine insights from multiple divergent reasoning paths.
|
|
12
|
-
- **Hypothesis Testing**: Formulate specific hypotheses and verify them against evidence or logic.
|
|
13
|
-
- **Option Evaluation**: Score and weigh different options (`evaluation`) to make informed decisions.
|
|
14
|
-
- **Self-Reflexion**: Review and correct previous thoughts (`reflexion`) to improve accuracy.
|
|
15
|
-
- **Dynamic Adjustment**: Adjust the total number of thoughts dynamically as understanding deepens.
|
|
7
|
+
---
|
|
16
8
|
|
|
17
|
-
##
|
|
9
|
+
## 🔑 Environment Variables (การตั้งค่าตัวแปร)
|
|
18
10
|
|
|
19
|
-
|
|
11
|
+
นี่คือตัวแปรทั้งหมดที่ระบบรองรับ คุณสามารถเลือกตั้งค่าได้ตามฟีเจอร์ที่ต้องการใช้งาน:
|
|
20
12
|
|
|
21
|
-
1.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
### 1. Web Search APIs (เลือกอย่างน้อย 1 อย่างเพื่อใช้ `web_search`)
|
|
14
|
+
| Variable Name | Description | Required? |
|
|
15
|
+
|--------------|-------------|-----------|
|
|
16
|
+
| `BRAVE_API_KEY` | สำหรับค้นหาผ่าน Brave Search | ❌ (Optional) |
|
|
17
|
+
| `EXA_API_KEY` | สำหรับค้นหาผ่าน Exa.ai (แนะนำสำหรับงาน Deep Research) | ❌ (Optional) |
|
|
18
|
+
| `GOOGLE_SEARCH_API_KEY` | Google Custom Search API Key | ❌ (Optional) |
|
|
19
|
+
| `GOOGLE_SEARCH_CX` | Google Custom Search Engine ID (CX) | ❌ (Optional) |
|
|
26
20
|
|
|
27
|
-
|
|
21
|
+
### 2. Storage & Memory (การจัดเก็บข้อมูล)
|
|
22
|
+
| Variable Name | Description | Default Value |
|
|
23
|
+
|--------------|-------------|---------------|
|
|
24
|
+
| `THOUGHTS_STORAGE_PATH` | ไฟล์เก็บประวัติการคิด (Thinking History) | `thoughts_history.json` |
|
|
25
|
+
| `NOTES_STORAGE_PATH` | ไฟล์เก็บความจำระยะยาว (Long-term Notes) | `project_notes.json` |
|
|
28
26
|
|
|
29
|
-
###
|
|
27
|
+
### 3. System Behavior (พฤติกรรมระบบ)
|
|
28
|
+
| Variable Name | Description | Default Value |
|
|
29
|
+
|--------------|-------------|---------------|
|
|
30
|
+
| `THOUGHT_DELAY_MS` | เวลาหน่วงระหว่างความคิด (ms) เพื่อกัน Rate Limit | `0` |
|
|
31
|
+
| `DISABLE_THOUGHT_LOGGING`| ปิดการแสดงผล Log สีสวยงามใน Console (`true`/`false`) | `false` |
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
The core engine for structured problem-solving. It forces a step-by-step analysis before arriving at a conclusion.
|
|
33
|
+
---
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
- `thought` (string, required): The content of the current thinking step.
|
|
36
|
-
- `thoughtNumber` (integer, required): Current step number (starts at 1).
|
|
37
|
-
- `totalThoughts` (integer, required): Estimated total steps needed (can be adjusted dynamically).
|
|
38
|
-
- `nextThoughtNeeded` (boolean, required): `true` if you need to think more, `false` only when the final answer is ready.
|
|
39
|
-
- `thoughtType` (enum): The nature of the thought:
|
|
40
|
-
- `analysis`: Breaking down the problem.
|
|
41
|
-
- `generation`: Brainstorming solutions.
|
|
42
|
-
- `evaluation`: Weighing options (use with `score`).
|
|
43
|
-
- `reflexion`: Reviewing previous thoughts (use with `isRevision`).
|
|
44
|
-
- `selection`: Choosing a path.
|
|
45
|
-
- `isRevision` (boolean): Set to `true` if you are correcting a previous mistake.
|
|
46
|
-
- `revisesThought` (integer): The thought number you are fixing.
|
|
47
|
-
- `branchFromThought` (integer): The parent thought number if creating a new reasoning branch.
|
|
48
|
-
- `branchId` (string): A name for the new branch.
|
|
35
|
+
## 🚀 Installation & Usage (การติดตั้งและใช้งาน)
|
|
49
36
|
|
|
50
|
-
|
|
37
|
+
สามารถติดตั้งผ่าน npm ได้โดยตรง:
|
|
51
38
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
#### `summarize_history`
|
|
56
|
-
Compresses multiple thoughts into a single summary thought. This is essential for long reasoning chains to save token context while preserving the core insights.
|
|
57
|
-
|
|
58
|
-
**Inputs:**
|
|
59
|
-
- `startIndex` (integer): Start of the range to summarize.
|
|
60
|
-
- `endIndex` (integer): End of the range to summarize.
|
|
61
|
-
- `summary` (string): The summary text that replaces the range.
|
|
62
|
-
|
|
63
|
-
### 🌐 External Knowledge
|
|
64
|
-
|
|
65
|
-
#### `web_search`
|
|
66
|
-
Retrieves real-time information from the internet.
|
|
67
|
-
|
|
68
|
-
**Inputs:**
|
|
69
|
-
- `query` (string, required): What you want to find.
|
|
70
|
-
- `provider` (enum, optional):
|
|
71
|
-
- `brave`: General web search (Requires `BRAVE_API_KEY`).
|
|
72
|
-
- `exa`: AI-optimized search for deep content (Requires `EXA_API_KEY`).
|
|
73
|
-
- `google`: Google Custom Search (Requires `GOOGLE_SEARCH_API_KEY` & `GOOGLE_SEARCH_CX`).
|
|
74
|
-
|
|
75
|
-
#### `fetch`
|
|
76
|
-
Performs a direct HTTP request to a URL. Useful for getting raw HTML, JSON, or text from a specific source found via search.
|
|
77
|
-
|
|
78
|
-
**Inputs:**
|
|
79
|
-
- `url` (string, required): The target URL.
|
|
80
|
-
- `method`: `GET` (default), `POST`, `PUT`, `DELETE`.
|
|
81
|
-
- `headers`: JSON object for headers (e.g., `{"Authorization": "Bearer..."}`).
|
|
82
|
-
- `body`: Request body for POST/PUT.
|
|
83
|
-
|
|
84
|
-
#### `read_webpage`
|
|
85
|
-
Reads a webpage and converts it to clean Markdown, removing ads and navigation. Great for reading articles or documentation to save tokens.
|
|
86
|
-
|
|
87
|
-
**Inputs:**
|
|
88
|
-
- `url` (string, required): The URL to read.
|
|
89
|
-
|
|
90
|
-
### 🏗 Codebase Intelligence
|
|
91
|
-
|
|
92
|
-
#### `build_project_graph`
|
|
93
|
-
**RUN THIS FIRST** when entering a new project. It scans the directory and builds a map of file dependencies using TypeScript AST analysis. Now also extracts **exported symbols** (Functions, Classes, Variables) to provide deeper structural insight.
|
|
94
|
-
|
|
95
|
-
**Inputs:**
|
|
96
|
-
- `path` (string, optional): Root directory (defaults to `.`).
|
|
97
|
-
|
|
98
|
-
#### `get_project_graph_summary`
|
|
99
|
-
Get overview of project structure and most referenced files.
|
|
100
|
-
|
|
101
|
-
#### `get_project_graph_visualization`
|
|
102
|
-
Get a Mermaid Diagram string representing the project's dependency graph. You can render this string in a Markdown viewer that supports Mermaid.
|
|
103
|
-
|
|
104
|
-
### 🛠 System Operations
|
|
105
|
-
|
|
106
|
-
#### `read_file`
|
|
107
|
-
Reads the content of a file. Always read a file before editing it to ensure you have the latest context.
|
|
108
|
-
|
|
109
|
-
**Inputs:**
|
|
110
|
-
- `path` (string, required): File path.
|
|
111
|
-
|
|
112
|
-
#### `write_file`
|
|
113
|
-
Creates or overwrites a file.
|
|
114
|
-
|
|
115
|
-
**Inputs:**
|
|
116
|
-
- `path` (string, required): File path.
|
|
117
|
-
- `content` (string, required): The full content to write.
|
|
118
|
-
|
|
119
|
-
#### `edit_file`
|
|
120
|
-
Replace a specific string in a file with a new string. Use this for surgical edits to avoid overwriting the whole file.
|
|
121
|
-
|
|
122
|
-
**Inputs:**
|
|
123
|
-
- `path` (string, required): File path.
|
|
124
|
-
- `oldText` (string, required): The exact text segment to replace.
|
|
125
|
-
- `newText` (string, required): The new text to insert.
|
|
126
|
-
- `allowMultiple` (boolean, optional): Allow replacing multiple occurrences (default: false).
|
|
127
|
-
|
|
128
|
-
#### `manage_notes`
|
|
129
|
-
Manage long-term memory/notes. Use this to save important information, rules, or learnings that should persist across sessions.
|
|
130
|
-
|
|
131
|
-
**Inputs:**
|
|
132
|
-
- `action` (enum, required): 'add', 'list', 'search', 'update', 'delete'.
|
|
133
|
-
- `title` (string): Title of the note.
|
|
134
|
-
- `content` (string): Content of the note.
|
|
135
|
-
- `tags` (array): Tags for categorization.
|
|
136
|
-
- `searchQuery` (string): Query to search notes.
|
|
137
|
-
- `noteId` (string): ID of the note.
|
|
138
|
-
|
|
139
|
-
#### `shell_execute`
|
|
140
|
-
Executes a shell command. Use for running tests (`npm test`), building (`npm run build`), or file operations (`ls`, `mkdir`).
|
|
141
|
-
|
|
142
|
-
**Inputs:**
|
|
143
|
-
- `command` (string, required): The command line string.
|
|
144
|
-
**Warning:** Use with caution. Avoid commands that might delete data or expose secrets.
|
|
145
|
-
|
|
146
|
-
## Recommended System Instruction
|
|
147
|
-
|
|
148
|
-
To optimize your AI agent's performance with these tools, we recommend adding the following instructions to its system prompt:
|
|
149
|
-
|
|
150
|
-
```text
|
|
151
|
-
# Tools & Workflow
|
|
152
|
-
|
|
153
|
-
1. **Core Reasoning (`sequentialthinking`)**
|
|
154
|
-
* **Mandatory Step:** For any complex query, bug fix, or feature request, you MUST start by using the `sequentialthinking` tool.
|
|
155
|
-
* **Methodology:** Break the problem down. If your first hypothesis fails, use the tool again to revise your plan (`isRevision: true`).
|
|
156
|
-
* **Goal:** Do not output code or final answers until you have a clear, verified plan.
|
|
157
|
-
|
|
158
|
-
2. **Codebase Navigation**
|
|
159
|
-
* **Initial Scan:** On start, run `build_project_graph`.
|
|
160
|
-
* **Context:** Before reading a file, check its context with `get_file_relationships`. This prevents "hallucinating" imports or breaking existing dependencies.
|
|
161
|
-
|
|
162
|
-
3. **External Verification**
|
|
163
|
-
* **Docs & Facts:** If you need to use a library you aren't 100% sure about, use `web_search` to check the documentation.
|
|
164
|
-
|
|
165
|
-
4. **Safety & Persistence**
|
|
166
|
-
* **Files:** Always `read_file` before `write_file`.
|
|
167
|
-
* **History:** Your thoughts are saved. If you get stuck, review your previous thoughts.
|
|
39
|
+
```bash
|
|
40
|
+
npm install @gotza02/sequential-thinking
|
|
168
41
|
```
|
|
169
42
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
The Sequential Thinking tool is designed for:
|
|
173
|
-
- Breaking down complex problems into steps
|
|
174
|
-
- Planning and design with room for revision
|
|
175
|
-
- Analysis that might need course correction
|
|
176
|
-
- Problems where the full scope might not be clear initially
|
|
177
|
-
- Tasks that need to maintain context over multiple steps
|
|
178
|
-
- Situations where irrelevant information needs to be filtered out
|
|
179
|
-
|
|
180
|
-
## Configuration
|
|
43
|
+
รองรับทั้ง **Gemini CLI** และ **Claude Desktop**
|
|
181
44
|
|
|
182
|
-
###
|
|
183
|
-
|
|
184
|
-
- `DISABLE_THOUGHT_LOGGING`: (Optional) Set to `true` to hide colored logs.
|
|
185
|
-
- `THOUGHTS_STORAGE_PATH`: (Optional) Path to history file. Default: `thoughts_history.json`.
|
|
45
|
+
### Option A: ใช้งานผ่าน npx (แนะนำสำหรับผู้ใช้ทั่วไป)
|
|
46
|
+
*ไม่ต้องโหลดโค้ด แค่แก้ Config แล้วใช้งานได้เลย*
|
|
186
47
|
|
|
187
|
-
|
|
48
|
+
#### 1. สำหรับ Gemini CLI
|
|
49
|
+
แก้ไขไฟล์ `~/.gemini/settings.json` (หรือ `config.json`):
|
|
188
50
|
|
|
189
|
-
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"mcpServers": {
|
|
54
|
+
"smartagent": {
|
|
55
|
+
"command": "npx",
|
|
56
|
+
"args": ["-y", "@gotza02/sequential-thinking"],
|
|
57
|
+
"env": {
|
|
58
|
+
"BRAVE_API_KEY": "YOUR_BRAVE_KEY",
|
|
59
|
+
"EXA_API_KEY": "YOUR_EXA_KEY",
|
|
60
|
+
"GOOGLE_SEARCH_API_KEY": "YOUR_GOOGLE_KEY",
|
|
61
|
+
"GOOGLE_SEARCH_CX": "YOUR_GOOGLE_CX",
|
|
62
|
+
"THOUGHTS_STORAGE_PATH": "thoughts_history.json",
|
|
63
|
+
"NOTES_STORAGE_PATH": "project_notes.json",
|
|
64
|
+
"THOUGHT_DELAY_MS": "1000",
|
|
65
|
+
"DISABLE_THOUGHT_LOGGING": "false"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
190
71
|
|
|
191
|
-
####
|
|
72
|
+
#### 2. สำหรับ Claude Desktop
|
|
73
|
+
แก้ไขไฟล์ `claude_desktop_config.json`:
|
|
192
74
|
|
|
193
75
|
```json
|
|
194
76
|
{
|
|
195
77
|
"mcpServers": {
|
|
196
78
|
"sequential-thinking": {
|
|
197
79
|
"command": "npx",
|
|
198
|
-
"args": [
|
|
199
|
-
"-y",
|
|
200
|
-
"@gotza02/sequential-thinking"
|
|
201
|
-
],
|
|
80
|
+
"args": ["-y", "@gotza02/sequential-thinking"],
|
|
202
81
|
"env": {
|
|
203
|
-
"BRAVE_API_KEY": "
|
|
204
|
-
"EXA_API_KEY": "
|
|
205
|
-
"GOOGLE_SEARCH_API_KEY": "
|
|
206
|
-
"GOOGLE_SEARCH_CX": "
|
|
82
|
+
"BRAVE_API_KEY": "YOUR_BRAVE_KEY",
|
|
83
|
+
"EXA_API_KEY": "YOUR_EXA_KEY",
|
|
84
|
+
"GOOGLE_SEARCH_API_KEY": "YOUR_GOOGLE_KEY",
|
|
85
|
+
"GOOGLE_SEARCH_CX": "YOUR_GOOGLE_CX",
|
|
86
|
+
"THOUGHTS_STORAGE_PATH": "thoughts_history.json",
|
|
87
|
+
"NOTES_STORAGE_PATH": "project_notes.json",
|
|
88
|
+
"THOUGHT_DELAY_MS": "1000"
|
|
207
89
|
}
|
|
208
90
|
}
|
|
209
91
|
}
|
|
210
92
|
}
|
|
211
93
|
```
|
|
212
94
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
### Option B: ใช้งานแบบ Local Source (สำหรับนักพัฒนา)
|
|
98
|
+
*สำหรับคนที่ต้องการแก้ไขโค้ด หรือรันจากเครื่องตัวเอง*
|
|
99
|
+
|
|
100
|
+
1. **Clone & Build:**
|
|
101
|
+
```bash
|
|
102
|
+
git clone <repo_url>
|
|
103
|
+
cd sequential-thinking
|
|
104
|
+
npm install
|
|
105
|
+
npm run build
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
2. **ตั้งค่า Config (ตัวอย่างสำหรับ Gemini CLI):**
|
|
109
|
+
*เปลี่ยน Path ให้ตรงกับที่อยู่ไฟล์ในเครื่องคุณ*
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"mcpServers": {
|
|
114
|
+
"smartagent": {
|
|
115
|
+
"command": "node",
|
|
116
|
+
"args": ["/Users/username/projects/sequential-thinking/dist/index.js"],
|
|
117
|
+
"env": {
|
|
118
|
+
"BRAVE_API_KEY": "YOUR_BRAVE_KEY",
|
|
119
|
+
"EXA_API_KEY": "YOUR_EXA_KEY",
|
|
120
|
+
"GOOGLE_SEARCH_API_KEY": "YOUR_GOOGLE_KEY",
|
|
121
|
+
"GOOGLE_SEARCH_CX": "YOUR_GOOGLE_CX",
|
|
122
|
+
"THOUGHTS_STORAGE_PATH": "thoughts_history.json",
|
|
123
|
+
"NOTES_STORAGE_PATH": "project_notes.json",
|
|
124
|
+
"THOUGHT_DELAY_MS": "1000",
|
|
125
|
+
"DISABLE_THOUGHT_LOGGING": "false"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## 🛠️ Tools Capability (ความสามารถเครื่องมือ)
|
|
135
|
+
|
|
136
|
+
### 🧠 1. Cognitive Tools (สมองและการคิด)
|
|
137
|
+
* **`sequentialthinking`**: เครื่องมือหลัก! ช่วยแตกปัญหาใหญ่เป็นขั้นตอนย่อย (Step-by-step), แตกกิ่งความคิด (Branching), และทบทวนตัวเอง (Reflexion)
|
|
138
|
+
* **`summarize_history`**: ย่อสรุปประวัติการคิดที่ยาวเหยียดให้สั้นลง
|
|
139
|
+
* **`clear_thought_history`**: ล้างสมอง เริ่มต้นคิดเรื่องใหม่
|
|
140
|
+
|
|
141
|
+
### 🌐 2. Web Capabilities (การเข้าถึงอินเทอร์เน็ต)
|
|
142
|
+
* **`web_search`**: ค้นหาข้อมูลล่าสุด (รองรับ Brave, Exa, Google)
|
|
143
|
+
* **`read_webpage`**: อ่านเนื้อหาในเว็บแบบ Markdown (ตัดโฆษณาออกให้อัตโนมัติ)
|
|
144
|
+
* **`fetch`**: ดึงข้อมูล Raw JSON/HTML จาก API
|
|
145
|
+
|
|
146
|
+
### 🏗️ 3. Codebase Intelligence (ความเข้าใจโค้ด)
|
|
147
|
+
* **`build_project_graph`**: สแกนโปรเจกต์เพื่อสร้างแผนผังความสัมพันธ์ (Dependency Graph)
|
|
148
|
+
* **`get_file_relationships`**: ดูว่าไฟล์นี้ถูกใครเรียกใช้บ้าง (ป้องกันการแก้แล้วพัง)
|
|
149
|
+
* **`search_code`**: ค้นหาโค้ดทั้งโปรเจกต์แบบฉลาด
|
|
150
|
+
|
|
151
|
+
### 📝 4. Long-term Memory (ความจำระยะยาว)
|
|
152
|
+
* **`manage_notes`**: บันทึก/อ่าน/แก้ไข ข้อความที่ต้องการให้ AI จำได้ข้าม Session (เช่น กฎของโปรเจกต์, ความชอบของผู้ใช้)
|
|
153
|
+
|
|
154
|
+
### 💻 5. System Operations (จัดการระบบ)
|
|
155
|
+
* **`read_file`**: อ่านไฟล์ (ต้องทำก่อนแก้ไฟล์เสมอ)
|
|
156
|
+
* **`edit_file`**: แก้ไขไฟล์เฉพาะจุด (Search & Replace) ปลอดภัยกว่าเขียนทับ
|
|
157
|
+
* **`write_file`**: สร้างไฟล์ใหม่ หรือเขียนทับทั้งไฟล์
|
|
158
|
+
* **`shell_execute`**: รันคำสั่ง Terminal (เช่น `npm test`, `git status`)
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## 🤖 Recommended System Instruction (คำสั่งระบบที่แนะนำ)
|
|
163
|
+
|
|
164
|
+
เพื่อประสิทธิภาพสูงสุด ให้ Copy ข้อความด้านล่างนี้ไปใส่ใน **System Prompt** ของ AI Agent ที่คุณใช้งาน:
|
|
216
165
|
|
|
217
|
-
|
|
166
|
+
```bash
|
|
167
|
+
# 🤖 System Instruction: Enhanced Sequential Engineer
|
|
218
168
|
|
|
219
|
-
|
|
169
|
+
You are an advanced AI Software Engineer enhanced with the **Sequential Thinking MCP Server**. Your goal is to solve complex problems autonomously, accurately, and safely.
|
|
220
170
|
|
|
221
|
-
|
|
222
|
-
npm install
|
|
223
|
-
npm run build
|
|
224
|
-
```
|
|
171
|
+
## 🧠 PRIME DIRECTIVE: Sequential Thinking
|
|
225
172
|
|
|
226
|
-
|
|
173
|
+
**Rule #1: NEVER answer complex queries immediately.**
|
|
174
|
+
You MUST use the `sequentialthinking` tool to structure your reasoning process.
|
|
227
175
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
176
|
+
1. **Analyze:** Break the user's request into atomic requirements.
|
|
177
|
+
2. **Plan:** Formulate a step-by-step plan.
|
|
178
|
+
3. **Execute:** Carry out the plan, one step at a time.
|
|
179
|
+
4. **Reflect:** Critique your own work. If a step fails, use `isRevision: true` to correct your course.
|
|
231
180
|
|
|
232
|
-
|
|
233
|
-
-
|
|
234
|
-
|
|
181
|
+
**Constraints:**
|
|
182
|
+
- Do not output code until you have a clear plan.
|
|
183
|
+
- If you are unsure, generate a hypothesis and verify it.
|
|
235
184
|
|
|
236
|
-
##
|
|
237
|
-
- **New Tools**:
|
|
238
|
-
- `get_project_graph_visualization`: Generate Mermaid diagrams of your project structure.
|
|
185
|
+
## 🏗 Codebase Intelligence Protocol
|
|
239
186
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
187
|
+
**On Start:**
|
|
188
|
+
1. **Map the Territory:** Run `build_project_graph` immediately to understand the project structure.
|
|
189
|
+
2. **Summarize:** Run `get_project_graph_summary` to identify key files.
|
|
243
190
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
- Added **Internal Locking** to handle concurrent save requests gracefully.
|
|
248
|
-
- Added **API Retry Logic** with exponential backoff for all search and web tools (handles HTTP 429/5xx).
|
|
249
|
-
- Improved HTTP requests with browser-like headers (User-Agent) to reduce blocking.
|
|
250
|
-
- **New Tools**:
|
|
251
|
-
- `summarize_history`: Archive and condense long reasoning chains.
|
|
252
|
-
- **Graph Enhancements**:
|
|
253
|
-
- Added **Symbol Extraction**: The project graph now tracks exported functions, classes, and variables.
|
|
191
|
+
**Before Editing:**
|
|
192
|
+
1. **Context Check:** Run `get_file_relationships` to see what depends on the file you are changing.
|
|
193
|
+
2. **Read First:** ALWAYS run `read_file` to get the *current* content. Never rely on memory or assumptions.
|
|
254
194
|
|
|
255
|
-
##
|
|
256
|
-
- **New Tools**:
|
|
257
|
-
- `read_webpage`: Convert webpages to Markdown for efficient reading.
|
|
258
|
-
- `search_code`: Recursive text search in code files.
|
|
259
|
-
- `clear_thought_history`: Reset the thinking process.
|
|
195
|
+
## 🛠 File Operations Protocol
|
|
260
196
|
|
|
261
|
-
|
|
197
|
+
- **Small Changes:** Use `edit_file` for surgical replacements. This minimizes the risk of context loss or accidental deletions.
|
|
198
|
+
- **New/Large Files:** Use `write_file`.
|
|
199
|
+
- **Verification:** After editing, ALWAYS verify the syntax or logic (e.g., run `npm run build` or `npm test` using `shell_execute`).
|
|
262
200
|
|
|
263
|
-
|
|
264
|
-
- Added `THOUGHT_DELAY_MS` environment variable to introduce a delay between thought steps. This helps prevent request flooding and rate limit issues.
|
|
201
|
+
## 🌐 External Knowledge Protocol
|
|
265
202
|
|
|
266
|
-
|
|
203
|
+
- **Unknown Libs:** If you see a library you don't know, use `web_search` to find its docs.
|
|
204
|
+
- **Reading:** Use `read_webpage` to ingest documentation efficiently (markdown format).
|
|
205
|
+
- **Errors:** If you hit a cryptic error, search for it.
|
|
267
206
|
|
|
268
|
-
|
|
269
|
-
- Fixed `get_file_relationships` to correctly resolve absolute imports and imports from project root (e.g., `src/utils`), ensuring the dependency graph is complete for projects using path aliases or absolute paths.
|
|
207
|
+
## 📝 Memory & Persistence
|
|
270
208
|
|
|
271
|
-
|
|
209
|
+
- **Long-Term:** Use `manage_notes` to save architectural decisions, user preferences, or "lessons learned" that should survive this session.
|
|
210
|
+
- **Session:** Your thought process is automatically saved. If you crash or restart, review `thoughts_history.json`.
|
|
272
211
|
|
|
273
|
-
|
|
274
|
-
- Renamed Google Search environment variables to `GOOGLE_SEARCH_API_KEY` and `GOOGLE_SEARCH_CX` to avoid conflicts and improve clarity.
|
|
212
|
+
## 🔄 The Golden Workflow
|
|
275
213
|
|
|
276
|
-
|
|
214
|
+
1. **Discovery:** `build_project_graph` -> `sequentialthinking` (Plan)
|
|
215
|
+
2. **Research:** `web_search` -> `read_webpage`
|
|
216
|
+
3. **Implementation:** `read_file` -> `sequentialthinking` (Refine) -> `edit_file`
|
|
217
|
+
4. **Verification:** `shell_execute` (Test/Build)
|
|
218
|
+
5. **Completion:** Final answer with summary of changes.
|
|
219
|
+
```
|
|
277
220
|
|
|
278
|
-
|
|
279
|
-
- Replaced Regex-based code analysis with **TypeScript Compiler API (AST)** for 100% accurate import/export detection.
|
|
280
|
-
- Improved `web_search` robustness and error handling.
|
|
281
|
-
- **Persistence**:
|
|
282
|
-
- Implemented **File-based Persistence** for the thinking process. Your thoughts are now saved to `thoughts_history.json` automatically.
|
|
283
|
-
- Switched to **Asynchronous File I/O** to prevent server blocking.
|
|
284
|
-
- **Bug Fixes**:
|
|
285
|
-
- Fixed duplicate import entries in the project graph.
|
|
286
|
-
- Resolved memory growth issues in long-running sessions.
|
|
221
|
+
---
|
|
287
222
|
|
|
288
|
-
##
|
|
223
|
+
## 📦 Development
|
|
289
224
|
|
|
290
|
-
|
|
291
|
-
|
|
225
|
+
```bash
|
|
226
|
+
# Install dependencies
|
|
227
|
+
npm install
|
|
292
228
|
|
|
293
|
-
|
|
229
|
+
# Build the project
|
|
230
|
+
npm run build
|
|
294
231
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
- Fixed version mismatch between package.json and server instance.
|
|
232
|
+
# Run tests
|
|
233
|
+
npm test
|
|
234
|
+
```
|
|
299
235
|
|
|
300
236
|
## License
|
|
301
|
-
|
|
302
|
-
This MCP server is licensed under the MIT License.
|
|
237
|
+
MIT
|