Model or dataset
mock-server/mockserver-monorepo avatar
mock-server/mockserver-monorepo

MockServer 7.6: One Port for HTTP, gRPC, WebSockets, and Chaos Testing

MockServer is an HTTP(S) mock server and proxy for testing that lets you mock APIs, inspect and modify live traffic, and inject failures. It supports HTTP/1.1, HTTP/2, gRPC, WebSockets, TCP and more on a single port, with additional support for HTTP/3, message brokers, and AI/LLM APIs.

4,971 stars1,116 forksJavaApache-2.0

At a glance

What is it?
MockServer is a Java-based HTTP(S) mock server and proxy that auto-detects protocols from the first bytes of a connection, so a single port can handle HTTP/1.1, HTTP/2, gRPC, WebSockets, and raw TCP. It also adds chaos injection, LLM mocking, and an MCP server, making it a broad tool for testing dependencies.
Who is it for?
Adopt MockServer if you need a single tool that mocks and proxies multiple protocols, especially if your stack mixes HTTP/2, gRPC, WebSockets, or raw TCP and you want to inject failures without running several dedicated mocks. Teams that only need simple REST mocking might find the configuration overhead and the breadth of features excessive; a lighter tool like WireMock or a language-specific stub would be simpler.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository received new commits within the last day.
What is it written in?
Mainly Java, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

What MockServer Actually Solves

MockServer addresses a common testing problem: your application depends on APIs that are unavailable, incomplete, or hard to reproduce. Instead of standing up a separate stub for each protocol, MockServer acts as both a mock server and a proxy. It lets you mock the APIs you depend on, proxy real traffic to record and inspect it, and inject failures like latency and dropped connections for chaos testing. The intended users are developers and testers who need to simulate dependencies across a range of protocols, not just HTTP. The README positions it as a tool for testing how your application copes when the systems it relies on degrade or fail. That is a broader claim than most mocking tools make, and it shapes the entire design.

One Port, Auto-Detected Protocols

The core mechanism is protocol auto-detection from the first bytes of each connection. MockServer listens on a single port and figures out whether the incoming traffic is HTTP/1.1, HTTPS, HTTP/2, gRPC, gRPC-Web, WebSockets, or raw TCP. This is a significant design choice because it removes the need to configure separate ports or listeners for each protocol. The README states that no per-protocol configuration is required. For example, a gRPC client and a WebSocket client can both point to the same MockServer address, and the server routes them correctly. This is different from tools that require you to declare a protocol upfront. The trade-off is that auto-detection must be reliable; if a protocol is not in the supported list or the first bytes are ambiguous, the connection may not be handled correctly. The README also mentions experimental HTTP/3 (QUIC) support on its own UDP port, which means that protocol does not share the same auto-detected port.

Getting It Running: Docker and the Control Plane

The fastest path is Docker. The README shows a three-step process: start MockServer with `docker run -d --rm -p 1080:1080 mockserver/mockserver`, then create an expectation with a `curl` PUT to `http://localhost:1080/mockserver/expectation`, and finally call the mocked endpoint. The control plane is a REST API on the same port, which is a practical design because you do not need a separate admin port. For local development on macOS or Linux, you can install via Homebrew with `brew install mockserver` and run `mockserver run --port 1080`. The README also points to a self-hosting guide that covers a JVM-less binary bundle, Helm/Kubernetes, a JAR, and Testcontainers. There are also docker-compose recipes in the `examples/docker-compose` directory that provide one-command setups for mocking from an OpenAPI spec, a record/replay proxy, a contract-validating proxy, and a chaos proxy. That is a useful way to see real configurations without reading the full documentation.

Expectations, Templating, and Verification

MockServer's model is based on expectations: you define an `httpRequest` matcher and an `httpResponse`. The matcher can use method, path, query, headers, cookies, and body, with support for JSON, XML, JSONPath, XPath, regex, and OpenAPI. Responses can be static or dynamic. Dynamic responses are generated via templating engines like Velocity, Mustache, or JavaScript, or through class/closure callbacks and webhooks. This is more flexible than a simple static file server. Verification is also built in: you can assert which requests were received, in what order, and how many times. That is essential for contract testing. The README does not give an example of verification syntax, so you would need to consult the full documentation to see the exact API. But the presence of verification as a first-class feature distinguishes MockServer from a basic stub.

Chaos Engineering and Failure Injection

