mcpField
T
Terminal History Mcp

Terminal History Mcp

Local
github.com/HasanJahidulDeveloper Tools5Updated 24w ago

About Terminal History Mcp

Terminal History Mcp is a local MCP server for developers and coding agents to search zsh, bash, and fish history. It stores commands in SQLite FTS5 and scrubs detected secrets before storage.

Key features

  1. 01Full-text shell history search
  2. 02Filter commands by working directory
  3. 03Find commands with non-zero exit codes
  4. 04Inspect nearby command sequences
  5. 05Reindex history files and logs
  6. 06Redact secrets before storage

Use cases

  1. 01Recall a command used weeks ago
  2. 02Review failed commands in a shell session
  3. 03Find commands run in a specific directory

MCP support

Exposes shell-history search, filtering, and reindexing tools to MCP clients. It can run over stdio and is designed for clients such as Claude Code, Cursor, Cline, and Zed.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"terminal-history": {
"command": "npx",
"args": [
"-y",
"terminal-history-mcp"
]
}
}
}
Run commandnpx -y terminal-history-mcp

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npmterminal-history-mcp

Tools

5

Saved tool list · updated 3w ago

This tool takes no parameters.

Details

From the project README

terminal-history-mcp logo

terminal-history-mcp

MCPize mcp.so terminal-history-mcp MCP server CI npm version License: MIT

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.

demo

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."

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 list
Wire 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 claude

Or 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                              # reload

The 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 zsh

To remove:

terminal-history-mcp uninstall-hook zsh

Tools

ToolWhat it does
search_history(query, limit)FTS5 keyword + prefix match across all history
recent_in_dir(cwd, limit)Last N commands in a working dir (needs hook)
failed_commands(since_ts_ms, limit)Commands with non-zero exit (needs hook)
command_chains(query, window_ms, limit)For each match, list commands within ±5 min
reindexRe-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: … headers
  • Env vars containing TOKEN / KEY / SECRET / PASSWORD / API_KEY
  • CLI flags --token=…, --api-key …, -k …
  • URL basic-auth https://user:pass@host
  • JWTs (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 index

Development

git clone https://github.com/hasanjahidul/terminal-history-mcp
cd terminal-history-mcp
npm install
npm run build
npm test

License

MIT — see LICENSE.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.