Terminal History MCP
Terminal History MCP indexes your local shell history (zsh/bash/fish) and exposes tools to search, explore, and debug past commands — all stored locally, with secrets automatically redacted.
search_history(query, limit): Full-text keyword and prefix search across all indexed shell commands, returning results with timestamps, working directory, and exit codes.recent_in_dir(cwd, limit): List the most recent commands run in a specific working directory (requires shell hook for cwd capture).failed_commands(since_ts_ms, limit): Retrieve commands that exited with a non-zero status, useful for debugging recent errors (requires shell hook for exit code capture).command_chains(query, window_ms, limit): For any matching command, surface surrounding commands run within ±5 minutes, revealing multi-step sequences likecd → build → deploy.reindex: Re-parses~/.zsh_history,~/.bash_history,~/.fish_history, and the extended log to refresh the local SQLite database.
Privacy: All data stays on your machine (~/.terminal-history-mcp/history.db). Sensitive values (API keys, tokens, passwords, JWTs) are redacted before storage. A shell hook can be installed for zsh/bash/fish to capture additional context (cwd, exit codes) needed by some tools.
terminal-history-mcp
Search your shell history (zsh / bash / fish) from Claude Code, Cline, Cursor, Zed, or any MCP client. Local-only. SQLite FTS5. Secret-redacted before storage.

What you can ask
"When did I last ssh into the staging server?"
"Show recent failed commands."
"What did I run yesterday in
/etc/nginx?""What's that long docker compose flag I used 3 weeks ago?"
"Show command chains around
kubectl apply."
Related MCP server: Longhand
Install
npm install -g terminal-history-mcp
terminal-history-mcp index # one-time backfill from existing history(Or run from a clone: git clone … && npm install && npm run build && npm link.)
Wire to Claude Code
claude mcp add --scope user terminal-history -- terminal-history-mcp
claude mcp listWire to other MCP clients
Anywhere that takes a stdio MCP server config:
{
"mcpServers": {
"terminal-history": {
"command": "terminal-history-mcp"
}
}
}Connect via MCPize
Use this MCP server instantly with no local installation:
npx -y mcpize connect @HasanJahidul/terminal-history --client claudeOr connect at: https://mcpize.com/mcp/terminal-history
Capture cwd + exit code (recommended)
By default zsh/bash history files store only the command. To unlock recent_in_dir and failed_commands, install the shell hook:
terminal-history-mcp install-hook zsh # or bash, or fish
exec $SHELL # reloadThe hook appends pipe-delimited lines to ~/.terminal-history-mcp/extended.log. Reindex picks them up.
To inspect the snippet first:
terminal-history-mcp print-hook zshTo remove:
terminal-history-mcp uninstall-hook zshTools
Tool | What it does |
| FTS5 keyword + prefix match across all history |
| Last N commands in a working dir (needs hook) |
| Commands with non-zero exit (needs hook) |
| For each match, list commands within ±5 min |
| Re-parse history files + extended log |
Privacy
Everything is local. The DB lives at ~/.terminal-history-mcp/history.db. Nothing is uploaded.
Secrets are scrubbed before insert. Detected patterns:
GitHub PATs (
ghp_*,gho_*, …)OpenAI keys (
sk-*)Slack tokens (
xox[baprs]-*)AWS access keys (
AKIA…)Authorization: Bearer/Basic <value>X-*-Token: …,X-*-Key: …,X-*-Secret: …headersEnv vars containing
TOKEN/KEY/SECRET/PASSWORD/API_KEYCLI flags
--token=…,--api-key …,-k …URL basic-auth
https://user:pass@hostJWTs (
eyJ.*.*)
If you find a leak, please open an issue. To wipe and re-index after upgrading patterns:
rm ~/.terminal-history-mcp/history.db*
terminal-history-mcp indexDevelopment
git clone https://github.com/hasanjahidul/terminal-history-mcp
cd terminal-history-mcp
npm install
npm run build
npm testLicense
MIT — see LICENSE.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceA powerful tool for exploring, searching, and managing your shell command history through the MCP (Model Control Protocol) interface. This project allows you to easily access, search, and retrieve your previously executed shell commands.2MIT
- AlicenseAqualityAmaintenancePersistent local memory for Claude Code that indexes every session's JSONL file verbatim into SQLite + ChromaDB. Exposes 17 MCP tools for semantic recall, deterministic file replay, and fuzzy "do you remember when..." queries across your entire session history — no API calls, nothing leaves the machine.1712MIT
- AlicenseAqualityBmaintenancePersistent memory + FTS5 full-text search for Claude Code conversation history. Indexes ~/.claude/projects/ JSONL into SQLite, exposes 10 MCP tools (store/recall/search memories, browse sessions, get summaries) plus prompts. Includes a web UI for visual exploration1011592MIT
- AlicenseAqualityDmaintenanceInspect, manage, and kill local dev servers via MCP. Stop guessing what's on :3000. Five tools: list servers with framework detection, inspect ports, find zombies, diagnose conflicts, safe-kill with dry-run default. Local, no cloud, no telemetry.5183MIT
Related MCP Connectors
Search your AI chat history (ChatGPT, Claude, Codex) from any MCP client. Remote, private, read-only
User-owned memory for AI agents, Copilot, Claude, IDEs, CLIs, and chat apps over remote MCP.
Hosted MCP memory: save sessions/decisions once, search from Claude, Cursor, ChatGPT. EU-hosted FTS.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/HasanJahidul/terminal-history-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server