# RevCent MCP Guide: `SearchSales`

Brief AI/MCP-focused guide for searching RevCent Sales.

---

## Operation Summary

Operation:

```text
SearchSales
```

Purpose:

```text
Search previously created Sales using a search term.
```

Use `SearchSales` when the exact Sale ID is unknown and the user provides a search term such as customer email, customer name, phone, order/internal ID, address, status, metadata value, product/order context, or another searchable phrase.

---

## Related Links

| Guide | Link |
|---|---|
| Sale Overview | `https://revcent.com/documentation/markdown/mcp/operation/OverviewSale.md` |
| GetSale | `https://revcent.com/documentation/markdown/mcp/operation/GetSale.md` |
| GetSales | `https://revcent.com/documentation/markdown/mcp/operation/GetSales.md` |
| Product Sale Overview | `https://revcent.com/documentation/markdown/mcp/operation/OverviewProductSale.md` |
| Transaction Overview | `https://revcent.com/documentation/markdown/mcp/operation/OverviewTransaction.md` |
| Shipping Overview | `https://revcent.com/documentation/markdown/mcp/operation/OverviewShipping.md` |
| Tax Overview | `https://revcent.com/documentation/markdown/mcp/operation/OverviewTax.md` |
| Subscription Overview | `https://revcent.com/documentation/markdown/mcp/operation/OverviewSubscription.md` |
| Trial Overview | `https://revcent.com/documentation/markdown/mcp/operation/OverviewTrial.md` |
| BigQueryRunQuery | `https://revcent.com/documentation/markdown/mcp/operation/BigQueryRunQuery.md` |

---

## When to Use

Use `SearchSales` for targeted lookup when the Sale ID is unknown.

Good search terms:

- customer email,
- customer name,
- customer phone,
- order/internal ID,
- third-party shop order ID,
- address,
- Sale status,
- product name/SKU where indexed,
- metadata value,
- external/customer/internal identifier.

After finding a likely match:

```text
SearchSales
    ↓
Review result/highlights/score
    ↓
GetSale
    ↓
Confirm exact Sale before action
```

---

## Input Schema

Required:

| Field | Type | Description |
|---|---:|---|
| `search_term` | string | Single search term or phrase used by the full-text search engine. |

Example:

```json
{
  "search_term": "customer@example.com"
}
```

---

## Output Summary

Search results can include:

| Field | Meaning |
|---|---|
| `item_type` | Usually `sale`. |
| `id` | 20-character Sale ID. |
| `created_date_unix` | Sale creation timestamp. |
| `first_name` / `last_name` | Customer name when returned. |
| `email` | Customer email when returned. |
| `phone` | Customer phone when returned. |
| `internal_id` | Internal/order ID when returned. |
| `status` | Sale status when returned. |
| `metadata` | Metadata name/value pairs. |
| `url` | Direct RevCent details URL. |
| `highlights` | Fields and values matched by the search. |
| `score` | Search score. Higher means a better match. |

---

## Search Safety Rule

Search results are possible matches.

They are not enough to perform consequential actions.

Before voiding, refunding, editing related shipment details, processing recovery, or discussing sensitive Sale context:

```text
SearchSales
    ↓
Select likely result
    ↓
GetSale
    ↓
Confirm customer, Sale status, amount, payment, and related records
    ↓
Only then take action if appropriate
```

Do not void, refund, or take lifecycle actions directly from a search result.

---

## Customer-Facing AI Verification Warning

This operation can help locate sensitive customer, order, sale, payment, shipping, tax, subscription, trial, refund, fraud, or lifecycle context.

If this operation is used inside a customer-facing AI flow, such as:

- AI Voice Agent,
- public chatbot,
- support chatbot,
- customer portal assistant,
- SMS assistant,
- any visitor-facing AI workflow,

the AI/MCP client should verify the visitor is actually related to the resulting Sale before providing details or taking action.

Recommended rule:

```text
Do not provide Sale details to a public-facing visitor based only on the search input they supplied.
```

Search inputs can be guessed, mistyped, shared, or discovered. A search result is only a possible match, not proof that the visitor is authorized.

Safe customer-facing flow:

```text
Visitor provides search input
    ↓
AI runs SearchSales
    ↓
AI selects likely result
    ↓
AI runs GetSale for the selected Sale
    ↓
AI verifies the visitor against a secondary value from the GetSale response
    ↓
Only after verification:
        provide limited appropriate details
        or take an allowed action
```

Recommended secondary verification values:

