# Skill Contract

**Skill ID:** product_search
**Version:** v1
**Status:** APPROVED

---

## Intent
Search for products by a user-provided term, display their details in a tabular format, and present them as a product list, removing currency symbols from prices if present. The output will be framed as a shopping cart list.

---

## Inputs
- product_search_term (string)

---

## Outputs
- productID (string)
- productName (string)
- productDescription (string)

---

## Output Message
The Following is Your Shopping Cart followed by the product list table.

---

## Logic
1. Extract the `product_search_term` from the user's input.
2. Call the `search_product` MCP tool, passing the extracted `product_search_term` as the `proname` argument.
3. Check the response from the `search_product` tool.
4. If the tool returns a 404 error, or if the `error.status` in the response is true, or if the `data` array is empty, respond with "no product related to '{product_search_term}' found".
5. If the tool returns any other error (e.g., connection issue, API error), provide an appropriate error message to the user.
6. If successful, parse the `data` from the `search_product` tool's response. For each product found, identify `productID`, `productName`, `productDescription`, and any `productPrice` values.
7. For any identified `productPrice` values, remove the '$' currency symbol. Ensure `productID` values preserve any leading zeros from the source data.
8. Format the output message by iterating through the found products and displaying their ID, name, description, and processed price in a tabular format, presented as "The Following is Your Shopping Cart followed by the product list table."

---

## Additional Logic
The input mode for collecting parameters should be 'chat' to allow for conversational extraction of the product search term. Remove the '$' currency symbol from all price values in the output. The output message should be updated to 'The Following is Your Shopping Cart' followed by the product list table. Preserve leading zeros in 'productID' when passed to any subsequent skill that uses it (e.g., `add_cart_item`).

---

## Side Effects
None directly on external systems; retrieves product information via the `search_product` MCP tool.

---

## Capability Summary
Allows users to search for products by name, view their details, and see them presented as a shopping cart list, with currency symbols removed from prices.

---

## Allowed Roles
- SUPERUSER

---

## Assumptions
- The `search_product` MCP tool is available and correctly configured to search the product catalog.
- Product details (ID, name, description, and potentially price) are consistently available in the `search_product` tool's response.
- Price values, if present in the tool's response, are expected to be strings containing a '$' symbol that needs removal.
- `productID` values, if they contain leading zeros, should be processed in a way that preserves these zeros for accurate identification in subsequent operations.

---

## Non-Goals
- Adding products to a cart or modifying product details within any system.
- Handling complex filtering, sorting, or advanced product catalog management beyond a simple search term.

---

## Failure Modes
- The `search_product` MCP tool returns a 404 error, an `error.status` of true, or an empty `data` array, leading to a user-friendly "no product related to '{product_search_term}' found" message.
- The `search_product` MCP tool returns a general error (e.g., service unavailable or other API errors), which should be communicated to the user.
- The response from the `search_product` tool is malformed or missing expected data fields.

---

## Data & System Access
Reads product data from the external system accessed by the `search_product` MCP tool. No direct database access or internal variable modification beyond temporary processing.

---

## Safety & Risk
Risk Level: LOW

---

## Input Mode
chat

---

## Approval

    Approved by: USER  
    Approved on: 2026-05-08T07:19:13.974589Z