# Automate MCP server testing using Pytest and Testcontainers

## In this learning path

- [Introduction](https://learn.arm.com/learning-paths/cross-platform/automate-mcp-with-testcontainers/)
- [Introduction to MCP server testing](https://learn.arm.com/learning-paths/cross-platform/automate-mcp-with-testcontainers/introduction/)
- [Set up your testing environment](https://learn.arm.com/learning-paths/cross-platform/automate-mcp-with-testcontainers/setup-environment/)
- [Run a basic Testcontainers example](https://learn.arm.com/learning-paths/cross-platform/automate-mcp-with-testcontainers/run-testcontainers-example/)
- [Write integration tests for MCP servers](https://learn.arm.com/learning-paths/cross-platform/automate-mcp-with-testcontainers/write-test-cases/)
- [Configure GitHub Actions for CI/CD](https://learn.arm.com/learning-paths/cross-platform/automate-mcp-with-testcontainers/github-actions-ci/)
- [Next Steps](https://learn.arm.com/learning-paths/cross-platform/automate-mcp-with-testcontainers/_next-steps/)

## About this Learning Path

| Skill level:           | Introductory        |
|------------------------|---------------------|
| Reading time:          | 1 hr                |
| Last updated:          | 02 Jul 2026         |

| Author:                | Neethu Elizabeth Simon |
|------------------------|---------------------|
| Arm IP:                | [Neoverse](https://support.arm.com/?tab=compute-ip&Product%20Type=Infrastructure%20Processors), [Cortex-A](https://support.arm.com/?tab=compute-ip&Product%20Type=Application%20Processors) |
| Tags:                  | [CI-CD](https://learn.arm.com/tag/ci-cd), [Linux](https://learn.arm.com/tag/linux), [macOS](https://learn.arm.com/tag/macos), [Windows](https://learn.arm.com/tag/windows), [Python](https://learn.arm.com/tag/python), [Pytest](https://learn.arm.com/tag/pytest), [Docker](https://learn.arm.com/tag/docker), [GitHub Actions](https://learn.arm.com/tag/github-actions), [Testcontainers](https://learn.arm.com/tag/testcontainers), [MCP](https://learn.arm.com/tag/mcp) |

### Who is this for?
This is an introductory topic for software developers and QA engineers who want to automate integration testing of Model Context Protocol (MCP) servers using Testcontainers and PyTest.

### What will you learn?
Upon completion of this Learning Path, you will be able to:
- Set up Testcontainers with PyTest for containerized testing of MCP servers
- Write and run integration tests that validate MCP server functionality
- Configure GitHub Actions to automate MCP server testing in CI/CD pipelines

### Prerequisites
Before starting, you will need the following:
- A computer with [Docker](https://learn.arm.com/install-guides/docker/) and Python 3.11 or later installed
- Basic familiarity with Python, PyTest, and container concepts
- Familiarity with the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) specification

### Summary
You’ll automate integration testing of Model Context Protocol (MCP) servers using PyTest and Testcontainers. First, you’ll prepare a Python and Docker environment, verify Docker availability, and run a short Testcontainers example to start a disposable container and execute commands inside it. Then, you’ll build a minimal integration test suite for the Arm MCP server, focusing on JSON-RPC 2.0 communication over standard input and output. Finally, you’ll add a GitHub Actions workflow to run the tests on every push and pull request using native arm64 runners with Docker. By the end, you’ll have containerized tests that validate MCP server behavior locally and in continuous integration.

### Frequently asked questions

<details>
<summary>How do I know Docker is ready before running the examples?</summary>
Run `docker info` and confirm it returns configuration details without errors. If it fails, start the Docker daemon and retry.
</details>

<details>
<summary>What should I expect when I run the basic Testcontainers example?</summary>
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.
</details>

<details>
<summary>How do the integration tests communicate with an MCP server?</summary>
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.
</details>

<details>
<summary>Where can I find a complete reference implementation of the tests?</summary>
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.
</details>

<details>
<summary>Which events should trigger the GitHub Actions workflow, and where is it defined?</summary>
The workflow runs on `push` and `pull_request` and is defined at `.github/workflows/integration-tests.yml`. GitHub’s native Arm64 runners include Docker.
</details>
