跳到正文
DEV Community· intothewild·· 14 天前AI 評分47

MCP 伺服器能否防止 AI Agent 洩露秘密?

Can an MCP Server Actually Help Prevent AI Agents From Leaking Secrets?

AI 導讀

StagedSec 正在探索透過 MCP 伺服器和 AI Agent hook,在 AI Agent 寫入內容前掃描秘密資訊。這個早期開源項目還包括 Go 秘密偵測引擎、CLI、Git 整合及 VS Code 擴充功能;如何處理分拆、重試和混淆的秘密仍是尚待探索的問題。

正文

intothewild

I've been experimenting with MCP servers and AI coding agents while building an open-source project called StagedSec.

One thing I've been thinking about is where security checks should happen when an AI agent works with a developer's repository.

Most secret scanners operate on files, Git history, or commits. These are useful, but with AI agents, there's another interesting point: the moment an agent attempts to write something.

Imagine an agent generating a configuration file containing:

API_KEY=sk_live_...
DATABASE_PASSWORD=...

A scanner can find these values later, but what if we could inspect the content before allowing the write?

That's one of the ideas behind StagedSec.

What I'm experimenting with

StagedSec currently has:

  • A Go-based secret detection engine.
  • An MCP server that exposes scanning capabilities to AI agents.
  • An agent hook that checks tool-call content.
  • A CLI, Git integration, and VS Code extension.

The goal is to make secret detection available closer to the point where the content is generated.

But there are still difficult problems

I'm particularly interested in a few questions:

  1. What happens when an agent splits a secret across multiple tool calls?
  2. How should a security hook handle repeated retries without making the agent workflow unusable?
  3. Can we detect encoded or obfuscated secrets without storing sensitive content?
  4. How much should an MCP server be responsible for enforcing security versus simply reporting findings?

These aren't completely solved problems in my implementation. I'm exploring them as I develop the project.

I'd like to hear from people working with MCP and AI agents

If you're building MCP servers, AI coding tools, or developer security tooling, I'd genuinely like to hear how you're approaching these problems.

I'm also looking for a few people willing to test the MCP integration and report what works or doesn't.

Project: https://gitlab.com/stagedsec/stagedsec

MCP package: https://www.npmjs.com/package/stagedsec-mcp-server

This is an early open-source project, and I'm interested in technical criticism just as much as positive feedback.

來源:DEV Community · dev.to