name: convert-to-stateful
user-invocable: false
description: Convert existing WireMock stubs to be stateful using the key-value state store. Use when the user wants mock API resources to persist across requests (create, retrieve, update, delete).
argument-hint: ""
allowed-tools:
- Read(../references/*)
- mcp__wiremock__who_am_i
- mcp__wiremock__search_my_mock_apis
- mcp__wiremock__search_stub_mappings
- mcp__wiremock__import_stubs_to_mock_api
- mcp__wiremock__update_stub_mapping
- mcp__wiremock__delete_stub_mapping
- mcp__wiremock__search_request_journal
- mcp__wiremock__reset_request_journal
- mcp__wiremock__make_http_request
- mcp__wiremock__pull
- mcp__wiremock__push
- mcp__wiremock__look_up_documentation
Prerequisites
This skill requires the WireMock Cloud MCP server to be configured and running. If it is unavailable, stop and inform the user before proceeding.
Reference Documentation
Read these references before converting stubs:
- Stateful Stubbing - full guide to stateful mocking with the key-value state store, including examples
- Stub Creation Guidelines - rules for creating and importing stubs
- Response Template Authoring - guidelines for Handlebars response templates and brace collision avoidance
- Validating and Fixing Stubs - process for validating stubs and fixing errors
Instructions
The target mock API is: $ARGUMENTS
If $ARGUMENTS is empty, ask the user which mock API to convert.
- Identify the target mock API using
search_my_mock_apis. - Read the Stateful Stubbing and Response Template Authoring references.
- Pull the existing stubs using
pulland review them. - Ask the user which resource collections to make stateful (or all of them).
- Convert stubs to be stateful following the patterns in the stateful-stubbing reference:
- Add
serveEventListenerswith appropriate state operations (SET, REQUEST_VAR, DELETE, DELETE_CONTEXT) - Enable response templating with
"transformers": ["response-template"] - Create 404 not-found stubs with
require-stateand"absent": true - Use
jsonMergefor creating and updating resources
- Add
- Import the new stateful stubs and delete the old non-stateful versions.
- Validate using the process in Validating and Fixing Stubs.
- Smoke test by creating and retrieving a resource to confirm the stateful flow works.