mcp-keyscan
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
mcp-keyscan
Never prints a secret value. Every key it finds is shown only as a redacted preview (first 4 characters + length), in the terminal, in the JSON and in the shareable report. A test in this repo (npm test) fails if any fixture secret appears in stdout, stderr, the report file or the JSON.
mcp-keyscan finds plaintext API keys in your AI-agent and MCP client configs, agent logs and transcripts, and shell history, then gives you a redacted report you can paste into an issue, a chat or a post, with a one-line fix per finding.
npx github:aether-cell/mcp-keyscanLocal only: no network calls, no telemetry, zero dependencies. Node 18+. Apache-2.0.
Did Claude Code save your key in settings.local.json?
Claude Code's "Yes, and don't ask again" option can write the exact approved command — API key included — into .claude/settings.json or .claude/settings.local.json. The Hacker News, citing Apiiro, reports 1,122 public copies of settings.local.json holding at least one secret (1,379 secrets total) out of 104,185 copies.
Check your machine (the report is redacted and never prints the value):
npx github:aether-cell/mcp-keyscanmcp-keyscan flags API keys and tokens in permissions.allow, and also flags database passwords in connection strings like psql postgres://user:pass@host. If a key is in a permissions.allow entry, rotate it, then remove that entry, then add .claude/settings.local.json to the repo's .gitignore; if it was ever committed, the key is in git history, so rotate first. mcp-keyscan does not edit the file.
Related MCP server: Keyspoor MCP
Why
Setup guides tell you to paste keys straight into
env,headersorargs. Those files get synced, shared, committed, and read by agents.Agents then copy the same keys into their logs and transcripts (
~/.claude/projects/*.jsonl,~/.codex/sessions, Cline tasks…), andclaude mcp add -e KEY=…/export KEY=…leave them in shell history.Most scanners stop at the config file and print the secret back to you. mcp-keyscan checks all three places and never prints the value, so the report itself is safe to share.
Usage
npx github:aether-cell/mcp-keyscan # known agent configs + logs + shell history + current project
npx github:aether-cell/mcp-keyscan path/to/repo # walk a directory instead (add --global for the per-user locations too)
npx github:aether-cell/mcp-keyscan --out keyscan.md # also save the shareable report
npx github:aether-cell/mcp-keyscan --json # machine-readable, still redacted
npx github:aether-cell/mcp-keyscan --min-severity high # only provider-specific hits
npx github:aether-cell/mcp-keyscan --no-logs --no-history # configs only
npx github:aether-cell/mcp-keyscan --list-locations # which paths it checks on this machine
npx github:aether-cell/mcp-keyscan --mcp # stdio MCP server, tool: scan_secretsExit code: 0 = clean, 1 = findings (at or above --min-severity), 2 = usage error. Works as a CI gate:
- run: npx --yes github:aether-cell/mcp-keyscan . --min-severity mediumUse it from an agent (MCP server)
--mcp runs mcp-keyscan as a stdio MCP server with one read-only tool, scan_secrets, so an agent can check its own machine. The tool returns the same redacted report (or redacted JSON), so the agent never sees a value either.
{
"mcpServers": {
"keyscan": { "command": "npx", "args": ["-y", "github:aether-cell/mcp-keyscan", "--mcp"] }
}
}Tool arguments (all optional): paths, include_logs, include_history, min_severity, format (text | json).
Sample report
Fixture keys below are fake. Home paths are shown as ~, so the report does not reveal your user name.
# mcp-keyscan report (v1.0.0)
Scanned 10 files on this machine: 7 agent/MCP configs, 1 agent log, 2 shell histories. Nothing left this machine.
Found 4 plaintext secrets: 4 high, 0 medium, 0 low.
Values are redacted (first 4 characters + length). This report is safe to share.
1. [HIGH] .cursor/mcp.json:7 (Cursor, server github · env.GITHUB_PERSONAL_ACCESS_TOKEN)
github-pat · github · ghp_…(40 chars)
fix: rotate this github key, then replace the value with "${env:GITHUB_PERSONAL_ACCESS_TOKEN}" and export GITHUB_PERSONAL_ACCESS_TOKEN outside the file (or use a keychain/broker)
2. [HIGH] .mcp.json:5 (Claude Code / portable, server stripe · args[2])
stripe-access-token · stripe · sk_l…(28 chars)
fix: rotate this stripe key, then replace the value with "${STRIPE_API_KEY}" and export STRIPE_API_KEY outside the file (or use a keychain/broker)
3. [HIGH] ~/.bash_history:4 (shell)
curl-auth-header · github · ghp_…(40 chars)
fix: rotate this github key, then delete line 4 from ~/.bash_history; pass keys via env or a prompt, not on the command line
4. [HIGH] ~/.claude/projects/-work-demo/session.jsonl:2 (Claude Code)
stripe-access-token · stripe · sk_l…(32 chars)
fix: rotate this stripe key, then delete or scrub ~/.claude/projects/-work-demo/session.jsonl; the agent wrote it to disk in clear
scanned with npx mcp-keyscanWhat it scans
Per-user locations (Linux ~/.config, macOS ~/Library/Application Support, Windows %APPDATA%), plus project files in the current directory:
Source | Files |
Claude Desktop |
|
Claude Code |
|
Cursor |
|
VS Code |
|
Windsurf / Devin Desktop |
|
Zed |
|
Continue |
|
Cline / Roo / Kilo Code |
|
Gemini CLI |
|
Codex |
|
Others | opencode, Goose, Kiro, LM Studio, Amazon Q, Copilot CLI, Aider ( |
Shell history |
|
PATH mode walks the directory (skipping .git, node_modules, virtualenvs, build dirs) and picks up MCP configs, .env* and history files by name. Log files over 50 MB are skipped and listed.
What it detects
The gitleaks rule set, vendored unchanged in
rules/gitleaks.json(221 rules, MIT, seerules/LICENSE-gitleaks): provider keys (Anthropic, OpenAI, GitHub, AWS, Stripe, Slack, Hugging Face, GCP, …), private keys, JWTs,curl -H "Authorization: …"and gitleaks' generic API-key rule, with gitleaks' keywords, entropy thresholds and allowlists. No home-grown regex farm.One key-name heuristic on top, because agent configs are mostly
NAME=value: a sensitive name (*_API_KEY,*TOKEN*,*SECRET*,PASSWORD,--api-key VALUE,?token=) with a secret-looking value (letters + digits, ≥ 12 chars, entropy ≥ 3), plus generic credentials in URLs (https://user:pass@). These are reported asmedium. Passwords in database connection strings (postgres://,mysql://,mongodb://,redis://, and similar) are reported ashigh(connection-string-password).Ignored:
${VAR},${env:VAR},${input:id},$VAR,%VAR%,{{…}},<…>,op://…and similar references, and placeholders (your-api-key-here,xxxx,changeme,…EXAMPLE).In MCP JSON/JSONC configs each finding names the server and the field (
env.X,headers.Authorization,args[2]); TOML findings name the[mcp_servers.*]table.
Severity: high = a gitleaks provider rule; medium = gitleaks' generic rule or the key-name heuristic. In logs and transcripts the generic rule is skipped (too noisy there); provider rules and the heuristic still run.
Fixing findings
Every finding has a one-line fix: the env-var reference your client understands (${env:VAR} for Cursor / VS Code, ${VAR} for Claude Code .mcp.json), which line to delete from your history, or which log to scrub. Always rotate a key that was found: it was on disk in clear. mcp-keyscan never edits files.
Limitations
YAML and TOML are scanned line by line, not parsed.
Detection is regex + heuristic. Expect some false positives at
medium(use--min-severity high) and misses for unusual formats.Secrets in OS keychains, browser storage or client databases (SQLite) are out of scope.
Paths follow each client's docs as of 2026-11; clients move files between releases. Pass a
PATHfor anything else, and open an issue with the location.Large transcript folders take a while (it reads every line locally);
--no-logsskips them.
Development
npm test # node --test, no dependenciesAll keys in test/fixtures are fake. To update the vendored gitleaks rules, see scripts/vendor-gitleaks.py.
v0.1.0 (Python) is tagged as v0.1.0; v1 is a Node rewrite so npx works with no install.
License
Apache-2.0. Copyright aether-cell contributors. Vendored gitleaks rules: MIT, Copyright (c) 2019 Zachary Rice.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Scan configs, files, or text for leaked secrets and obvious misconfigurations. Nothing stored.
Security scanner for MCP servers and skills: Unicode injection, patterns, secrets.
Scan text and git diffs for committed credentials using real vendor key formats plus entropy.
Security scanner for MCP servers. Detect vulnerabilities, prompt injection, and tool poisoning.
Related MCP Servers
- AlicenseAqualityDmaintenanceScans diffs, files, and snippets for leaked secrets like AWS keys, GitHub tokens, and private keys, returning redacted findings while running fully locally without network calls.1MIT
- AlicenseNot gradedqualityBmaintenanceRead-only MCP server that exposes the scan_text and scan_paths tools so AI coding agents can scan text, files, staged Git changes, local history and archives for secrets entirely offline, returning redacted findings with rules, positions and fingerprints and flagging incomplete scans. Results can be emitted as JSON, JSONL or SARIF without ever serializing raw secret values or source snippets.Apache 2.0
- AlicenseBqualityBmaintenanceScans MCP client configurations for risky settings without starting the configured servers. Returns redacted findings through a read-only MCP server and CLI232 PyPIMIT
- AlicenseNot gradedqualityBmaintenanceA read-only MCP server that lets agents scan a project's AI agent setup — Claude Code, Codex, Cursor, MCP servers and instruction files — and surface security findings such as the lethal trifecta, broad permissions, exposed secrets and unpinned packages.57 npmMIT