- Home
- Skills
- Agents & Orchestration
- Triage Sentinel: Self-Healing MCP Agent & Guardrails Kit
Works with the AI Agents you already use
Triage Sentinel: Self-Healing MCP Agent & Guardrails Kit
by Amit Dwivedi
Turn fragile Python/MCP agents into production-ready systems with Pydantic self-healing retries, circuit breakers, prompt-injection & SSRF guardrails, and an offline chaos test suite.
$9.99
Triage Sentinel: Self-Healing MCP Agent & Guardrails Kit
Example session with this skill installed
I have an MCP-backed Python agent that keeps crashing on malformed LLM tool arguments, getting stuck in retry loops, and failing during downstream 503 outages. Use the self-healing-mcp-agent skill to add Pydantic validation retries, per-tool circuit breakers, prompt-injection/SSRF guardrails, and an offline chaos test suite.
- Read your context and instructions
- Compiled the triage sentinel
I have integrated the
Self-Healing MCP & Guardrails Harness into your Python agent, adding pre-execution Pydantic schema retries, per-tool circuit breakers, SHA-256 loop detection, prompt-injection/SSRF guardrails, and an offline pytest chaos evaluation suite.
What Was Wired In
| Component | File Added / Updated | Protection Provided |
|---|---|---|
| Pydantic Validation Retries | src/runtime/orchestrator.py | Catches ValidationError before tool execution and feeds field errors back to the LLM to self-heal (up to 2 retries/step) |
| Circuit Breakers & Loop Guard | src/guardrails/circuit_breaker.py | Trips ToolCircuitBreaker (CLOSED → OPEN → HALF_OPEN) after 3 failures; blocks duplicate (tool, args) calls via SHA-256 fingerprinting |
| Injection & SSRF Guards | src/guardrails/sanitizer.py | Quarantines instruction-override payloads in <untrusted_ticket_data> XML tags; restricts HTTP replay to /api/... |
| Offline Chaos Sandbox | src/tools/target_sandbox.py | FastAPI mock backend with http_503_storm, latency_spike, null_pointer_500, and malformed_json modes |
Key Implementation (orchestrator.py)
# Self-healing schema validation loop before executing any MCP tool
while validation_retries <= self.max_validation_retries:
try:
validated_args = schema_cls.model_validate(current_raw_args).model_dump()
break
except ValidationError as ve:
validation_retries += 1
if validation_retries > self.max_validation_retries:
break
error_details = [f"Field '{e['loc'][0]}': {e['msg']}" for e in ve.errors()]
messages.append({
"role": "user",
"content": f"VALIDATION_FAILED for '{tool_name}':\n" + "\n".join(error_details),
})
retry_resp = await self.llm_provider.decide_next_step(...)
current_raw_args = retry_resp.arguments or {}
# Block duplicate loops & open circuits before execution
is_new, loop_err = budget.register_action(tool_name, validated_args)
if not cb.can_execute():
return {"success": False, "error": "CIRCUIT_BREAKER_OPEN"}
Verification (pytest -v -s)
All 36 unit & E2E chaos tests passed offline using MockLLMProvider (zero API calls):
test_self_healing_schema_validation_retry— PASSED (1 validation retry, recovered toCOMPLETE)test_chaos_503_storm_circuit_breaker— PASSED (tripped toOPENafter 3× 503s, escalated asP0)test_adversarial_prompt_injection_quarantine— PASSED (QUARANTINED_INJECTION, 0 tokens leaked)test_ssrf_guard_blocks_metadata_and_traversal— PASSED (blocked169.254.169.254and../)
Next Steps
- Run
pytest -v -sin your environment to confirm all 36 checks pass locally. - Set
OPENAI_API_KEYorOPENROUTER_API_KEYin.envand swapMockLLMProviderforOpenAICompatibleProviderwhen ready for live traffic.
Connects securely to your tools. The creator never sees your data.
About this skill
Stop your AI agents from crashing on bad tool arguments, looping infinitely, or getting hijacked by prompt injections.
Triage Sentinel is a plug-and-play production harness and Agent Skill that teaches Claude Code, Cursor, Copilot, and 20+ coding agents how to wire battle-tested reliability and security layers into any Python, FastAPI, or MCP-backed AI agent.
What’s Included
Self-Healing Schema Retries: Validates every LLM tool call against strict Pydantic v2 schemas before execution. When the model hallucinates bad arguments, structured ValidationError feedback is fed back to the LLM to self-correct automatically (up to 2 retries/step) instead of crashing. Per-Tool Circuit Breakers (CLOSED → OPEN → HALF_OPEN): Trips after 3 consecutive tool failures or timeouts to stop retry storms during downstream 503 outages, with automatic cooldown recovery. Loop Detection & Budget Caps: Enforces hard step, token, and wall-clock limits plus SHA-256 action fingerprinting to block identical repeated tool calls.
Defense-in-Depth Guardrails
PromptInjectionGuard: Detects instruction-override / exfiltration patterns and isolates untrusted payloads inside <untrusted_ticket_data> XML delimiters. SSRFGuard: Strict /api/... allowlist blocking external domains, file://, path traversal (..), and cloud metadata (169.254.169.254). MCP Server + ChromaDB Duplicate Search: Official mcp Python SDK server with HTTP endpoint replay, service log querying, and ChromaDB semantic duplicate matching. Zero-Cost Offline Chaos Suite (pytest): Includes a toggleable FastAPI chaos sandbox (503 storms, latency spikes, NPE 500s, malformed JSON), a deterministic MockLLMProvider, and 36 passing unit & E2E tests—run everything in CI with zero API keys.
- In-Memory Store & Simulated Logs: Out of the box,
search_duplicate_issuesuses an ephemeral in-memory ChromaDB collection (pre-seeded with 8 sample tickets) andquery_service_logsreturns simulated logs. Point these adapters to your persistent vector DB and log provider (e.g., Datadog, CloudWatch, ELK) for production use. - Python & MCP SDK Versions: Tested on Python 3.12 (Python 3.10–3.12 recommended for
chromadb/onnxruntimewheel compatibility). UsesMCPServerfrommcp>=2.0; if your codebase pinsmcp<2, replaceMCPServerwithFastMCP. - Regex-Based Injection Detection:
PromptInjectionGuardcombines regex signature matching with<untrusted_ticket_data>XML delimiter isolation rather than a separate ML classifier, so it should be paired with strict tool allowlists (SSRFGuard). - Single-Process State:
ToolCircuitBreakerandRunBudgetTrackerkeep state in memory per instance rather than in a distributed store like Redis.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 10 days ago
- Software
Python 3.10+MCP-backed
- Optional
OpenAI
orOpenRouter API key
Permissions
File Scopes
Read/Write Files and Terminal/Shell are used to copy the guardrail, circuit-breaker, and MCP templates into your src/ and tests/ directories and run pytest. Network Access and Environment Variables are only needed when connecting a live OpenAI/OpenRouter API key; offline chaos tests run locally via FastAPI ASGI transport and MockLLMProvider with zero external network calls.
What's inside
Frequently Asked Questions
New in Agents & Orchestration
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Agents & Orchestration.