# Search Jurisdictions

`Search_Jurisdictions` retrieves GovTribe jurisdiction participant records that represent state-level subdivisions and local governing entities.

## When To Use

* Which jurisdictions match a state, a jurisdiction name, or a known FIPS code?
* Which jurisdiction records correspond to a list of IDs provided by a user or workflow?
* Which states currently have the most jurisdiction records in a filtered set?
* Which jurisdictions are similar to a known jurisdiction or related GovTribe entity?
* Which jurisdiction records should be used as normalized inputs for downstream state-and-local 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.
3. [Location\_Filtering\_Guide](https://docs.govtribe.com/user-guide/mcp/guides/location_filtering_guide): Required before setting location filters.

## 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`
* `state_ids`: Filter by states. Use GovTribe IDs or USPS state codes. See Required Reading: [Location\_Filtering\_Guide](https://docs.govtribe.com/user-guide/mcp/guides/location_filtering_guide).
  * `type`: `array<string>`
  * `required`: `no`
  * `default`: `n/a`
* `state_ids_operator`: Choose whether to include or exclude values for State IDs (GovTribe or USPS code).
  * `type`: `null|string`
  * `required`: `no`
  * `default`: `in`
  * `options`: `in`, `not_in`
* `similar_filter`: Find similar to the provided govtribe\_type + govtribe\_id.
  * `type`: `null|object`
  * `required`: `no`
  * `default`: `n/a`
  * `shape`: `{ govtribe_type: string, govtribe_id: string }`
* `jurisdiction_ids`: Include or exclude results by jurisdictions. Use GovTribe IDs or FIPS codes. See Required Reading: [Location\_Filtering\_Guide](https://docs.govtribe.com/user-guide/mcp/guides/location_filtering_guide).
  * `type`: `array<string>`
  * `required`: `no`
  * `default`: `n/a`
* `jurisdiction_ids_operator`: Choose whether to include or exclude values for Jurisdiction IDs (GovTribe or FIPS code).
  * `type`: `null|string`
  * `required`: `no`
  * `default`: `in`
  * `options`: `in`, `not_in`
* `aggregations`: Aggregation keys to compute.
  * `type`: `array<string>`
  * `required`: `no`
  * `default`: `n/a`
  * `options`: `top_states_by_doc_count`
* `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`, `fips_code`, `updated_at`

## 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.
  * `aggregations`: Aggregation payload keyed by requested aggregation names when requested.
* Row keys:
  * `govtribe_id`
  * `govtribe_type`
  * `govtribe_url`
  * `name`
  * `fips_code`
  * `updated_at`
* Relationship retrieval map:
  * `none`: This resource has no relationship fields.

## Usage Patterns

Pattern A: Jurisdictions in a target state with row output. Tool: `Search_Jurisdictions`

```json
{
  "query": "",
  "search_mode": "keyword",
  "fields_to_return": [
    "govtribe_id"
  ],
  "state_ids": [
    "CA"
  ],
  "per_page": 25
}
```

Pattern B: Exact jurisdiction lookup by FIPS code. Tool: `Search_Jurisdictions`

```json
{
  "query": "",
  "search_mode": "keyword",
  "fields_to_return": [
    "govtribe_id"
  ],
  "per_page": 10,
  "jurisdiction_ids": [
    "06081"
  ]
}
```

Pattern C: Aggregation-only distribution of jurisdictions by state. Tool: `Search_Jurisdictions`

```json
{
  "query": "",
  "search_mode": "keyword",
  "aggregations": [
    "top_states_by_doc_count"
  ],
  "per_page": 0
}
```

Pattern D: Similar jurisdictions to a known jurisdiction record. Tool: `Search_Jurisdictions`

```json
{
  "query": "",
  "search_mode": "semantic",
  "fields_to_return": [
    "govtribe_id"
  ],
  "similar_filter": {
    "govtribe_type": "jurisdiction",
    "govtribe_id": "<JURISDICTION_ID>"
  },
  "per_page": 10
}
```
