Finds the active order (cart) of the MCP session, or creates one, the same way the built-in
add_to_cart tool does. Call it in a Shop tool that adds to the cart, instead of
.
ActiveOrderService.getActiveOrder(ctx, undefined, true)Set usesActiveOrder: true on the tool. The MCP plugin then gives the call a session, and the
helper reads the session from ctx. Without a session the helper throws an
IllegalOperationError. You can also call the helper from a service that the tool calls: pass
the ctx the tool received.
Call it after the checks that can refuse the call. Core writes the ID of a new order to the session cache, and a rollback does not undo that.
Example
Parameters
RequestContextInjectorArchitecture reviews, custom plugin work, migrations, ongoing support. Get a hand from the team that builds Vendure.