Skip to main content

DDEV Add-on for MCP Server Testing with Playwright

· 4 min read
Victor Jimenez
Software Engineer & AI Agent Builder

I built a DDEV add-on that runs Playwright checks against local MCP endpoints using internal DDEV DNS names like web. This solves flaky localhost-based testing and gives one command for repeatable MCP smoke tests.

The Problem

Teams testing MCP servers locally usually mix host networking, ad-hoc scripts, and one-off commands. That breaks quickly when ports change or when tests run from a different container context.

Pain pointTypical failure
Host-only URLs (localhost)Fails inside containers where service DNS is required
Manual Playwright setup per projectInconsistent versions and missing browser deps
No MCP-specific smoke commandHealth-check regressions are discovered too late

Related context: Build: MCP Web Setup, Build: Drupal MCP Toolkit, Drupal Context MCP Integration.

The Solution

The add-on installs:

  • A dedicated mcp-playwright service via Docker Compose.
  • DDEV commands: ddev mcp-pw-smoke and ddev mcp-pw-test.
  • A Playwright smoke test for GET /health with configurable MCP_BASE_URL.

Tech Stack

ComponentTechnologyWhy
Container platformDDEV / Docker ComposeStandard local dev for CMS projects
Test runnerPlaywright v1.56.1Reliable browser automation with built-in assertions
Base imagemcr.microsoft.com/playwright:v1.56.1-nobleAll browser deps pre-installed
Service DNSDDEV internal networkingweb resolves to the app container without port hacks

Implementation

.ddev/docker-compose.mcp-playwright.yaml
services:
mcp-playwright:
image: mcr.microsoft.com/playwright:v1.56.1-noble
working_dir: /var/www/html/.ddev/mcp-playwright
Use DDEV DNS Names, Not localhost

web DNS names inside DDEV are safer than localhost for cross-container test reliability. When your test runner lives in a sidecar container, localhost points to the sidecar itself, not your app.

URL Format Bugs Are Silent

A tiny helper (resolveMcpBaseUrl) plus tests prevents subtle URL-format bugs. Trailing slashes, missing ports, and protocol mismatches fail silently and waste hours of debugging.

Full add-on file structure
.ddev/
docker-compose.mcp-playwright.yaml
commands/
host/
mcp-pw-smoke
mcp-pw-test
mcp-playwright/
package.json
playwright.config.js
tests/
mcp-health.spec.js

Why this matters for Drupal and WordPress

DDEV is the standard local development environment for Drupal projects and increasingly adopted by WordPress teams. Any Drupal or WordPress site integrating MCP-based AI tools -- content analyzers, module generators, migration assistants -- needs reliable endpoint testing before deployment. This add-on gives CMS teams a single command to verify MCP server health inside the same container stack they already use for local development, eliminating the gap between "it works on my machine" and CI-reproducible smoke tests.

What I Learned

  • web DNS names inside DDEV are safer than localhost for cross-container test reliability.
  • A tiny helper (resolveMcpBaseUrl) plus tests prevents subtle URL-format bugs.
  • Dedicated smoke commands are worth adding early when MCP endpoints are a release gate.

References


Looking for an Architect who doesn't just write code, but builds the AI systems that multiply your team's output? View my enterprise CMS case studies at victorjimenezdev.github.io or connect with me on LinkedIn.