# Search Government Files

`Search_Government_Files` is the GovTribe MCP search tool for government-provided files tied to federal and state/local contracting and grant workflows; if content beyond `content_snippet` is needed, call `Documentation` with `article_name="Vector_Store_Content_Retrieval_Guide"`, then use `Add_To_Vector_Store` and `Search_Vector_Store`.

## When To Use

Typical questions this tool answers well:

* Which government files mention a phrase, concept, or requirement in the file corpus?
* Which files are attached to a known federal contract opportunity, federal grant opportunity, IDV, state/local opportunity, agency, state, or jurisdiction?
* Which files include specific points of contact and should be reviewed first?
* Which file set should be staged into a vector store for follow-on semantic file chunk retrieval?
* How can I return search metadata only (`per_page: 0`) versus document rows (`per_page > 0`)?

## 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`
* `federal_contract_idv_ids`: Filter by federal contract IDVs. Use GovTribe IDs.
  * `type`: `array<string>`
  * `required`: `no`
  * `default`: `n/a`
* `federal_contract_idv_ids_operator`: Choose whether to include or exclude values for Federal Contract IDV GovTribe IDs.
  * `type`: `null|string`
  * `required`: `no`
  * `default`: `in`
  * `options`: `in`, `not_in`
* `federal_contract_opportunity_ids`: Filter by federal contract opportunities. Use GovTribe IDs.
  * `type`: `array<string>`
  * `required`: `no`
  * `default`: `n/a`
* `federal_contract_opportunity_ids_operator`: Choose whether to include or exclude values for Federal Contract Opportunity GovTribe IDs.
  * `type`: `null|string`
  * `required`: `no`
  * `default`: `in`
  * `options`: `in`, `not_in`
* `federal_grant_opportunity_ids`: Filter by federal grant opportunities. Use GovTribe IDs.
  * `type`: `array<string>`
  * `required`: `no`
  * `default`: `n/a`
* `federal_grant_opportunity_ids_operator`: Choose whether to include or exclude values for Federal Grant Opportunity GovTribe IDs.
  * `type`: `null|string`
  * `required`: `no`
  * `default`: `in`
  * `options`: `in`, `not_in`
* `jurisdiction_ids`: Filter 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`
* `state_local_contract_opportunity_ids`: Filter by state and local contract opportunities. Use GovTribe IDs.
  * `type`: `array<string>`
  * `required`: `no`
  * `default`: `n/a`
* `state_local_contract_opportunity_ids_operator`: Choose whether to include or exclude values for State and Local Contract Opportunity GovTribe IDs.
  * `type`: `null|string`
  * `required`: `no`
  * `default`: `in`
  * `options`: `in`, `not_in`
* `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`
* `contact_ids`: Filter by points of contact. Use GovTribe IDs.
  * `type`: `array<string>`
  * `required`: `no`
  * `default`: `n/a`
* `contact_ids_operator`: Choose whether to include or exclude values for Contact GovTribe IDs.
  * `type`: `null|string`
  * `required`: `no`
  * `default`: `in`
  * `options`: `in`, `not_in`
* `federal_agency_ids`: Filter by federal agencies. Use GovTribe IDs.
  * `type`: `array<string>`
  * `required`: `no`
  * `default`: `n/a`
* `federal_agency_ids_operator`: Choose whether to include or exclude values for Federal Agency GovTribe IDs.
  * `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 }`
* `government_file_ids`: Include or exclude results by GovTribe IDs.
  * `type`: `array<string>`
  * `required`: `no`
  * `default`: `n/a`
* `government_file_ids_operator`: Choose whether to include or exclude values for GovTribe IDs.
  * `type`: `null|string`
  * `required`: `no`
  * `default`: `in`
  * `options`: `in`, `not_in`
* `sort`: Sort configuration.
  * `type`: `object`
  * `required`: `no`
  * `default`: `n/a`
  * `shape`: `{ key?: null|string, direction?: null|string }`
  * `options`: `key`: `postedDate`, `_score`; `direction`: `asc`, `desc`
* `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_ai_summary`, `govtribe_type`, `govtribe_url`, `name`, `download_url`, `size`, `posted_date`, `content_snippet`, `updated_at`, `parent_record`, `found_in_file_contacts`

## 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.
  * When `per_page: 0`, responses are metadata-only and include `path`, `total`, `contains`, `search_results_id_can_generate_saved_search`, `search_results_id`, and `view_search_results_url`.
* Row keys:
  * `govtribe_id`
  * `govtribe_ai_summary`
  * `govtribe_type`
  * `govtribe_url`
  * `name`
  * `download_url`
  * `size`
  * `posted_date`
  * `content_snippet`
  * `updated_at`
  * `parent_record`
  * `found_in_file_contacts`
* Relationship retrieval map:
  * `found_in_file_contacts`
    * `resource_type`: `contact`
    * `tool`: `Search_Contacts`
    * `filter`: `contact_ids`
    * `nested_keys`: `govtribe_id`, `govtribe_type`, `name`, `email`, `govtribe_url`
  * `parent_record`
    * `resource_type`: `federal_contract_idv`
    * `tool`: `Search_Federal_Contract_IDVs`
    * `filter`: `federal_contract_i_d_v_ids`
    * `nested_keys`: `govtribe_id`, `govtribe_type`, `govtribe_url`, `name`
    * `resource_type`: `federal_contract_opportunity`
    * `tool`: `Search_Federal_Contract_Opportunities`
    * `filter`: `federal_contract_opportunity_ids`
    * `nested_keys`: `govtribe_id`, `govtribe_type`, `govtribe_url`, `name`
    * `resource_type`: `federal_grant_opportunity`
    * `tool`: `Search_Federal_Grant_Opportunities`
    * `filter`: `federal_grant_opportunity_ids`
    * `nested_keys`: `govtribe_id`, `govtribe_type`, `govtribe_url`, `name`
    * `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: Keyword lookup for exact phrases in government-file corpus, scoped by federal opportunity IDs. Tool: `Search_Government_Files`