MockServer explicitly supports chaos engineering. You can inject latency, dropped connections, and errors to test how your application copes with a misbehaving dependency. This is not a side feature; it is one of the three main things the README lists. The mechanism is presumably part of the expectation model, where you can define a response that delays or closes the connection. The README does not show a concrete chaos example, so the exact syntax is not visible. But the docker-compose chaos proxy recipe suggests that you can set up a proxy that modifies live traffic in a controlled way. This is a different value proposition from pure mocking: MockServer can sit between your application and a real dependency, then alter the traffic to simulate failures. That makes it a tool for resilience testing, not just for stubbing out unavailable services.

Beyond HTTP: gRPC, WebSockets, Message Brokers, and LLMs

The README lists support for gRPC and gRPC-Web, WebSockets, raw TCP, message brokers (Kafka and MQTT via AsyncAPI), and AI/LLM APIs. The message broker support is described as "AsyncAPI-driven message-broker testing against external Kafka and MQTT brokers," which means MockServer does not run a broker itself but can mock or test interactions with an existing one. For LLM mocking, it can mock chat-completion APIs for OpenAI, Anthropic, Gemini, Bedrock, Azure OpenAI, and Ollama, including streaming. There is also a built-in MCP server at `/mockserver/mcp` for AI coding assistant integration. This is a broad scope. The risk is that each of these integrations may not be as deep as a dedicated tool. For example, if you need to test a complex Kafka consumer with specific partitioning behavior, a dedicated Kafka mock might be more appropriate. But if you want a single test environment that simulates an LLM API and a gRPC service on the same port, MockServer is one of the few tools that attempts that.

Limitations and Wrong-Tool Cases

The most obvious limitation is that HTTP/3 is experimental and runs on a separate UDP port, so it does not benefit from the single-port auto-detection. If your application relies heavily on HTTP/3, you should verify that the experimental support meets your needs. Another limitation is that the README does not provide details on performance or resource usage. Since MockServer is a Java application, it may be heavier than a lightweight Node.js or Python mock server. For simple REST mocking with a small number of endpoints, MockServer might be overkill. The expectation model is powerful but has a learning curve. The README does not show how to configure TLS termination, mutual TLS, or complex proxy rules, so you would need to consult the full documentation. Also, the project is a monorepo with many clients and integrations, which means the codebase is large and the upgrade path may require updating multiple components if you use the Java or Node client. The license is Apache-2.0, which is permissive and does not impose copyleft obligations, but you should still review the license file for any notices.

Alternatives and the Difference in Approach

A common alternative is WireMock, which is also a Java-based HTTP mock server. WireMock focuses on HTTP/HTTPS only and does not attempt to handle gRPC or WebSockets on the same port. Its approach is to be a dedicated HTTP stub with a rich matching and templating language, but you would need separate tools for other protocols. Another alternative is a protocol-specific mock, such as a dedicated gRPC mock server or a Kafka mock. Those tools are often simpler and more precise for their protocol, but they require you to run multiple processes. MockServer's difference is the auto-detection of protocols on one port and the proxy/chaos capabilities. If you need to test a system that talks to a mix of HTTP, gRPC, and WebSockets, MockServer reduces the number of moving parts. But if you only need to mock a single REST API, a tool like WireMock is likely easier to configure and lighter to run.

Editorial conclusion

Adopt MockServer if you need a single tool that mocks and proxies multiple protocols, especially if your stack mixes HTTP/2, gRPC, WebSockets, or raw TCP and you want to inject failures without running several dedicated mocks. Teams that only need simple REST mocking might find the configuration overhead and the breadth of features excessive; a lighter tool like WireMock or a language-specific stub would be simpler. Before adopting, verify that the auto-detection of protocols works for your exact traffic patterns, test the experimental HTTP/3 support on a separate UDP port, and check the changelog for breaking changes between 7.5 and 7.6. If you rely on message brokers or LLM APIs, confirm that the external Kafka/MQTT integration and the AI/LLM mocking endpoints match your expected request formats. MockServer is not a single-purpose mock; it is a multi-protocol proxy and control plane that requires you to learn its expectation model and REST API, but that investment pays off when your dependencies span many protocols.

Official sources

  1. License: Apache-2.0
  2. mock-server/mockserver-monorepo on GitHub
  3. Project website
  4. README
  5. Releases
Community notes

Community notes