mock-server/mockserver-monorepo

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.

MockServer – a versatile mock, proxy and chaos‑engineering server

What it is – MockServer is a self‑contained HTTP(S) server that can also act as a proxy. It lets you define expectations (rules) for incoming requests and return whatever responses you need, without having the real downstream service running. It can also record real traffic, let you edit it on‑the‑fly, and deliberately inject failures (latency, dropped connections, error codes) to test how resilient your application is.

Why it matters for AI/ML projects – Modern AI services (LLM chat‑completion APIs, vector‑store back‑ends, data‑pipeline endpoints, etc.) are usually accessed over HTTP/gRPC. During development you often need a stable, controllable stand‑in for those external services, especially when:

  • The real service is rate‑limited, costly, or not yet deployed.
  • You want to test error handling, time‑outs, or malformed responses.
  • You need to replay a recorded request/response flow for reproducible CI tests.
  • You are building an AI‑powered application that talks to OpenAI, Anthropic, Gemini, Bedrock, Azure OpenAI, Ollama, or even a custom MCP‑based coding‑assistant – MockServer can mimic those endpoints, including streaming responses.

Key capabilities (as described in the README)

Feature What you can do
Multi‑protocol support Handles HTTP/1.1, HTTPS, HTTP/2, experimental HTTP/3 (QUIC), gRPC, gRPC‑Web, WebSockets, raw TCP, JSON‑RPC, and even message‑broker protocols like Kafka and MQTT – all auto‑detected from the first bytes of the connection.
Mocking Define expectations based on method, path, query, headers, cookies, and body (JSON, XML, JSONPath, XPath, regex, OpenAPI). Return static bodies, templated responses (Velocity, Mustache, JavaScript), or invoke custom callbacks/webhooks.
Proxy & record Forward real traffic, capture requests/responses, inspect TLS‑encrypted traffic, and pause at interactive breakpoints to edit or abort a request – essentially a debugger for network traffic.
Chaos engineering Inject latency, slow or dropped connections, and error status codes to see how your system behaves under failure conditions.
LLM / AI mocking Built‑in mock endpoints for popular chat‑completion APIs (OpenAI, Anthropic, Gemini, Bedrock, Azure OpenAI, Ollama) including streaming mode, plus an MCP server for AI coding‑assistant integration.
Verification After a test run you can assert that certain requests were received, in what order, and how many times.
Live dashboard Real‑time UI at /mockserver/dashboard showing expectations, received requests and logs.
Client libraries Official clients for Java, JavaScript/Node, Python, Ruby, Go, PHP, .NET and Rust, plus JUnit, Spring and Testcontainers integrations.
Deployment options Run as a Docker container, via Homebrew (mockserver CLI), as a plain JAR/WAR, on Kubernetes with an official Helm chart, or embed the Netty‑based server directly in unit tests.

Typical workflow (60‑second quick‑start)

  1. Start the server (docker run -d -p 1080:1080 mockserver/mockserver).
  2. Create an expectation with a simple curl POST to the control‑plane endpoint /mockserver/expectation – e.g., map GET /hello to a 200 response containing “Hello World”.
  3. Call the mocked endpoint (curl http://localhost:1080/hello) and receive the configured response.

All of this can be scripted, driven from CI pipelines, or managed through UI tools like Postman, Bruno, or the community‑built React admin UI.

How you might use it in an AI development pipeline

  • Unit / integration tests for code that calls OpenAI’s /v1/chat/completions – replace the real service with a MockServer expectation that returns a deterministic JSON payload or a streaming chunk sequence.
  • Performance / resilience testing – inject a 5‑second latency on every LLM request to see how your front‑end handles slow responses.
  • Record‑and‑replay – capture real traffic from a production LLM gateway, then replay it locally for debugging.
  • Contract validation – generate expectations automatically from an OpenAPI spec of your own AI micro‑service and verify that the implementation conforms.

Installation & ecosystem

  • Dockerdocker run -d --rm -p 1080:1080 mockserver/mockserver
  • Homebrewbrew install mockserver && mockserver run --port 1080
  • Kubernetes – Helm chart mockserver/mockserver (OCI‑hosted) for clustered deployments.
  • Language clients – Maven/Gradle artifacts (mockserver-netty-no-dependencies, mockserver-client-java, etc.), NPM packages (mockserver-node, mockserver-client), PyPI (mockserver-client), RubyGems, Go modules, NuGet, and crates.io.

Project health – Actively maintained (latest version 7.6.0 released June 2026), CI via Buildkite, open issue tracker, discussion forum, and a roadmap project on GitHub. Requires Java 17+ (or the Docker image bundles the runtime).


Bottom line – MockServer is a production‑grade, protocol‑agnostic mock and proxy server that makes it easy to simulate, record, and stress‑test any HTTP‑based API, including the rapidly growing family of LLM chat‑completion services. It is a solid tool for anyone building, testing, or benchmarking AI‑enabled applications.

Related

  • Project
  • Project
  • Project
  • Project
  • Project