Local History MCP Server for Cursor, VS Code
Access Cursor and VS Code local history via an MCP server for AI-powered recovery and seamless context-aware file restoration.
npx -y @xxczaki/local-history-mcpOverview
This MCP (Model Context Protocol) server exposes the Local History snapshots created by Cursor and Visual Studio Code to AI assistants and other MCP clients. Local History records file snapshots at save points — unlike undo/redo — so it can recover content lost by accidental overwrites, refactors, or destructive edits. The Local History MCP Server acts as a local bridge so AI tools can query file histories, search past contents, and restore earlier versions in a context-aware way.
For developers, this means AI assistants (for example, Cursor, Claude, or other MCP-compatible tools) can access a structured view of your local file history to provide better diagnostic suggestions, automated recovery, or richer code-completion context. The server is designed for personal, local use and integrates into existing MCP workflows for Cursor and VS Code.
Features
- Exposes Cursor and VS Code Local History via the Model Context Protocol (MCP)
- Browse files that have Local History snapshots
- Inspect full history for a specific file and fetch individual entries
- Search text across all saved history entries
- Restore a file to a previous snapshot (creates a backup before writing)
- Simple CLI install and a source build path for contributors
- MCP-compatible — works with any client that supports custom MCP servers
Installation / Configuration
Quick install with a package runner:
# npm
# pnpm
# yarn
# bun
From source:
Typical development commands:
Registering the MCP server with clients:
Cursor: you can install via the one-click MCP install (or add manually via Cursor’s MCP docs).
- One-click install: https://cursor.com/en/install-mcp?name=local-history&config=eyJjb21tYW5kIjogIm5weCIsICJhcmdzIjogWyIteSIsICJsb2NhbC1oaXN0b3J5LW1jcCJdfQo%3D
- Cursor MCP docs: https://docs.cursor.com/en/context/mcp
Claude (CLI/Desktop):
- Claude Code (CLI):
- See Anthropic’s MCP docs for desktop setup.
- Claude Code (CLI):
Visual Studio Code:
- Follow VS Code instructions to add an MCP server: https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_add-an-mcp-server
After installation, start the server and register the reported endpoint with your MCP client.
Available Tools
| Tool name | Description |
|---|---|
| list_history_files | List files that have Local History snapshots |
| get_file_history | Retrieve the full history list for a given file |
| get_history_entry | Fetch the content of a single history entry |
| restore_from_history | Restore the workspace file from a selected history entry (creates a backup) |
| search_history_content | Full-text search across all saved history entries |
| get_history_stats | Return summary statistics (counts, sizes, timestamps) |
These tools are exposed through MCP method calls so your assistant can invoke them directly as part of a context request.
Use Cases
- Recover an accidentally overwritten implementation: locate the previous snapshot for a .js/.py file and restore the missing function without restoring the entire repository.
- Assist AI troubleshooting: feed a model the past few save points for a module so it can infer when a bug was introduced and propose targeted fixes.
- Search historical code: locate previous implementations or comments that were removed during a refactor.
- Audit and forensics: collect timestamps and content of past saves for a file when tracking changes across development sessions.
- Improve completion/context: give an AI assistant access to older versions so it can suggest more accurate refactors or reinstate removed behavior.
Concrete example — quick recovery:
- Start server:
npx local-history-mcp - From your MCP-enabled assistant, call
list_history_filesto find affected files. - Use
get_file_historyandget_history_entryto preview an older snapshot. - Use
restore_from_historyto restore the file (the server creates a backup of the current version).
Notes on privacy & safety
- The server reads Local History stored on the machine and is intended for local/personal use. Register MCP endpoints only with trusted assistants and clients.
- Restores create backups by default to avoid accidental data loss.
- Review your editor’s Local History retention settings if you need longer or shorter snapshot retention.
Repository and issues: https://github.com/xxczaki/local-history-mcp
License: MIT