mcp-guardian

mcp-guardian

Privacy firewall for AI agents that scans files, commits, and push URLs to prevent sensitive data leaks.

Category
访问服务器

README

mcp-guardian

English | 한국어 | 中文 | 日本語 | Español | Français | हिन्दी | العربية


Privacy firewall for AI-powered development. Stops secrets, PII, and internal keywords from ever reaching GitHub when an AI agent commits code.

✨ What this is

AI가 코드를 작성합니다. 그리고 실수를 합니다. 민감한 정보를 커밋에 넣거나, 토큰을 원격 URL에 노출하거나, 개인 정보를 README에 적는 실수 말이죠.

한 번 GitHub에 올라가면 되돌릴 수 없습니다. fork되고, 캐시되고, 영구적으로 남아요.

mcp-guardian4단계 방어선입니다:

# ❌ Before: AI가 실수할 때까지 기다림
AI가 API 키를 하드코딩 → push → 발견 → panic → 히스토리 정리 → 토큰 revoke

# ✅ After: 사전 차단
AI가 API 키를 하드코딩 → check_files가 즉시 차단 → 커밋 안 됨 → 사고 없음

실제 동작 방식:

AI: "이 파일 저장할게요"
→ check_files("src/config.py")
→ 🔍 스캔 중...
→ ❌ 발견: OpenAI API 키 패턴 (line 12)
→ 차단: 커밋이 진행되지 않음

AI: "아, 감사합니다. 수정할게요."

🎯 When to use it

Scenario 1: AI가 민감한 정보를 포함하는 파일을 작성할 때

AI: "이 설정 파일을 저장할게요"
→ check_files("config.py")

결과:
🔍 스캔 결과 — 2개 파일, 1개 문제

❌ config.py
   Line 12: OPENAI_API_KEY = "sk-proj-abc123..."
   → 감지됨: OpenAI API 키 패턴
   → 차단됨

✅ 수정 후:
   OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
   → ✅ 통과

Scenario 2: 커밋 전에 전체 변경사항 검사

# Staged 파일들을 자동으로 검사
git add .
→ check_commit()

결과:
🔍 커밋 전 검사 — 5개 파일

❌ README.md
   Line 45: export GH_TOKEN=ghp_abc123...
   → 감지됨: GitHub PAT 패턴
   → 커밋 차단됨

✅ 수정 후 다시 커밋:
   export GH_TOKEN=$GITHUB_TOKEN
   → ✅ 커밋 성공

Scenario 3: 이미 push된 민감한 정보 추적

"아, 전에 토큰을 실수로 push한 것 같은데..."
→ sanitize_history()

결과:
🔍 히스토리 검사 — 47개 커밋

❌ 발견: 1개
   커밋: a1b2c3d (2주 전)
   파일: .env
   내용: OPENAI_API_KEY = "sk-..."
   → 이 커밋에서 최초 노출됨

조치:
   1. 토큰 즉시 revoke
   2. git filter-branch로 히스토리 정리
   3. force push (주의!)

Scenario 4: 원격 URL에 토큰이 포함되었을 때

git remote set-url origin https://ghp_abc123@github.com/user/repo.git
git push
→ check_remote_url()

결과:
❌ 원격 URL에 토큰 포함됨
   감지됨: GitHub PAT (ghp_...)
   자동 수정: 토큰 제거 후 push

✅ 수정된 URL:
   https://github.com/user/repo.git

Why it exists

AI agents write code faster than humans can review it. A single stray credential or personal name in a README can become a permanent public record the moment a commit lands on GitHub. mcp-guardian is the defense layer that catches these mistakes at four checkpoints:

  1. Edit timecheck_files flags sensitive content before save.
  2. Commit timecheck_commit or the pre-commit hook blocks the commit entirely.
  3. Push timecheck_remote_url strips PATs that leaked into the remote URL.
  4. Audit timesanitize_history traces past leaks to their originating commit.

Recursive safety

The server ships its own pattern rules in src/mcp_guardian/patterns.py. That file is whitelisted (along with server.py and test fixtures) so the guardian never blocks itself when it scans its own repository.

Install

pip install mcp-guardian

Or from source:

git clone https://github.com/nerin81-netizen/mcp-guardian
cd mcp-guardian
pip install -e .

Wire it up

In your MCP client config (e.g. Claude Code's claude_desktop_config.json):

{
  "mcpServers": {
    "guardian": {
      "command": "python",
      "args": ["-m", "mcp_guardian.server"]
    }
  }
}

Then ask your agent:

"Before you commit, run check_commit on this repo."

Or install the OS-level enforcement once and forget:

mcp-guardian install-hook

Now every git commit is guarded, even if the agent forgets to call the tool.

Rule categories

Category Examples caught
Personal identifiers company / project / personal-name keywords
GitHub tokens ghp_…, gho_…, github_pat_…
Provider keys OpenAI, Anthropic, Slack, Google, AWS
Generic secrets api_key = "…" style assignments
Email addresses non-allowlisted addresses

Inspect the live rules via the MCP resource:

resource: config://rules

License

MIT — see LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选