# 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_names=["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, state/local award, state/local IDV, state/local vehicle, 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\_Mode\_And\_Query\_Guide](/user-guide/mcp/guides/search_mode_and_query_guide.md): Required before setting free-text query strings and choosing keyword vs semantic retrieval.
2. [Location\_Filtering\_Guide](/user-guide/mcp/guides/location_filtering_guide.md): Required before setting location filters.

## 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`
    * `resource_type`: `state_local_contract_award`
    * `tool`: `Search_State_And_Local_Contract_Awards`
    * `filter`: `state_and_local_contract_award_ids`
    * `nested_keys`: `govtribe_id`, `govtribe_type`, `govtribe_url`, `name`
    * `resource_type`: `state_local_contract_idv`
    * `tool`: `Search_State_And_Local_Contract_IDVs`
    * `filter`: `state_and_local_contract_i_d_v_ids`
    * `nested_keys`: `govtribe_id`, `govtribe_type`, `govtribe_url`, `name`
    * `resource_type`: `state_local_contract_vehicle`
    * `tool`: `Search_State_And_Local_Contract_Vehicles`
    * `filter`: `state_and_local_contract_vehicle_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
{
  "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
{
  "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
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.govtribe.com/user-guide/mcp/tools/search-government-files.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
