Skip to main content

Python Verification Pyramid & CI/CD Eval Gates

Test your MCP tools automatically in CI/CD before shipping—so vague docstrings and bad date schemas fail fast in pull requests.

Structure a fast Python verification pyramid from millisecond Pydantic contract tests and hermetic 2026-07-28 wire replays up to rubric-graded trajectory evaluations gated automatically in CI pull requests.

Key Terms in This Lab:Testing & Evals3-Layer Python Verification PyramidIn plain English: Calling live LLMs for every typo is slow and expensive. Layer 1 tests Pydantic rules in milliseconds; Layer 2 replays JSON-RPC in memory; Layer 3 grades real tool selection accuracy across golden prompts in CI.Analogy: Test a car part on a workbench, run a simulator dress rehearsal, then pass final crash-test inspection.On Azure Stack: pytest + in-memory MCP client + azure-ai-evaluation in GitHub Actions.Testing & Evals12-Case CI Eval GateIn plain English: A vague Python docstring causes LLMs to pick the wrong tool or accept malformed dates. Running a fixed golden suite (routing, schema, adversarial cases) ensures high-signal docstrings and >95% accuracy before merge.Analogy: A standardized driving test a car update must pass before it is allowed onto public highways.On Azure Stack: azure-ai-evaluation blocking GitHub Actions merges under 95%.Python & SchemaPydantic v2 BaseModel & FieldIn plain English: AI models sometimes pass malformed dates or missing IDs. Pydantic v2 lets you declare strict types, regex patterns, and length bounds (Field(pattern=..., min_length=...)) so bad inputs are caught immediately.Analogy: A strict bouncer with a checklist at the door—if the ID format fails, it never reaches the database.On Azure Stack: Validates Course/Student payloads on ACA before touching Azure Database for PostgreSQL.Security & FERPAFERPA PII RedactionIn plain English: The U.S. FERPA law protects student education records. Outbound middleware scans database results and telemetry spans, replacing SSNs and emails with safe tokens like [REDACTED_SSN] before serialization.Analogy: Blacking out private names and SSNs with a marker before handing a report to an outside reviewer.On Azure Stack: Microsoft Presidio + Azure AI Language PII detection.
Microsoft Azure Stack:
Microsoft agent-framework + Azure AI FoundryAzure Monitor Application Insights
Details
Agent Orchestrator SDK
Microsoft agent-framework + Azure AI Foundry

Typed Python agent orchestration binding FastMCP 4 and mcp v2 tool contracts.

GCP equivalent: Google ADK
OpenTelemetry Backend
Azure Monitor Application Insights

End-to-end W3C traceparent correlation across APIM, FastMCP workers, and Postgres queries.

GCP equivalent: Google Cloud Trace
Concept Escalator

1. Visual Analogy · Unit Bench Test → Dress Rehearsal → Automated Safety Inspection Gate

Intuition First
Start Here · Plain-English Concept Brief
~4 min

How do we stop a one-line docstring edit from silently breaking AI tool selection in production?

In traditional software, a comment or docstring never changes behavior. In MCP, your Python docstring IS the instruction manual the AI reads to choose a tool! Testing only Python syntax misses routing mistakes, so teams use a 3-layer pyramid ending in automated CI eval gates.

How this fits: This is Piece 5 (Evals). Before promoting your container to production traffic, automated eval gates in GitHub Actions or Cloud Build verify routing and safety.

  • Layer 1 (Unit) checks Pydantic rules in milliseconds; Layer 2 (Harness) replays wire frames in memory.
  • Layer 3 (12-Case CI Gate) runs azure-ai-evaluation or Vertex Gen AI Eval across routing, schema, and adversarial prompts.
  • Explicit negative routing hints ("Do NOT use for student grades or FERPA PII") prevent dangerous misroutes.

You verify every component on a bench (pytest + Pydantic), run an in-memory dress rehearsal against your FastMCP server, and finally pass an automated 12-case CI safety inspection gate (azure-ai-evaluation or Vertex Gen AI Eval) before any pull request ships to districts.

Engineering Takeaway: Explicit docstrings with negative routing hints and ISO-8601 Pydantic Field constraints push tool-selection accuracy and adversarial resistance past 95%.
Quick Concept Check (Optional)

Why did the "Vague Docstring" preset fail adversarial and negative-routing test cases?

Step 1 of 3 ready? Move on to see how the pieces connect visually.

Engineering Scratchpad

Auto-saved per lab in mcp_foundry_v1_scratchpads

0 chars saved