Works with the AI Agents you already use

    Triage Sentinel: Self-Healing MCP Agent & Guardrails Kit

    by Amit Dwivedi

    1

    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

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Triage Sentinel: Self-Healing MCP Agent & Guardrails Kit

    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

    ComponentFile Added / UpdatedProtection Provided
    Pydantic Validation Retriessrc/runtime/orchestrator.pyCatches ValidationError before tool execution and feeds field errors back to the LLM to self-heal (up to 2 retries/step)
    Circuit Breakers & Loop Guardsrc/guardrails/circuit_breaker.pyTrips ToolCircuitBreaker (CLOSED → OPEN → HALF_OPEN) after 3 failures; blocks duplicate (tool, args) calls via SHA-256 fingerprinting
    Injection & SSRF Guardssrc/guardrails/sanitizer.pyQuarantines instruction-override payloads in <untrusted_ticket_data> XML tags; restricts HTTP replay to /api/...
    Offline Chaos Sandboxsrc/tools/target_sandbox.pyFastAPI 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 to COMPLETE)
    • test_chaos_503_storm_circuit_breaker — PASSED (tripped to OPEN after 3× 503s, escalated as P0)
    • test_adversarial_prompt_injection_quarantine — PASSED (QUARANTINED_INJECTION, 0 tokens leaked)
    • test_ssrf_guard_blocks_metadata_and_traversal — PASSED (blocked 169.254.169.254 and ../)

    Next Steps

    1. Run pytest -v -s in your environment to confirm all 36 checks pass locally.
    2. Set OPENAI_API_KEY or OPENROUTER_API_KEY in .env and swap MockLLMProvider for OpenAICompatibleProvider when 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_issues uses an ephemeral in-memory ChromaDB collection (pre-seeded with 8 sample tickets) and query_service_logs returns 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/onnxruntime wheel compatibility). Uses MCPServer from mcp>=2.0; if your codebase pins mcp<2, replace MCPServer with FastMCP.
    • Regex-Based Injection Detection: PromptInjectionGuard combines 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: ToolCircuitBreaker and RunBudgetTracker keep state in memory per instance rather than in a distributed store like Redis.

    How to use

    1. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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

    Terminal / Shell
    Network Access
    Read Files
    Environment Variables
    Write Files

    File Scopes

    src/**
    tests/**
    pyproject.toml

    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.

    Listed10 days ago

    What's inside

    Creator

    Amit Dwivedi

    Amit Dwivedi

    AI skills creator

    Frequently Asked Questions

    This skill provides a Python reliability layer that uses Pydantic v2 to catch validation errors and automatically feed them back to the LLM for correction, while preventing infinite loops and cascading API failures with built-in circuit breakers.

    It is designed for Python 3.10+ environments and integrates seamlessly with any agent or MCP server using the official MCP Python SDK, Pydantic v2, and FastAPI.

    You receive the complete Python source code for the TriageOrchestrator, the ToolCircuitBreaker logic, the SSRFGuard security module, and the full FastAPI chaos testing sandbox for offline validation.

    The Chaos Testing Suite allows you to simulate 503 errors, latency spikes, and malformed JSON in a local sandbox, letting you verify your agent's resilience without spending money on LLM tokens.

    Unlike prompts which are often ignored by models under high pressure, this skill enforces hard constraints in the execution code, making it physically impossible for the agent to bypass security allowlists or exceed retry budgets.

    No. The skill includes a deterministic MockLLMProvider and an ASGI-backed FastAPI chaos sandbox, so all 36 unit and end-to-end tests run 100% offline in pytest with zero API keys or external network calls. When you are ready for production, just add your OPENAI_API_KEY or OPENROUTER_API_KEY in .env and switch to OpenAICompatibleProvider.

    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.