惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
Forbes - Security
Forbes - Security
WordPress大学
WordPress大学
P
Proofpoint News Feed
T
Threat Research - Cisco Blogs
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
Spread Privacy
Spread Privacy
D
Darknet – Hacking Tools, Hacker News & Cyber Security
大猫的无限游戏
大猫的无限游戏
博客园 - 三生石上(FineUI控件)
P
Privacy International News Feed
A
About on SuperTechFans
T
Tailwind CSS Blog
I
InfoQ
S
Securelist
云风的 BLOG
云风的 BLOG
罗磊的独立博客
Recent Announcements
Recent Announcements
T
The Exploit Database - CXSecurity.com
B
Blog RSS Feed
V
Visual Studio Blog
Know Your Adversary
Know Your Adversary
The GitHub Blog
The GitHub Blog
Jina AI
Jina AI
腾讯CDC
Cyberwarzone
Cyberwarzone
有赞技术团队
有赞技术团队
AWS News Blog
AWS News Blog
博客园 - 【当耐特】
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
F
Full Disclosure
S
Secure Thoughts
博客园 - 司徒正美
J
Java Code Geeks
Y
Y Combinator Blog
Google Online Security Blog
Google Online Security Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
Help Net Security
Help Net Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Project Zero
Project Zero
T
Tenable Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Tor Project blog
MyScale Blog
MyScale Blog
Scott Helme
Scott Helme
小众软件
小众软件
K
Kaspersky official blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
AI Agents und MCP: Warum autonome Agenten scheitern und wie Sie die Kontrolle behalten
Uhltak Therestismysecret · 2026-05-30 · via DEV Community

AI Agents und MCP – Warum autonome Agenten oft scheitern und wie Sie das Ruder übernehmen

„Man gibt einem Computer ein Ziel, er geht in die Küche, kauft sich ein Sandwich und bricht das Haus ab.“ – Das ist das Bild, das viele von uns beim Stichwort autonome Agenten im Kopf haben. In der Praxis jedoch stellt sich häufig heraus, dass diese „Küchen‑Bots“ mehr Chaos als Ordnung produzieren. In diesem Artikel zerlegen wir das Problem Stück für Stück, zeigen drei echte Code‑Beispiele und geben ein persönliches Fazit, das Sie sofort umsetzen können.


1. Was sind AI Agents und was hat das mit MCP zu tun?

Erklärung: Ein AI Agent ist ein Software‑Konstrukt, das basierend auf einem Large Language Model (LLM) eigenständig Entscheidungen trifft – zum Beispiel, ein Tool aufzurufen, Daten zu verarbeiten oder einen Task zu delegieren. MCP (Machine‑Code‑Proxy) ist dabei das Bindeglied zwischen dem LLM‑Agenten und den System‑Tools. MCP stellt eine standardisierte Schnittstelle bereit, über die der Agent Befehle in einer strukturierten Form (z. B. JSON) sendet, die dann vom Proxy in System‑Calls übersetzt werden.

Beispiel‑Snippet (MCP‑Schema):

{
  "action": "run_command",
  "args": {
    "cmd": "ls -l /var/log",
    "timeout": 30
  }
}

Der Agent liefert dieses JSON an den MCP‑Daemon, der dann ls -l /var/log ausführt und das Ergebnis zurückgibt.

Persönliche Einschätzung: Viele Entwickler glauben, dass das reine Vorhandensein eines MCP automatisch zuverlässige Tool‑Aufrufe ergibt. Das ist ein Trugschluss – der eigentliche Stolperstein liegt in der Semantik der übermittelten Befehle und der Sicherheits‑Policies, die selten von Grund auf definiert werden.


2. Der technische Ablauf – vom Prompt zum Systemaufruf

Erklärung: Der klassische Flow sieht so aus:

  1. Der Nutzer gibt einen Prompt (z. B. "Erstelle ein Backup von /etc") ein.
  2. Das LLM interpretiert die Absicht und generiert ein MCP‑Payload.
  3. Der MCP‑Daemon validiert das Payload gegen ein Policy‑Set.
  4. Der Daemon führt den Befehl aus und leitet die Ausgabe zurück.

Beispiel‑Code (Python‑Agent + MCP‑Client):

import json, requests

prompt = "Zeige die aktiven Prozesse, die mehr als 200 MB RAM verbrauchen"
# 1️⃣ LLM‑Aufruf (hier mit Ollama als lokales Modell)        
resp = requests.post(
    "http://localhost:11434/api/generate",
    json={"model": "llama2", "prompt": prompt}
)
payload = json.loads(resp.text)['payload']   # → MCP‑JSON

# 2️⃣ MCP‑Client‑Aufruf
mcp_resp = requests.post(
    "http://localhost:8080/execute",
    json=payload
)
print(mcp_resp.json())

