
Product
Socket Now Protects the Firefox Extension Ecosystem
Socket is bringing experimental protection to Firefox, scanning 97,000+ extensions in Mozilla's official directory for malware and risky updates.
statecli-mcp-server
Advanced tools
MCP Server for State Replay & Self-Debugging - Memory, replay, and undo capability for AI agents
For AI Agents: Memory, replay, and undo capability for your actions.
MCP Server | State Management | Agent Self-Debugging | Rollback Capability
npx statecli-mcp-server
{
"mcpServers": {
"statecli": {
"command": "npx",
"args": ["-y", "statecli-mcp-server"]
}
}
}
| Tool | Description | Use When |
|---|---|---|
statecli_replay | See what you just did | Debugging, understanding past behavior |
statecli_undo | Rollback mistakes | Made an error, need to retry |
statecli_checkpoint | Save state before risky ops | About to do something risky |
statecli_log | View action history | Need audit trail |
statecli_track | Track state changes | Making important modifications |
// Checkpoint before risky operation
await statecli_checkpoint({ entity: "order:123", name: "before-refund" });
try {
await processOrder(order);
} catch (error) {
// Replay to see what went wrong
const replay = await statecli_replay({ entity: "order:123" });
// Undo if needed
await statecli_undo({ entity: "order:123" });
}
| Problem | Solution |
|---|---|
| "I changed something but don't know what" | statecli_replay(entity) |
| "I broke something and need to undo" | statecli_undo(entity) |
| "I want to try something risky" | statecli_checkpoint(entity) |
| "I need to understand my past behavior" | statecli_log(entity) |
statecli_replayReplay state changes for an entity. Shows step-by-step what happened.
{
"entity": "order:7421",
"actor": "ai-agent"
}
statecli_undoUndo state changes. Rollback when something went wrong.
{
"entity": "order:7421",
"steps": 3
}
statecli_checkpointCreate named checkpoint before making changes.
{
"entity": "order:7421",
"name": "before-refund"
}
statecli_logView state change history for an entity.
{
"entity": "order:7421",
"since": "1h ago",
"actor": "ai-agent"
}
statecli_trackExplicitly track a state change.
{
"entity_type": "order",
"entity_id": "7421",
"state": { "status": "paid", "amount": 49.99 }
}
try {
await agent.run(task);
} catch (error) {
// Get replay of what just happened
const replay = await mcp.call("statecli_replay", {
entity: `task:${task.id}`,
actor: "ai-agent"
});
// Analyze what went wrong
const analysis = await llm.analyze({
replay: replay.result,
error: error.message,
prompt: "What went wrong in this sequence?"
});
// Undo if fixable
if (analysis.canRetry) {
await mcp.call("statecli_undo", {
entity: `task:${task.id}`,
steps: 1
});
// Retry with fix
await agent.runWithFix(task, analysis.fix);
}
}
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"statecli": {
"command": "npx",
"args": ["-y", "statecli-mcp-server"]
}
}
}
Add to .cursor/mcp.json:
{
"mcpServers": {
"statecli": {
"command": "npx",
"args": ["-y", "statecli-mcp-server"]
}
}
}
Add to MCP settings:
{
"mcpServers": {
"statecli": {
"command": "npx",
"args": ["-y", "statecli-mcp-server"]
}
}
}
# Initialize configuration
statecli init
# Track a state change
statecli track order 7421 -d '{"status": "pending"}'
# Replay changes
statecli replay order:7421
# View log
statecli log order:7421 --since "1h ago"
# Create checkpoint
statecli checkpoint order:7421 before-payment
# Undo last change
statecli undo order:7421
# Get current state
statecli state order:7421
# List all entities
statecli list
# Start MCP server
statecli serve
import { StateCLI } from 'statecli-mcp-server';
const cli = new StateCLI();
// Track state
cli.track('order', '7421', { status: 'pending' }, 'ai-agent');
// Replay
const replay = cli.replay('order:7421');
// Checkpoint
cli.checkpoint('order:7421', 'before-payment');
// Undo
cli.undo('order:7421', 1);
// Log with wildcards
const log = cli.log('order:*', { since: '1h ago' });
import { AgentExecutor } from "langchain/agents";
const executor = AgentExecutor.fromAgentAndTools({
agent,
tools: [...tools, statecliMCPTools],
callbacks: [{
handleToolEnd: async (tool, output) => {
await statecli_track({
entity_type: "agent-task",
entity_id: taskId,
state: { tool, output }
});
}
}]
});
from statecli import StateCLI
class SelfDebuggingAgent:
def __init__(self):
self.statecli = StateCLI()
async def execute(self, task):
checkpoint = await self.statecli.checkpoint(f"task:{task.id}")
try:
await self.run_task(task)
except Exception as e:
replay = await self.statecli.replay(f"task:{task.id}")
await self.statecli.undo(f"task:{task.id}")
await self.retry_with_context(task, replay)
from crewai import Agent, Task
from statecli import statecli_mcp_tool
agent = Agent(
role="Developer",
tools=[statecli_mcp_tool],
allow_delegation=True
)
All outputs are JSON-stable:
{
"entity": "order:7421",
"changes": [
{
"timestamp": "2025-01-07T10:23:45Z",
"step": 1,
"before": { "status": null },
"after": { "status": "pending" },
"actor": "ai-agent"
}
],
"summary": "1 state change found",
"suggested_next_actions": ["investigate latest change"]
}
Create .statecli/config.json:
{
"storage": {
"type": "local",
"path": ".statecli/state.db"
},
"autoTrack": {
"enabled": true,
"patterns": ["order:*", "user:*", "task:*"]
},
"retention": {
"days": 30,
"maxChangesPerEntity": 1000
}
}
npm install
npm run build
npm test
MIT - Free for all use including commercial AI agents
state-management, mcp-server, ai-agent-tools, debugging, replay, undo, rollback, agent-memory, self-debugging, autonomous-agents, model-context-protocol, time-travel-debugging, checkpoint, agent-introspection, state-tracking, langchain-tools, autogpt-plugins, crewai-tools
FAQs
Memory and self-awareness layer for AI agents - MCP server for state tracking, replay, and undo
The npm package statecli-mcp-server receives a total of 56 weekly downloads. As such, statecli-mcp-server popularity was classified as not popular.
We found that statecli-mcp-server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket is bringing experimental protection to Firefox, scanning 97,000+ extensions in Mozilla's official directory for malware and risky updates.

Research
/Security News
Three compromised Rust crates pulled in a malicious dependency that downloaded and executed cross-platform malware during Cargo builds.

Research
/Security News
Socket uncovered 77 linked Firefox extensions, including 40 that steal wallet secrets or credentials and 37 deceptive sports-score shells.