```json
{
  "query": "\"performance work statement\" \"Q&A\"",
  "search_mode": "keyword",
  "fields_to_return": [
    "govtribe_id"
  ],
  "federal_contract_opportunity_ids": [
    "<FEDERAL_OPPORTUNITY_ID>"
  ],
  "federal_contract_opportunity_ids_operator": "in",
  "sort": {
    "key": "postedDate",
    "direction": "desc"
  },
  "page": 1,
  "per_page": 10
}
```

Pattern B: Semantic discovery for conceptually related files, filtered by agency and state. Tool: `Search_Government_Files`

```json
{
  "query": "upcoming network modernization support requirements in healthcare facilities",
  "search_mode": "semantic",
  "fields_to_return": [
    "govtribe_id"
  ],
  "federal_agency_ids": [
    "<FEDERAL_AGENCY_ID>"
  ],
  "federal_agency_ids_operator": "in",
  "state_ids": [
    "<STATE_ID>"
  ],
  "state_ids_operator": "in",
  "sort": {
    "key": "_score",
    "direction": "desc"
  },
  "page": 1,
  "per_page": 15
}
```

Pattern C: Retrieve files tied to a known IDV, then expand extracted contacts via `Search_Contacts`. Tool: `Search_Government_Files`

```json
{
  "query": "",
  "search_mode": "keyword",
  "fields_to_return": [
    "govtribe_id"
  ],
  "federal_contract_idv_ids": [
    "<IDV_GOVTRIBE_ID>"
  ],
  "federal_contract_idv_ids_operator": "in",
  "sort": {
    "key": "postedDate",
    "direction": "desc"
  },
  "page": 1,
  "per_page": 25
}
```

Pattern D: Metadata-only call to get result-count/search-result identifiers without row payload. Tool: `Search_Government_Files`

```json
{
  "query": "",
  "search_mode": "keyword",
  "state_local_contract_opportunity_ids": [
    "<STATE_LOCAL_OPPORTUNITY_ID>"
  ],
  "state_local_contract_opportunity_ids_operator": "in",
  "sort": {
    "key": "postedDate",
    "direction": "desc"
  },
  "page": 1,
  "per_page": 0
}
```
