Mockserver

com.mock-server由 mock-server.com 发布v9.4.0更新于 Nov 20, 2026

Mock, record/replay, verify and chaos-test any HTTP, REST, gRPC or LLM dependency over MCP.

已验证STDIO仅桌面开发者工具安全与监控

概览

AI 生成的概览

MockServer 内置的 MCP 服务器让助手为 HTTP、gRPC 和 LLM 依赖创建模拟、录制回放流量、校验请求并注入故障。

可以做什么
  • 创建和管理期望,返回固定、模板化或回调响应,覆盖 HTTP、gRPC 等协议
  • 作为代理运行,录制、查看并修改真实流量,包括 TLS 加密的交互
  • 校验预期请求是否到达,并查看已记录的请求历史
  • 注入延迟、连接中断和错误,对应用做混沌测试
  • 模拟 OpenAI、Anthropic、Gemini、Bedrock、Azure OpenAI 和 Ollama 的对话补全接口,含流式响应
  • 从 OpenAPI/Swagger 规范生成期望,并通过 REST 控制面统一操作
适用场景
适合在开发或测试调用外部 HTTP、gRPC 或 LLM 服务的代码时使用,用可控的确定性响应替代真实依赖,或先录制真实流量再回放。
运行要求
需要一个可通过 streamable HTTP 访问的运行中 MockServer 实例,通常是监听 1080 端口的 Docker 镜像;MCP 端点位于 /mockserver/mcp。非容器自托管安装需要 Java 17+(Docker 镜像自带 JVM)。未声明认证方式或环境变量。
安装前请注意
文档明确说明 MockServer 仅用于开发和测试,不适用于生产环境。它能代理并查看流量(包括 TLS 加密交互)并实时修改请求,因此只应指向测试系统和测试数据。创建期望和代理设置会改变服务器状态,且声明的配置没有认证,不要将端口暴露到公网。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Mockserver,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

MockServer            [Build status] [OpenSSF Best Practices] [GitHub license] [GitHub stars] [Artifact Hub] [MCP Toplist]

MockServer mocks, records, and chaos-tests any HTTP(S) dependency your application talks to — one binary, no per-protocol setup.

Why MockServer

  • One port, every protocol — HTTP/1.1, HTTPS, HTTP/2, gRPC & gRPC-Web, WebSockets and raw TCP are auto-detected from the first bytes of each connection. Beyond that: HTTP/3 (QUIC, experimental), JSON-RPC for MCP/A2A mocking, and AsyncAPI-driven testing against Kafka/MQTT brokers.
  • Mock, proxy, or both — return canned/templated/callback responses, or sit as a proxy (port forwarding, HTTP proxy, HTTPS tunneling, SOCKS) and record, inspect, and modify real traffic in flight, with full visibility into TLS-encrypted exchanges.
  • Chaos engineering built in — inject latency, dropped connections, and errors on demand to see how your application copes when a dependency misbehaves.
  • Mock AI too — chat-completion APIs for OpenAI, Anthropic, Gemini, Bedrock, Azure OpenAI and Ollama (including streaming), plus a built-in MCP server so AI coding assistants can drive MockServer directly.
  • Generate mocks, don't hand-write them — from an OpenAPI/Swagger spec, with request matching on method, path, query, headers, cookies, and body (JSON, XML, JSONPath, XPath, regex).
  • Fits your stack — Java, JavaScript/Node, Python, Ruby, Go, .NET, Rust, and PHP clients, plus JUnit and Spring support; runs as Docker, Helm/Kubernetes, a JAR, or a WAR, with a live dashboard and optional clustered state for multi-instance deployments.

See the changelog for what shipped in each version.

Getting started in 60 seconds

Run MockServer with Docker, then mock an endpoint and call it:

# 1. Start MockServer
docker run -d --rm -p 1080:1080 mockserver/mockserver

# 2. Mock an endpoint: GET /hello -> 200 "Hello World"
#    (MockServer exposes a REST control plane on the same port)
curl -X PUT http://localhost:1080/mockserver/expectation \
  -H 'Content-Type: application/json' \
  -d '{
        "httpRequest":  { "method": "GET", "path": "/hello" },
        "httpResponse": { "statusCode": 200, "body": "Hello World" }
      }'

# 3. Call your mock
curl http://localhost:1080/hello
# -> Hello World

…or, on macOS / Linux, install with Homebrew and run the mockserver command directly:

brew install mockserver
mockserver run --port 1080

For every way to run MockServer — Docker, docker-compose recipes, the mockserver CLI, a JVM-less binary bundle, Helm/Kubernetes, the JAR, and Testcontainers — see the Self-Hosting MockServer guide. The same setup can be driven from any client library or the dashboard at http://localhost:1080/mockserver/dashboard.

One-command recipes

The examples/docker-compose recipes are a single docker compose up each — mock from an OpenAPI spec, a record/replay proxy, a contract-validating proxy, or a chaos proxy:

cd examples/docker-compose/mock-from-openapi
docker compose up
curl http://localhost:1080/pets

Drive it from Postman or Bruno

[Run in Postman]

Install

ChannelCommand
Dockerdocker run -d --rm -p 1080:1080 mockserver/mockserver
Docker from GitHub Container Registry (avoids Docker Hub's pull limit)docker run -d --rm -p 1080:1080 ghcr.io/mock-server/mockserver
Homebrew (macOS/Linux)brew install mockserver
Helm (chart guide)helm upgrade --install --namespace mockserver mockserver oci://ghcr.io/mock-server/charts/mockserver
Maven Central [mockserver]org.mock-server:mockserver-netty-no-dependencies — see all Maven artifacts (server, WARs, JUnit 4/5, Spring, Maven plugin)
npmmockserver-node (start/stop)

Client libraries (create expectations, verify requests, drive the control plane from your tests):

[Java] [Node] [PyPI] [Gem] [Go] [Packagist] [NuGet] [Crates.io]

Full install options (SNAPSHOT repository, WAR deployment, Testcontainers modules, package-manager channels) are on the Self-Hosting guide and Where to find MockServer.

Requirements

Runtime: Java 17+ (raised from Java 11 in MockServer 6.0.0 — see the Java 17 / Jakarta upgrade guide; pin to 5.15.x if you need Java 11). The official Docker image bundles its own JVM, so containerised users need no JVM of their own.

Building from source: JDK 17+.

Security note: MockServer is a development and testing tool only — see SECURITY.md.

Documentation

Versions

[Latest release]

  • What changed: changelog and GitHub releases (every version is also a git tag mockserver-<version>).
  • API docs for a version: Java API at https://mock-server.com/versions/<version>/apidocs/index.html; REST API on SwaggerHub (one spec per major.minor.x).
  • Java 11: the last Java 11-compatible release is 5.15.0 (January 2023).

6.0.0 breaking change: the <classifier>shaded</classifier> Maven form was removed. Replace mockserver-netty:<version>:shaded with mockserver-netty-no-dependencies:<version> (same shaded bytes, new coordinates).

Community & Contributing

Maintainers

来源:README.md,提交 7db1289

工具

0
SourceWeft 曾在隔离沙箱中以无凭据方式启动该软件包一次,以列出其工具,但未能完成:该软件包类型无法在沙箱中运行。

版本历史

6
  1. v9.4.0最新Nov 20, 2026
  2. v9.3.0Nov 17, 2026
  3. v9.2.0Oct 29, 2026
  4. v9.1.0Oct 21, 2026
  5. v9.0.0Oct 16, 2026
  6. v8.0.0Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分