Skip to main content
First task: inspect an order and decide whether stock can cover another request. You will create ten mugs in inventory, reserve two for an order, and check whether a new request for nine mugs can be filled. Run the checks yourself, then let an AI agent inspect the same records. This walkthrough uses @stateset/embedded 1.35.1 locally. You need Node.js 20.20.0+ and npm 10+. You do not need a hosted StateSet key. The optional agent step needs an MCP-capable host with its own model connection.
This is a local practice workflow. It creates commerce records and reserves stock in your database. It does not connect a store, charge a card, or ship goods. If your first task is customer support, use the ResponseCX quickstart; for existing business systems, start with the service directory.

1. Create a project

Use a new directory so the fixture is separate from existing commerce data:
If the native module cannot load, use the SDK installation checks.

2. Create the operational fixture

Save this as setup-operation.mjs:
Success: the program prints a real order ID and database path and saves the three handoff files. It refuses to seed an existing operations.db, so an accidental second run does not create another order. If setup fails partway through, keep the failure for diagnosis and start again in a new directory rather than assuming the partial fixture is complete.

3. Verify the result independently

Save this as inspect-operation.mjs:
Success: the assertions pass and the printed order ID matches setup. This is a second process reading the saved database, so the result does not depend on the setup program staying open. You have completed the first operational check without an AI agent. The stock conclusion is a snapshot. A real order must check and reserve stock when it is created; a previous read is not a guarantee of availability. The orders quickstart tests that rejection path.

4. Give an AI agent the same task

Open the generated mcp-config.json. Copy its stateset-commerce entry into your MCP host’s configuration, following that host’s configuration format. Merge it with any existing servers. The file already contains the absolute database path, so there is no example path to replace. Restart or reconnect the server in the host, then paste the contents of agent-task.txt into the conversation. The task includes the exact order ID created on your machine; you do not need to give the agent filesystem access to read the handoff files. The configuration selects the core profile and omits --apply. In CLI 1.35.1, write calls remain preview-only; read tools can inspect the database. The MCP setup guide explains host executable paths, profiles, and the separate trusted configuration required to enable writes.

5. Check the agent’s evidence

Run node inspect-operation.mjs again after the agent responds. Its assertions confirm that the fixture’s order count, order state, total, and stock quantities still match. They do not audit every possible record or external system; inspect the host’s tool trace as well. A plausible answer without tool calls is not a successful connection test. An empty result is not an invitation to create replacement data: compare the configured database path and order ID first.

Move from the example to your operation

Use Connect Your Operation to choose data owners, check service access, and map real IDs before replacing this fixture with business data. Choose one next outcome and the system that owns its data: For an existing business, identify the source of truth and how data reaches the selected service before replacing fixture IDs with real ones. StateSet services have separate setup and credentials; connecting one MCP server does not configure the others. Use the agent operating procedure for task handoffs and the integration test plan to verify the workflow as you expand it.

Get unblocked

Share the package version, failed step, and redacted error using the support checklist.
Last modified on September 20, 2026