--- title: MockServer description: Open-source HTTP/1.1, HTTP/2, HTTP/3, HTTPS and gRPC mock server, recording proxy, and MCP server for AI assistants. Mock any API, record and replay traffic, inject chaos, set interactive breakpoints, and generate from OpenAPI. layout: default ---

MockServer

Stop testing against fragile, unavailable dependencies. Mock, record and proxy any API so your tests are fast, isolated and deterministic.

HTTP/1.1, HTTP/2, HTTP/3, HTTPS & gRPC — with a built-in MCP server so AI assistants can drive it too.

Fork MockServer on GitHub
MockServer GitHub Project  Join MockServer Slack  BuildKite Build Status
 

Getting Started

MockServer is a single, self-hosted tool that mocks and proxies the services your application depends on, so you can develop and test against realistic, controllable behaviour instead of fragile real dependencies. It is free and open-source, runs anywhere, and needs no SaaS account.

Why use MockServer?

To get started see the guide for mocking, proxying, connecting an AI assistant via MCP, or the code examples. The fastest way to try it — run MockServer with a single command:

docker run -d --rm -p 1080:1080 mockserver/mockserver
 

Your first mock in 30 seconds

Once MockServer is running, create an expectation and call it:

# 1. Create an expectation — return "Hello" for GET /hello
curl -s -X PUT http://localhost:1080/mockserver/expectation \
  -H "Content-Type: application/json" \
  -d '{
    "httpRequest":  { "method": "GET", "path": "/hello" },
    "httpResponse": { "statusCode": 200, "body": "Hello from MockServer!" }
  }'

# 2. Call the mock
curl http://localhost:1080/hello
# Hello from MockServer!

That's it. Read the Getting Started guide to learn how to match on headers, body, query parameters, and more, and how to verify what your code sent.

 

Quick links by use case

I want to… Start here
Write unit tests for a REST serviceGetting Started
Write Java / JUnit tests with TestcontainersMockServer & Testcontainers
Record and replay real trafficRecord and Replay
Generate mocks from an OpenAPI / Swagger specUsing OpenAPI
Mock a GraphQL APIGraphQL Mocking
Serve HTTPS / TLS transparentlyHTTPS & TLS
Test an AI application that calls an LLMLLM Response Mocking
Cut my LLM / inference billLLM Cost Optimisation
Inject chaos / test resilienceChaos Testing
Run a load / performance test against an APILoad Injection
Assert which requests my code sentVerification
Mock a gRPC servicegRPC Mocking
Debug live traffic with breakpointsInteractive Breakpoints & Proxying
Model multi-step API flowsStateful Scenarios
Import a Postman collection or HAR fileImporting Expectations
 

What is MockServer

One tool plays three roles for any HTTP, HTTPS or gRPC service you depend on:

Mock

Return realistic, controllable responses for any request so your tests stay fast, isolated and deterministic.

Proxy

Sit in front of a real backend to record and replay traffic, inject chaos, or pause requests at breakpoints.

Verify

Assert exactly which requests your system-under-test sent, as part of a test, on mocked or proxied traffic.

For any system you integrate with via HTTP or HTTPS MockServer can be used as:

Beyond mocking and proxying, the same MockServer instance also lets you:

It mocks far more than REST, and can build mocks from the contracts you already have:

And it is built to inspect, operate and scale:

MockServer is also AI-native: every instance ships a built-in Model Context Protocol (MCP) server at /mockserver/mcp with no extra configuration, and the documentation is published in machine-readable form for LLMs. In practice this means:

See AI & MCP Integration below for the full list of AI capabilities.

When MockServer receives a request it matches the request against active expectations that have been configured. Then, if no matches are found, it proxies the request if appropriate; otherwise a 404 is returned.

For each request received the following steps happen:

  1. find matching expectation and perform action
  2. if no matching expectation proxy request
  3. if not a proxy request return 404

An expectation defines the action that is taken, for example, a response could be returned.

MockServer supports the follow actions:

 

Chaos engineering & resilience testing

Most testing proves a system works when its dependencies behave. MockServer also lets you prove it survives when they don't. Because the same instance is already in the path of your traffic — as a mock or a proxy — it can deliberately degrade that traffic so failure modes are tested on purpose rather than discovered in production.

MockServer can inject:

Faults work for HTTP, gRPC and TCP, on both mocked and proxied traffic, and can be applied per expectation or as a global chaos experiment — including scheduled experiments with an automatic dead-man's-switch halt, and fleet-wide chaos for Kubernetes and service meshes. Live experiments can be started, watched and stopped from the dashboard.

Injecting chaos into proxied / forwarded real traffic — MockServer can sit in front of a real backend and degrade the responses it relays. HTTP-level faults reach proxied traffic through three mechanisms:

Note: the plain proxy fall-through (requests with no matching expectation) does not itself add HTTP-level chaos — HTTP faults on proxied traffic always flow through a forwarding expectation with a chaos clause or through service-scoped chaos. Connection-level faults flow through TCP chaos.

 

Proxying with MockServer

MockServer can:

MockServer supports the following proxying techniques:

 

AI & MCP Integration

MockServer is built to be AI-native. A built-in Model Context Protocol (MCP) server lets AI coding assistants drive the mock server in natural language, and an OpenAPI spec provides a fallback for tools that don't yet speak MCP. All documentation, including llms.txt, llms-full.txt, and ai.txt, is structured for retrieval and citation by LLMs.

For example, put MockServer in front of a real provider to record live traffic, then export a one-click cost-optimisation brief:

Proxy LLM traffic and export a cost-optimisation brief

The MCP endpoint requires no extra configuration — start MockServer and the AI surface is on the same port:

docker run -d --rm -p 1080:1080 mockserver/mockserver
# MCP endpoint immediately available at http://localhost:1080/mockserver/mcp
 

Why use MockServer

MockServer allows you to mock any server or service via HTTP or HTTPS, such as a REST or RPC service.

This is useful in the following scenarios:

Mocking Dependencies & Verifying Request

Given a system with service dependencies, as follows:

System In Production

MockServer could be used to mock the service dependencies, as follows:

Mocking service dependencies with MockServer

Isolating Single Service / Application

A single page application may load static resources such as HTML, CSS and JavaScript from a web server and also make AJAX calls to one or more separate services, as follows:

Single Page Application

To isolate a single AJAX service, for development or debugging, the MockServer can selectively forward specific requests to local instance of the service:

Isolating Single Service

Using MockServer as a content routing load balancer is described in more detail in the section called Isolate Single Service.

Why use MockServer as a proxy

MockServer allows you to record requests from the system-under-test, or to analyse an existing system by recording its outbound requests.

This is useful in the following scenarios:

Recording Requests & Analysing Behaviour

MockServer can record all proxied requests, as follows:

Recording service requests with MockServer Proxy

Verifying Requests

MockServer can verify proxied service requests, as follows:

Verifying service requests with MockServer Proxy

Verifying Responses

MockServer records the responses returned when it proxies requests, so a test can verify the responses received using request matchers:

Verifying service responses with MockServer Proxy

 

Developer Documentation

For detailed information about MockServer's internal architecture, infrastructure, build system, and operations, see the Contributing page, which links to comprehensive technical documentation on GitHub.