Dieses Minimalbeispiel zeigt bereits, wo die Vertrauenszonen liegen: Das LLM liefert das Payload, das MCP‑Backend prüft es – aber nur, wenn die Policies korrekt definiert sind.

Persönliche Einschätzung: In meinem täglichen Homelab habe ich das Schema ein einziges Mal ohne Policy verfasst und sofort endlose fork bomb‑Muster beobachtet. Ohne eine klare Allow‑List laufen die Agents schnell in unvorhergesehene Systemzustände.


3. Beispiel 1 – Ein CLI‑Tool per Subprocess starten

Erklärung: Das einfachste Szenario ist, dass ein Agent ein lokales Kommando ausführt – zum Beispiel dig für DNS‑Abfragen. Der MCP‑Daemon übersetzt das JSON in einen subprocess.run‑Aufruf.

Konkretes Beispiel (Docker‑Compose‑Setup):

version: "3.9"
services:
  mcp:
    image: ghcr.io/mcp-proxy/mcp:latest
    ports:
      - "8080:8080"
    environment:
      - "ALLOWED_COMMANDS=dig,nslookup"
  agent:
    image: ollama/llama2:latest
    depends_on: [mcp]
    command: "sleep infinity"

Agent‑Payload:

{
  "action": "run_command",
  "args": {
    "cmd": "dig +short example.com",
    "timeout": 10
  }
}

MCP‑Log‑Auszug:

[INFO] Incoming request: run_command
[DEBUG] Validated command against policy – allowed
[TRACE] Executing: dig +short example.com
[INFO] Command finished, exit code 0, runtime 0.12s

Damit erhalten wir die IP von example.com zurück.

Persönliche Einschätzung: Das Ganze klingt simpel, bis der Agent plötzlich dig -x 0.0.0.0 ausführt und unser internes Netzwerk scannt. Ohne Rate‑Limiting kann ein gut gemeinter Agent leicht zu einer DoS‑Situation werden.


4. Beispiel 2 – REST‑API‑Aufruf über MCP

Erklärung: Moderne Tools bieten HTTP‑APIs (z. B. GitHub, JIRA). Hier muss der MCP nicht nur curl ausführen, sondern auch Header, Auth und JSON‑Body korrekt handhaben.

MCP‑Payload für GitHub‑Issue‑Erstellung:

{
  "action": "http_request",
  "args": {
    "method": "POST",
    "url": "https://api.github.com/repos/me/me/issues",
    "headers": {
      "Authorization": "Bearer {{$GITHUB_TOKEN}}",
      "Accept": "application/vnd.github+json"
    },
    "json": {
      "title": "Automatischer Bug‑Report",
      "body": "Erzeugt von AI‑Agent am $(date)"
    }
  }
}

MCP‑Daemon‑Konfiguration (policy.yaml):

http_requests:
  - domain: "api.github.com"
    methods: ["GET", "POST"]
    max_body_size: 10KB
    auth_required: true

Ausgabe (nach erfolgreichem Aufruf):

{
  "status": 201,
  "response": {
    "html_url": "https://github.com/me/me/issues/42",
    "number": 42
  }
}

Persönliche Einschätzung: Der Knackpunkt ist die Credential‑Injection. Wenn das LLM den Token aus einem Prompt ableitet, endet das Projekt in einer Sicherheitskatastrophe. In meiner Praxis habe ich deshalb strikt die Token‑Übergabe über die MCP‑Umgebungsvariablen und niemals im Prompt erlaubt.


5. Beispiel 3 – Kombination aus LangChain, lokalem LLM und Tool‑Orchestrierung

Erklärung: Fortgeschrittene Agents nutzen Bibliotheken wie LangChain oder CrewAI, um mehrere Schritte hintereinander zu planen. Der Agent baut dann einen Chain aus mehreren MCP‑Aufrufen.

Python‑Beispiel (LangChain‑Chain):

from langchain.agents import initialize_agent, Tool
from langchain.llms import Ollama
import requests, json

# ---- MCP‑Wrapper ----
class MCPTool(Tool):
    name = "MCP"
    description = "Executes a system command via MCP"
    def _run(self, cmd: str) -> str:
        payload = json.dumps({"action": "run_command", "args": {"cmd": cmd, "timeout": 20}})
        r = requests.post("http://localhost:8080/execute", data=payload)
        return r.json().get("output", "")

# ---- LLM + Agent ----
llm = Ollama(model="llama2")
agent = initialize_agent([MCPTool()], llm, agent="zero-shot-react-description", verbose=True)

# Prompt: Prüfe das Disk‑Layout und erstelle ein Report‑PDF
result = agent.run("run df -h && generate a PDF report with the output")
print(result)

Erwartete MCP‑Aufrufe:

  1. df -h
  2. pandoc -f markdown -t pdf -o /tmp/report.pdf

