MCP Tools Reference
MockServer's MCP server exposes a comprehensive set of tools that AI assistants can use to interact with MockServer. Tools are divided into high-level tools (simplified parameters for common tasks) and low-level tools (full JSON passthrough for advanced use cases).
Tool Overview
| Tool | Description | Level |
|---|---|---|
create_expectation | Create a mock expectation | High |
verify_request | Verify a request was received N times | High |
verify_request_sequence | Verify requests were received in order | High |
retrieve_recorded_requests | Get recorded requests | High |
retrieve_request_responses | Get request-response pairs | High |
clear_expectations | Clear matching expectations and/or logs | High |
reset | Reset all MockServer state | High |
get_status | Server status and ports | High |
create_forward_expectation | Create a forwarding proxy expectation | High |
debug_request_mismatch | Diagnose why a request did not match | High |
stop_server | Stop the MockServer instance | High |
create_expectation_from_openapi | Generate expectations from an OpenAPI spec | High |
raw_expectation | Full expectation JSON passthrough | Low |
raw_retrieve | Full retrieve with correlation ID filtering | Low |
raw_verify | Full verification JSON | Low |
High-Level Tools
create_expectation
Create a mock expectation that matches incoming requests and returns a specified response.
| Parameter | Type | Required | Description |
|---|---|---|---|
method | string | Yes | HTTP method to match (GET, POST, PUT, DELETE, etc.) |
path | string | Yes | URL path to match (e.g. /api/users) |
statusCode | integer | No | HTTP status code to return. Defaults to 200. |
responseBody | string or object | No | Response body to return. Strings are sent as-is; objects are serialised as JSON. |
responseHeaders | object | No | Response headers as key-value pairs |
times | integer | No | Number of times the expectation should be used. Defaults to unlimited. |
timeToLive | string | No | How long the expectation remains active, in format <number> <UNIT> (e.g. "60 SECONDS"). Defaults to unlimited. |
Example request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "create_expectation",
"arguments": {
"method": "GET",
"path": "/api/users",
"statusCode": 200,
"responseBody": "{\"users\": [{\"id\": 1, \"name\": \"Alice\"}]}",
"responseHeaders": {
"content-type": "application/json"
}
}
}
}
Example response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [
{
"type": "text",
"text": "{\"status\":\"created\",\"count\":1}"
}
],
"isError": false
}
}
verify_request
Verify that a specific request was received by MockServer a certain number of times.
| Parameter | Type | Required | Description |
|---|---|---|---|
method | string | No | HTTP method to match |
path | string | Yes | URL path to match |
atLeast | integer | No | Minimum number of times the request must have been received |
atMost | integer | No | Maximum number of times the request must have been received |
Example request:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "verify_request",
"arguments": {
"method": "POST",
"path": "/api/orders",
"atLeast": 1,
"atMost": 3
}
}
}
Example response:
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"content": [
{
"type": "text",
"text": "Verification passed"
}
],
"isError": false
}
}
verify_request_sequence
Verify that a sequence of requests was received in the specified order.
| Parameter | Type | Required | Description |
|---|---|---|---|
requests | array | Yes | Ordered array of request matchers, each with optional method and path fields |
Example request:
{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "verify_request_sequence",
"arguments": {
"requests": [
{ "method": "POST", "path": "/api/login" },
{ "method": "GET", "path": "/api/profile" },
{ "method": "POST", "path": "/api/logout" }
]
}
}
}
retrieve_recorded_requests
Retrieve requests that have been recorded by MockServer.
| Parameter | Type | Required | Description |
|---|---|---|---|
method | string | No | Filter by HTTP method |
path | string | No | Filter by URL path |
limit | integer | No | Maximum number of requests to return |
Example request:
{
"jsonrpc": "2.0",
"id": 4,
"method": "tools/call",
"params": {
"name": "retrieve_recorded_requests",
"arguments": {
"path": "/api/payments",
"limit": 10
}
}
}
Example response:
{
"jsonrpc": "2.0",
"id": 4,
"result": {
"content": [
{
"type": "text",
"text": "[{\"method\": \"POST\", \"path\": \"/api/payments\", \"headers\": {\"content-type\": [\"application/json\"]}, \"body\": {\"amount\": 99.99}}]"
}
],
"isError": false
}
}
retrieve_request_responses
Retrieve request-response pairs recorded by MockServer, useful for understanding the full HTTP conversation.
| Parameter | Type | Required | Description |
|---|---|---|---|
method | string | No | Filter by HTTP method |
path | string | No | Filter by URL path |
limit | integer | No | Maximum number of pairs to return |
Example request:
{
"jsonrpc": "2.0",
"id": 5,
"method": "tools/call",
"params": {
"name": "retrieve_request_responses",
"arguments": {
"path": "/api/users",
"limit": 5
}
}
}
clear_expectations
Clear expectations and/or recorded requests and logs that match the specified request matcher.
| Parameter | Type | Required | Description |
|---|---|---|---|
method | string | No | HTTP method to match |
path | string | No | URL path to match |
type | string | No | What to clear: ALL, LOG, or EXPECTATIONS. Defaults to ALL. |
Example request:
{
"jsonrpc": "2.0",
"id": 6,
"method": "tools/call",
"params": {
"name": "clear_expectations",
"arguments": {
"path": "/api/users",
"type": "EXPECTATIONS"
}
}
}
reset
Reset MockServer by clearing all expectations, recorded requests, and logs. This tool takes no parameters.
Example request:
{
"jsonrpc": "2.0",
"id": 7,
"method": "tools/call",
"params": {
"name": "reset",
"arguments": {}
}
}
get_status
Retrieve the status of MockServer, including which ports it is listening on. This tool takes no parameters.
Example request:
{
"jsonrpc": "2.0",
"id": 8,
"method": "tools/call",
"params": {
"name": "get_status",
"arguments": {}
}
}
Example response:
{
"jsonrpc": "2.0",
"id": 8,
"result": {
"content": [
{
"type": "text",
"text": "{\"ports\": [1080]}"
}
],
"isError": false
}
}
create_forward_expectation
Create a forwarding proxy expectation that forwards matching requests to a destination host.
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | Yes | URL path to match for forwarding |
host | string | Yes | Destination host to forward to |
port | integer | No | Destination port. Defaults to 443. |
scheme | string | No | Protocol scheme: HTTP or HTTPS. Defaults to HTTPS. |
Example request:
{
"jsonrpc": "2.0",
"id": 9,
"method": "tools/call",
"params": {
"name": "create_forward_expectation",
"arguments": {
"path": "/api/.*",
"host": "api.example.com",
"port": 443,
"scheme": "HTTPS"
}
}
}
debug_request_mismatch
Diagnose why a request did not match any expectation. This tool compares the provided request details against active expectations and returns detailed mismatch information.
Note: This functionality is also available as a REST API endpoint (PUT /mockserver/debugMismatch) and via the Java client (mockServerClient.debugMismatch(request)). See Troubleshooting Matching for details.
| Parameter | Type | Required | Description |
|---|---|---|---|
method | string | No | HTTP method of the failing request |
path | string | Yes | URL path of the failing request |
headers | object | No | Headers of the failing request |
body | string | No | Body of the failing request |
Example request:
{
"jsonrpc": "2.0",
"id": 10,
"method": "tools/call",
"params": {
"name": "debug_request_mismatch",
"arguments": {
"method": "POST",
"path": "/api/users",
"headers": {
"content-type": "application/xml"
},
"body": "<user><name>Alice</name></user>"
}
}
}
stop_server
Stop the MockServer instance. This tool takes no parameters. Use with caution as the server will shut down immediately.
Example request:
{
"jsonrpc": "2.0",
"id": 15,
"method": "tools/call",
"params": {
"name": "stop_server",
"arguments": {}
}
}
create_expectation_from_openapi
Generate mock expectations from an OpenAPI v3 specification. MockServer will create one expectation per operation in the specification, using example responses where available.
| Parameter | Type | Required | Description |
|---|---|---|---|
specUrlOrPayload | string | Yes | URL, file path, or inline OpenAPI specification (JSON or YAML) |
operationsAndResponses | object | No | Map of operationId to status code to control which operations and responses are mocked |
Example request:
{
"jsonrpc": "2.0",
"id": 11,
"method": "tools/call",
"params": {
"name": "create_expectation_from_openapi",
"arguments": {
"specUrlOrPayload": "https://petstore3.swagger.io/api/v3/openapi.json",
"operationsAndResponses": {
"findPetsByStatus": "200",
"getPetById": "200"
}
}
}
}
Low-Level Tools
Low-level tools accept the full MockServer JSON format, giving you complete control over all options. Use these when the high-level tools do not expose a parameter you need.
raw_expectation
Create an expectation using the full MockServer expectation JSON format. This is a passthrough to the PUT /mockserver/expectation REST API.
| Parameter | Type | Required | Description |
|---|---|---|---|
expectation | object | Yes | Full expectation JSON as defined in the REST API specification |
Example request:
{
"jsonrpc": "2.0",
"id": 12,
"method": "tools/call",
"params": {
"name": "raw_expectation",
"arguments": {
"expectation": {
"httpRequest": {
"method": "GET",
"path": "/api/users",
"queryStringParameters": {
"page": ["1"],
"limit": ["10"]
}
},
"httpResponse": {
"statusCode": 200,
"headers": {
"content-type": ["application/json"]
},
"body": "{\"users\": [], \"total\": 0}"
},
"times": {
"remainingTimes": 5,
"unlimited": false
}
}
}
}
}
raw_retrieve
Retrieve recorded data using the full MockServer retrieve JSON format. This is a passthrough to the PUT /mockserver/retrieve REST API.
| Parameter | Type | Required | Description |
|---|---|---|---|
requestDefinition | object | No | Request matcher JSON to filter results |
type | string | No | Type of data to retrieve: REQUESTS, REQUEST_RESPONSES, RECORDED_EXPECTATIONS, ACTIVE_EXPECTATIONS, or LOGS |
format | string | No | Response format: JSON, JAVA, or LOG_ENTRIES |
correlationId | string | No | Filter log entries by correlation ID (only applies when type is LOGS). Each incoming request is assigned a unique correlation ID that links all log entries for that request's lifecycle. |
Example request:
{
"jsonrpc": "2.0",
"id": 13,
"method": "tools/call",
"params": {
"name": "raw_retrieve",
"arguments": {
"requestDefinition": {
"path": "/api/.*",
"method": "POST"
},
"type": "REQUEST_RESPONSES",
"format": "JSON"
}
}
}
raw_verify
Verify requests using the full MockServer verification JSON format. This is a passthrough to the PUT /mockserver/verify REST API.
| Parameter | Type | Required | Description |
|---|---|---|---|
verification | object | Yes | Full verification JSON as defined in the REST API specification |
Example request:
{
"jsonrpc": "2.0",
"id": 14,
"method": "tools/call",
"params": {
"name": "raw_verify",
"arguments": {
"verification": {
"httpRequest": {
"method": "POST",
"path": "/api/orders",
"body": {
"type": "JSON_SCHEMA",
"jsonSchema": "{\"type\": \"object\", \"required\": [\"orderId\"]}"
}
},
"times": {
"atLeast": 1,
"atMost": 5
}
}
}
}
}
MCP Resources
In addition to tools, MockServer's MCP server exposes resources that AI assistants can read for context. Resources provide real-time visibility into MockServer's current state.
| Resource URI | Description |
|---|---|
mockserver://expectations | All currently active expectations configured on the server |
mockserver://requests | All recorded requests received by MockServer |
mockserver://logs | Server logs including request matching, expectation creation, and errors |
mockserver://configuration | Current MockServer configuration properties |
Resources are read-only and are updated in real time. AI assistants can use these to understand the current state of MockServer before taking actions. For example, an assistant might read mockserver://expectations to see what mocks are already configured before creating a new one.