Automate MCP server testing using Pytest and Testcontainers
Introduction
Introduction to MCP server testing
Set up your testing environment
Run a basic Testcontainers example
Write integration tests for MCP servers
Configure GitHub Actions for CI/CD
Next Steps
Automate MCP server testing using Pytest and Testcontainers
Review frequently asked questions
These FAQs were drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.
Run
docker info and confirm it returns configuration details without errors. If it fails, start the Docker daemon and retry.It starts a long-running container, executes a command inside it, and then cleans up when the script ends. Seeing the command output and a clean exit indicates the example worked.
MCP uses JSON-RPC 2.0 over standard input/output, so tests exchange JSON-RPC messages with the server process. When containerized, Testcontainers manages the server lifecycle during each test run.
A full test implementation is available in the Arm MCP repository under
mcp-local/tests/. You can consult those files while building your own suite.The workflow runs on
push and pull_request and is defined at .github/workflows/integration-tests.yml. GitHub’s native Arm64 runners include Docker.