| Search Input | Secondary Verification Value |
|---|---|
| Customer name | Customer email or phone from `GetSale`. |
| Customer email | Secondary phone, order-related value, or another record-backed verification value where available. |
| Phone number | Customer email from `GetSale`. |
| Order/internal ID | Customer email or phone from the retrieved Sale. |
| Metadata/external ID | Customer email or phone from the retrieved Sale. |
| Sale ID | Customer email from the retrieved Sale. |

Important:

```text
The secondary verification value should come from the retrieved RevCent record, not only from the visitor's original search input.
```

For example, if the visitor searches by name, order ID, or metadata value, do not reveal matching Sale details until they verify a customer email or another secondary value returned by `GetSale`.

Do not disclose sensitive details such as:

- payment details beyond what is appropriate for customer support,
- transaction/gateway internals,
- full shipment address,
- fraud/risk logic,
- unrelated subscription/trial/customer details,
- internal notes not meant for customers,
- other related records unless the visitor is verified and authorized.

For consequential actions, such as voiding a Sale, refunding Product Sales, refunding shipping/tax, processing pending recovery, changing subscriptions, or editing shipment information, require explicit confirmation and follow the relevant operation-specific safety guidance.


---

## Critical Reporting Rule

This Sale lookup/search operation is **not** a reporting tool.

Do not use this operation for:

- counting,
- aggregations,
- metrics,
- reporting,
- data mining,
- bulk retrieval,
- broad analysis,
- document property searches,
- sales revenue reports,
- conversion reports,
- campaign performance reports,
- shop performance reports,
- product performance reports,
- refund reports,
- payment-attempt reports,
- tax/shipping/subscription/trial lifecycle reports.

Use:

```text
BigQueryRunQuery
```

for those purposes.

Important AI/MCP behavior:

```text
If the AI/MCP client intended to use this operation for reporting, metrics, aggregation, or data mining and then realizes BigQueryRunQuery is the correct operation, it does not need to tell the user about the correction.

It should simply use BigQueryRunQuery instead.
```

The user does not need an explanation that the AI almost used the wrong operation. The correct behavior is to quietly choose the correct operation.


---

## Correct Use vs Incorrect Use

| User Intent | Correct Action |
|---|---|
| “Find the Sale for this customer email.” | Use `SearchSales`, then `GetSale`. |
| “Find this order/internal ID.” | Use `SearchSales`, then verify with `GetSale`. |
| “Search for this metadata value.” | Use `SearchSales`, then verify with `GetSale`. |
| “How many Sales mention X?” | Use `BigQueryRunQuery`, not `SearchSales`. |
| “Analyze Sales by metadata value.” | Use `BigQueryRunQuery`, not `SearchSales`. |
| “Find revenue by customer source.” | Use `BigQueryRunQuery`, not `SearchSales`. |

---

## Example: Correct Lookup Flow

```text
User: Find the Sale for customer@example.com.
```

Correct:

```text
1. SearchSales with search_term = "customer@example.com".
2. Review results.
3. GetSale for the correct result ID.
4. Summarize the exact Sale.
```

---

## Example: Incorrect Reporting Flow

```text
User: Search all Sales with utm_source=google and tell me revenue.
```

Incorrect:

```text
Use SearchSales repeatedly and aggregate results manually.
```

Correct:

```text
Use BigQueryRunQuery.
```

AI/MCP should simply run `BigQueryRunQuery` without telling the user it changed plans.

---

## Best Practices

1. Use specific search terms.
2. Prefer customer email, phone, order/internal ID, or unique metadata values over broad names.
3. Review `highlights` and `score`.
4. Use `GetSale` after selecting a result.
5. Do not use search results alone for Sale lifecycle actions.
6. Do not use search for reporting or data mining.
7. Verify customer identity with a secondary value from `GetSale` before sharing details in customer-facing AI flows.
8. Use `BigQueryRunQuery` for metrics and analysis.

---

## Final AI/MCP Instruction

Use `SearchSales` only for targeted full-text lookup of Sales when the exact Sale ID is unknown.

In customer-facing AI flows, search results are not proof of authorization. After finding a likely match, use `GetSale` and verify the visitor with a secondary value from the retrieved record, such as `customer.email`, before providing details or taking action.

Do not use it for reporting, metrics, aggregation, counting, broad analysis, or data mining. If the user's intent is analytical, silently use `BigQueryRunQuery` instead.


---
Document Parent Directory
* [Operations](https://revcent.com/documentation/markdown/mcp/operation/index.md) - AI/MCP details and overviews for operations available within the RevCent MCP.