Persönliche Einschätzung: Das Szenario zeigt, warum Komposability ein zweischneidiges Schwert ist. Jeder Zwischenschritt erhöht das Risiko einer Fehlkonfiguration. Ich habe deshalb in allen meinen produktiven Chains ein Fallback‑Mechanismus eingebaut, der bei unbekannten Befehlen die Ausführung stoppt und eine Fehlermeldung zurückgibt.


6. Typische Fehler – Warum viele Projekte im Chaos enden

Fehler Warum er passiert Konsequenz
Ungeprüfte Payloads Agent liefert beliebige JSON‑Strukturen Arbiträrer Code‑Execution
Fehlende Rate‑Limits Keine Beschränkung der Aufrufe DoS‑Angriffe, Ressourcen‑Exhaustion
Offene Credential‑Weitergabe Tokens im Prompt eingebettet Kompromittierte Secrets
Keine Output‑Sanitization Rückgabe wird direkt weiterverarbeitet Injection‑Angriffe (z. B. Shell‑Injection)
Zu breite Allow‑List ALLOWED_COMMANDS=* Unkontrollierter Zugriff auf System‑Tools

Kurz‑Checkliste:

  1. Definieren Sie eine Whitelist aller erlaubten Aktionen.
  2. Setzen Sie Timeouts und Memory‑Limits im MCP‑Daemon.
  3. Verwenden Sie Vault‑ähnliche Mechanismen für Secrets.
  4. Loggen Sie jedes MCP‑Payload + Response für Auditing.

Persönliche Einschätzung: In meinem letzten Projekt habe wir alle fünf Punkte vernachlässigt – das Resultat war ein nicht mehr stoppbarer Crash‑Loop, der das gesamte Netzwerk lahmlegte. Ein kurzer Blick auf den MCP‑Log hätte das sofort aufgezeigt.


7. Best Practices – So halten Sie die Kontrolle wieder zurück

  1. Policy‑First‑Ansatz – Schreiben Sie das Policy‑File bevor Sie einen Agenten bauen.
  2. Sandbox‑Umgebung – Führen Sie MCP zunächst in einem isolierten Container (--security-opt=no-new-privileges) aus.
  3. Auditable Logging – Integrieren Sie structured-logging (JSON) und schicken Sie die Logs an Elastic Stack.
  4. Fail‑Open vs. Fail‑Secure – Standardmäßig fail‑secure: Wenn ein Payload nicht eindeutig ist, wird es verworfen.
  5. Versionierung – Taggen Sie sowohl das LLM‑Modell als auch das MCP‑Binary, damit Sie bei Rollbacks exakt dieselben Versionen wiederherstellen können.

Beispiel‑Docker‑Run (sichere MCP‑Instanz):

docker run -d \
  --name mcp-secure \
  --restart unless-stopped \
  --read-only \
  --tmpfs /run \
  -e ALLOWED_COMMANDS="dig,nslookup" \
  -e POLICY_FILE="/etc/mcp/policy.yaml" \
  -v $(pwd)/policy.yaml:/etc/mcp/policy.yaml:ro \
  ghcr.io/mcp-proxy/mcp:latest

Damit ist das Dateisystem schreibgeschützt und nur die definierte Policy ist einsehbar.


8. Fazit und konkreter nächster Schritt

AI‑Agents in Kombination mit MCP besitzen ein enormes Potenzial: Sie können Routine‑Tasks automatisieren, komplexe Workflows orchestrieren und sogar in Bereichen wie Incident‑Response glänzen. Aber das gleiche Potenzial birgt das Risiko, dass ein schlecht konfigurierter Agent das gesamte System destabilisiert oder kritische Secrets preisgibt.

Mein Fazit:

  • Trust but verify – Vertrauen Sie dem LLM, prüfen Sie aber jedes generierte Payload.
  • Policy First – Lassen Sie das Policy‑File das Herzstück Ihrer Sicherheitsstrategie sein.
  • Iteratives Testing – Beginnen Sie mit einem Minimal‑Set an Befehlen, erweitern Sie schrittweise und beobachten Sie das Logging.

Konkreter nächster Schritt für Sie:

  1. Erstellen Sie eine policy.yaml mit einer White‑List der wirklich benötigten Befehle.
  2. Deployen Sie den MCP‑Daemon in einem isolierten Docker‑Container (Beispiel‑Befehl oben).
  3. Implementieren Sie einen einfachen Python‑Agenten, der das Policy‑File nutzt, und testen Sie ihn mit dem dig‑Beispiel.
  4. Analysieren Sie die Logs, passen Sie Timeout‑ und Rate‑Limits an und erweitern Sie die Whitelist nur nach Bedarf.

Auf diese Weise verwandeln Sie die anfängliche Küchen‑Katastrophe in ein kontrolliertes, nachvollziehbares System – und können die echten Vorteile von autonomen AI‑Agents genießen, ohne dem Chaos zu erliegen.