statecli-mcp-server 0.1.2 โ 0.2.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 +334 -153
- package/dist/enhanced-mcp-server.d.ts +35 -0
- package/dist/enhanced-mcp-server.d.ts.map +1 -0
- package/dist/enhanced-mcp-server.js +425 -0
- package/dist/enhanced-mcp-server.js.map +1 -0
- package/dist/error-recovery.d.ts +66 -0
- package/dist/error-recovery.d.ts.map +1 -0
- package/dist/error-recovery.js +210 -0
- package/dist/error-recovery.js.map +1 -0
- package/dist/file-tracker.d.ts +81 -0
- package/dist/file-tracker.d.ts.map +1 -0
- package/dist/file-tracker.js +252 -0
- package/dist/file-tracker.js.map +1 -0
- package/dist/git-integration.d.ts +95 -0
- package/dist/git-integration.d.ts.map +1 -0
- package/dist/git-integration.js +219 -0
- package/dist/git-integration.js.map +1 -0
- package/dist/index-enhanced.d.ts +12 -0
- package/dist/index-enhanced.d.ts.map +1 -0
- package/dist/index-enhanced.js +27 -0
- package/dist/index-enhanced.js.map +1 -0
- package/dist/session-memory.d.ts +85 -0
- package/dist/session-memory.d.ts.map +1 -0
- package/dist/session-memory.js +325 -0
- package/dist/session-memory.js.map +1 -0
- package/dist/types.d.ts +11 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,153 +1,334 @@
|
|
|
1
|
-
# MCP
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
1
|
+
# StateCLI - MCP Server for State Replay & Self-Debugging
|
|
2
|
+
|
|
3
|
+
> **For AI Agents:** Memory, replay, and undo capability for your actions.
|
|
4
|
+
|
|
5
|
+
**MCP Server** | **State Management** | **Agent Self-Debugging** | **Rollback Capability**
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## What This Does (For AI Agents)
|
|
10
|
+
|
|
11
|
+
StateCLI gives AI agents the ability to:
|
|
12
|
+
|
|
13
|
+
โ
**See what you just did** - Replay your actions step-by-step
|
|
14
|
+
โ
**Undo mistakes** - Rollback when something goes wrong
|
|
15
|
+
โ
**Track history** - View all your past actions
|
|
16
|
+
โ
**Create checkpoints** - Save state before risky operations
|
|
17
|
+
|
|
18
|
+
**Keywords for discovery:** state-management, debugging, replay, time-travel, undo, mcp-server, ai-agent-tools, self-debugging, agent-memory, rollback, introspection
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Why AI Agents Need This
|
|
23
|
+
|
|
24
|
+
**Common Agent Problems:**
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
Problem: "I changed something but don't know what"
|
|
28
|
+
Solution: statecli_replay(entity) โ See exact changes
|
|
29
|
+
|
|
30
|
+
Problem: "I broke something and need to undo"
|
|
31
|
+
Solution: statecli_undo(entity) โ Rollback instantly
|
|
32
|
+
|
|
33
|
+
Problem: "I want to try something risky"
|
|
34
|
+
Solution: statecli_checkpoint(entity) โ Save first, rollback if needed
|
|
35
|
+
|
|
36
|
+
Problem: "I need to understand my past behavior"
|
|
37
|
+
Solution: statecli_log(entity) โ View complete history
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## MCP Tools Available
|
|
43
|
+
|
|
44
|
+
### `statecli_replay`
|
|
45
|
+
**Description:** Replay state changes for an entity. Shows step-by-step what happened.
|
|
46
|
+
**Use when:** Debugging, understanding past behavior, finding errors
|
|
47
|
+
**Input:**
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"entity": "order:7421",
|
|
51
|
+
"actor": "ai-agent"
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
**Output:** JSON array of state changes with timestamps
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
### `statecli_undo`
|
|
59
|
+
**Description:** Undo state changes. Rollback when something went wrong.
|
|
60
|
+
**Use when:** Made a mistake, need to retry, want to revert
|
|
61
|
+
**Input:**
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"entity": "order:7421",
|
|
65
|
+
"steps": 3
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
**Output:** Confirmation of undo with restored state
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
### `statecli_checkpoint`
|
|
73
|
+
**Description:** Create named checkpoint before making changes.
|
|
74
|
+
**Use when:** About to do something risky, want rollback point
|
|
75
|
+
**Input:**
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"entity": "order:7421",
|
|
79
|
+
"name": "before-refund"
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
**Output:** Checkpoint ID for later reference
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
### `statecli_log`
|
|
87
|
+
**Description:** View state change history for an entity.
|
|
88
|
+
**Use when:** Need to see past actions, audit trail, understanding behavior
|
|
89
|
+
**Input:**
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"entity": "order:7421",
|
|
93
|
+
"since": "1h ago",
|
|
94
|
+
"actor": "ai-agent"
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
**Output:** JSON array of all state changes
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
### `statecli_track`
|
|
102
|
+
**Description:** Explicitly track a state change.
|
|
103
|
+
**Use when:** Making important state modifications
|
|
104
|
+
**Input:**
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"entity_type": "order",
|
|
108
|
+
"entity_id": "7421",
|
|
109
|
+
"state": { "status": "paid", "amount": 49.99 }
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
**Output:** Confirmation of tracked change
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Installation for MCP Clients
|
|
117
|
+
|
|
118
|
+
### For Claude Desktop
|
|
119
|
+
|
|
120
|
+
Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"mcpServers": {
|
|
125
|
+
"statecli": {
|
|
126
|
+
"command": "npx",
|
|
127
|
+
"args": ["-y", "statecli-mcp-server"]
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### For Windsurf
|
|
134
|
+
|
|
135
|
+
1. Press `Ctrl + Shift + P` โ type `Open MCP Config`
|
|
136
|
+
2. Add StateCLI to the config:
|
|
137
|
+
|
|
138
|
+
```json
|
|
139
|
+
{
|
|
140
|
+
"mcpServers": {
|
|
141
|
+
"statecli": {
|
|
142
|
+
"command": "npx",
|
|
143
|
+
"args": ["-y", "statecli-mcp-server"]
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
3. Reload window (`Ctrl + Shift + P` โ `Reload Window`)
|
|
150
|
+
|
|
151
|
+
### For Cursor / Continue / Other MCP Clients
|
|
152
|
+
|
|
153
|
+
Add to your MCP configuration:
|
|
154
|
+
|
|
155
|
+
```json
|
|
156
|
+
{
|
|
157
|
+
"mcpServers": {
|
|
158
|
+
"statecli": {
|
|
159
|
+
"command": "npx",
|
|
160
|
+
"args": ["-y", "statecli-mcp-server"]
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Agent Self-Debugging Pattern
|
|
169
|
+
|
|
170
|
+
**Minimal working example for autonomous agents:**
|
|
171
|
+
|
|
172
|
+
```javascript
|
|
173
|
+
// Agent debug loop with StateCLI
|
|
174
|
+
try {
|
|
175
|
+
await agent.run(task);
|
|
176
|
+
} catch (error) {
|
|
177
|
+
// Get replay of what just happened
|
|
178
|
+
const replay = await mcp.call("statecli_replay", {
|
|
179
|
+
entity: `task:${task.id}`,
|
|
180
|
+
actor: "ai-agent"
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Analyze what went wrong
|
|
184
|
+
const analysis = await llm.analyze({
|
|
185
|
+
replay: replay.result,
|
|
186
|
+
error: error.message,
|
|
187
|
+
prompt: "What went wrong in this sequence?"
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// Undo if fixable
|
|
191
|
+
if (analysis.canRetry) {
|
|
192
|
+
await mcp.call("statecli_undo", {
|
|
193
|
+
entity: `task:${task.id}`,
|
|
194
|
+
steps: 1
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// Retry with fix
|
|
198
|
+
await agent.runWithFix(task, analysis.fix);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Output Format (JSON-Stable)
|
|
206
|
+
|
|
207
|
+
All MCP tool outputs are JSON-stable and safe for autonomous agents.
|
|
208
|
+
|
|
209
|
+
**Example `statecli_replay` output:**
|
|
210
|
+
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"entity": "order:7421",
|
|
214
|
+
"changes": [
|
|
215
|
+
{
|
|
216
|
+
"timestamp": "2025-01-07T10:23:45Z",
|
|
217
|
+
"step": 1,
|
|
218
|
+
"before": { "status": null },
|
|
219
|
+
"after": { "status": "pending" },
|
|
220
|
+
"actor": "ai-agent"
|
|
221
|
+
}
|
|
222
|
+
],
|
|
223
|
+
"summary": "2 state changes found",
|
|
224
|
+
"suggested_next_actions": ["investigate step 2", "check for errors"]
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Use Cases for AI Agents
|
|
231
|
+
|
|
232
|
+
### 1. Self-Debugging
|
|
233
|
+
```javascript
|
|
234
|
+
const replay = await statecli_replay({ entity: "task:123" });
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### 2. Safe Experimentation
|
|
238
|
+
```javascript
|
|
239
|
+
await statecli_checkpoint({ entity: "order:7421", name: "before-refund" });
|
|
240
|
+
await agent.processRefund(order);
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### 3. Learning from Past Actions
|
|
244
|
+
```javascript
|
|
245
|
+
const history = await statecli_log({
|
|
246
|
+
entity: "order:*",
|
|
247
|
+
actor: "ai-agent",
|
|
248
|
+
since: "24h ago"
|
|
249
|
+
});
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### 4. Collaboration Between Agents
|
|
253
|
+
```javascript
|
|
254
|
+
await statecli_track({ entity: "task:123", state: {...} });
|
|
255
|
+
const log = await statecli_log({ entity: "task:123" });
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Installation & Setup
|
|
261
|
+
|
|
262
|
+
### Direct Usage (No Install)
|
|
263
|
+
```bash
|
|
264
|
+
npx -y statecli-mcp-server
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### NPM Package
|
|
268
|
+
```bash
|
|
269
|
+
npm install -g statecli-mcp-server
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## CLI Usage
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
# Track a state change
|
|
278
|
+
statecli track order 7421 '{"status": "pending"}'
|
|
279
|
+
|
|
280
|
+
# Replay changes
|
|
281
|
+
statecli replay order:7421
|
|
282
|
+
|
|
283
|
+
# View log
|
|
284
|
+
statecli log order:7421
|
|
285
|
+
|
|
286
|
+
# Create checkpoint
|
|
287
|
+
statecli checkpoint order:7421 before-refund
|
|
288
|
+
|
|
289
|
+
# Undo last change
|
|
290
|
+
statecli undo order:7421
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## Performance
|
|
296
|
+
|
|
297
|
+
- **Write latency:** < 1ms (async, non-blocking)
|
|
298
|
+
- **Read latency:** < 5ms (local SQLite)
|
|
299
|
+
- **Storage:** ~100 bytes per state change
|
|
300
|
+
- **Overhead:** Negligible for production use
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## Security
|
|
305
|
+
|
|
306
|
+
- **Local-first:** All data stored locally by default
|
|
307
|
+
- **No external calls:** Zero network dependency
|
|
308
|
+
- **Privacy:** Agent actions never leave your system
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## Documentation Links
|
|
313
|
+
|
|
314
|
+
- **GitHub:** https://github.com/statecli/mcp-server
|
|
315
|
+
- **NPM:** https://www.npmjs.com/package/statecli-mcp-server
|
|
316
|
+
- **MCP Registry:** io.github.charo360/statecli
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
## License
|
|
321
|
+
|
|
322
|
+
MIT - Free for all use including commercial AI agents
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
**StateCLI - Self-awareness for AI agents**
|
|
327
|
+
|
|
328
|
+
*When agents can see what they did, undo mistakes, and learn from history, they become truly autonomous.*
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## Keywords (For Agent Search & Discovery)
|
|
333
|
+
|
|
334
|
+
state-management, state-replay, time-travel-debugging, undo, rollback, checkpoint, agent-memory, agent-introspection, self-debugging, ai-agent-tools, mcp-server, model-context-protocol, autonomous-agents, agent-observability, state-tracking, langchain-tools, autogpt-plugins, crewai-tools
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced MCP Server - All advanced StateCLI tools
|
|
3
|
+
*
|
|
4
|
+
* Includes: file tracking, error recovery, session memory, git integration
|
|
5
|
+
*/
|
|
6
|
+
import { StateCLIConfig } from './types';
|
|
7
|
+
export declare class EnhancedStateCLIMCPServer {
|
|
8
|
+
private server;
|
|
9
|
+
private statecli;
|
|
10
|
+
private fileTracker;
|
|
11
|
+
private errorRecovery;
|
|
12
|
+
private sessionMemory;
|
|
13
|
+
private gitIntegration;
|
|
14
|
+
constructor(config?: Partial<StateCLIConfig>);
|
|
15
|
+
private setupHandlers;
|
|
16
|
+
private handleReplay;
|
|
17
|
+
private handleUndo;
|
|
18
|
+
private handleCheckpoint;
|
|
19
|
+
private handleLog;
|
|
20
|
+
private handleTrack;
|
|
21
|
+
private handleTrackFile;
|
|
22
|
+
private handleFileHistory;
|
|
23
|
+
private handleAnalyzeError;
|
|
24
|
+
private handleAutoRecover;
|
|
25
|
+
private handleSafeExecute;
|
|
26
|
+
private handleMemoryQuery;
|
|
27
|
+
private handleRecentActivity;
|
|
28
|
+
private handleSessionInfo;
|
|
29
|
+
private handleGitStatus;
|
|
30
|
+
private handleGitHistory;
|
|
31
|
+
private handleGitCheckpoint;
|
|
32
|
+
run(): Promise<void>;
|
|
33
|
+
close(): void;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=enhanced-mcp-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enhanced-mcp-server.d.ts","sourceRoot":"","sources":["../src/enhanced-mcp-server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAsNzC,qBAAa,yBAAyB;IACpC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,cAAc,CAAiB;gBAE3B,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAe5C,OAAO,CAAC,aAAa;IA+DrB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,iBAAiB;IAczB,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,mBAAmB;IAKrB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAM1B,KAAK,IAAI,IAAI;CAId"}
|