# Search Unspsc Categories

`Search_Unspsc_Categories` is the GovTribe MCP dataset tool for UNSPSC taxonomy records.

## When To Use

Typical questions this tool answers well:

* Which GovTribe UNSPSC category matches this code, name, or phrase?
* What canonical category identifier should be used for downstream state/local filtering?
* Which UNSPSC categories should be included or excluded before running market segmentation?
* Which category records best represent a capability area such as data center or managed IT services?
* How can I quickly produce a small working set of UNSPSC categories for follow-on opportunity analysis?

## Required Reading

1. [Search\_Query\_Guide](https://docs.govtribe.com/user-guide/mcp/guides/search_query_guide): Required before setting free-text query strings when search\_mode is used.
2. [Search\_Mode\_Guide](https://docs.govtribe.com/user-guide/mcp/guides/search_mode_guide): Required before choosing keyword vs semantic retrieval.

## Input Contract

* `query`: Free-text query string. See Required Reading: [Search\_Query\_Guide](https://docs.govtribe.com/user-guide/mcp/guides/search_query_guide).
  * `type`: `string`
  * `required`: `no`
  * `default`: `n/a`
* `page`: 1-based page index.
  * `type`: `null|number`
  * `required`: `no`
  * `default`: `1`
* `per_page`: Rows per page.
  * `type`: `null|number`
  * `required`: `no`
  * `default`: `10`
* `search_mode`: Query interpretation mode. See Required Reading: [Search\_Mode\_Guide](https://docs.govtribe.com/user-guide/mcp/guides/search_mode_guide).
  * `type`: `string`
  * `required`: `no`
  * `default`: `keyword`
  * `options`: `keyword`, `semantic`
* `unspsc_category_ids`: Include or exclude results by UNSPSC categories. Use GovTribe IDs or UNSPSC codes.
  * `type`: `array<string>`
  * `required`: `no`
  * `default`: `n/a`
* `unspsc_category_ids_operator`: Choose whether to include or exclude values for UNSPSC Category IDs (GovTribe or UNSPSC code).
  * `type`: `null|string`
  * `required`: `no`
  * `default`: `in`
  * `options`: `in`, `not_in`
* `fields_to_return`: Optional field list for row payloads. If omitted and `per_page > 0`, rows default to `govtribe_id`. For `per_page: 0` aggregation/meta calls, this field may be omitted. Specify `fields_to_return` whenever the user asks for fields beyond `govtribe_id`, and prefer omitting it in pure aggregation workflows.
  * `type`: `array<string>`
  * `required`: `no`
  * `default`: `n/a`
  * `options`: `govtribe_id`, `govtribe_type`, `govtribe_url`, `name`, `code`, `updated_at`, `state_local_contract_opportunities`

## Output Contract

* Top-level keys:
  * `current_page`: Current page number when `per_page > 0`.
  * `data`: Array of result rows when `per_page > 0`.
  * `from`: First row position in the current page.
  * `last_page`: Last page number for current filters.
  * `path`: GovTribe search URL for this result set.
  * `per_page`: Applied page size.
  * `to`: Last row position in the current page.
  * `total`: Total matched row count for current query filters.
  * `contains`: Dataset label for the returned result set.
  * `search_results_id_can_generate_saved_search`: Saved-search eligibility flag.
  * `search_results_id`: Server-side search result identifier.
  * `view_search_results_url`: URL to open this exact result set.
* Row keys:
  * `govtribe_id`
  * `govtribe_type`
  * `govtribe_url`
  * `name`
  * `code`
  * `updated_at`
  * `state_local_contract_opportunities`
* Relationship retrieval map:
  * `state_local_contract_opportunities`
    * `resource_type`: `state_local_contract_opportunity`
    * `tool`: `Search_State_And_Local_Contract_Opportunities`
    * `filter`: `state_and_local_contract_opportunity_ids`
    * `nested_keys`: `govtribe_id`, `govtribe_type`, `govtribe_url`, `name`

## Usage Patterns

Pattern A: Resolve one UNSPSC category by exact code before applying downstream `unspsc_category_ids` filters. Tool: `Search_Unspsc_Categories`

```json
{
  "query": "",
  "search_mode": "keyword",
  "fields_to_return": [
    "govtribe_id"
  ],
  "page": 1,
  "per_page": 1,
  "unspsc_category_ids": [
    "81110000"
  ],
  "unspsc_category_ids_operator": "in"
}
```

Pattern B: Resolve multiple known categories in one call using include semantics. Tool: `Search_Unspsc_Categories`

```json
{
  "query": "",
  "search_mode": "keyword",
  "fields_to_return": [
    "govtribe_id"
  ],
  "page": 1,
  "per_page": 10,
  "unspsc_category_ids": [
    "81110000",
    "81112003",
    "80101504"
  ],
  "unspsc_category_ids_operator": "in"
}
```

Pattern C: Semantic discovery when the user describes capability intent instead of giving a code. Tool: `Search_Unspsc_Categories`

```json
{
  "query": "technology services for data center operations",
  "search_mode": "semantic",
  "fields_to_return": [
    "govtribe_id"
  ],
  "page": 1,
  "per_page": 10
}
```

Pattern D: Exclude a known category while exploring alternatives. Tool: `Search_Unspsc_Categories`

```json
{
  "query": "",
  "search_mode": "keyword",
  "fields_to_return": [
    "govtribe_id"
  ],
  "page": 1,
  "per_page": 25,
  "unspsc_category_ids": [
    "81110000"
  ],
  "unspsc_category_ids_operator": "not_in"
}
```

Pattern E: Metadata-only response when a workflow needs counts and result-set identifiers without row payloads. Tool: `Search_Unspsc_Categories`

```json
{
  "query": "",
  "search_mode": "keyword",
  "page": 1,
  "per_page": 0
}
```
