# Search Federal Agencies

`Search_Federal_Agencies` returns GovTribe federal agency profiles that are tied to federal contract and grant activity.

## When To Use

Typical questions this tool answers well:

* What is the GovTribe ID for a specific federal agency name or acronym?
* Which agencies match a topical query or phrase in agency profile content?
* Which agencies should be included or excluded by explicit GovTribe ID lists?
* Which agencies are similar to a known agency or related record?
* How many agencies match a filter set before fetching rows?

## 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.

## 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.
  * `per_page: 0` behavior: response includes only `path`, `total`, `contains`, `search_results_id_can_generate_saved_search`, `search_results_id`, and `view_search_results_url`.
* Row keys:
  * `govtribe_id`
  * `govtribe_type`
  * `govtribe_url`
  * `name`
  * `alternate_name`
  * `acronym`
  * `defense_or_civilian`
  * `updated_at`
* Relationship retrieval map:
  * `none`: This resource has no relationship fields.

## Usage Patterns

Pattern A: Resolve a specific agency by exact name or acronym. Tool: `Search_Federal_Agencies`

```json
{
  "query": "\"Department of the Army\"",
  "search_mode": "keyword",
  "fields_to_return": [
    "govtribe_id"
  ],
  "page": 1,
  "per_page": 10
}
```

Pattern B: Include only a known set of agencies. Tool: `Search_Federal_Agencies`

```json
{
  "search_mode": "keyword",
  "fields_to_return": [
    "govtribe_id"
  ],
  "page": 1,
  "per_page": 25,
  "federal_agency_ids": [
    "9700|2100-A",
    "9700|1700-A"
  ],
  "federal_agency_ids_operator": "in"
}
```

Pattern C: Exclude agencies from broader matching. Tool: `Search_Federal_Agencies`

```json
{
  "query": "defense research",
  "search_mode": "semantic",
  "fields_to_return": [
    "govtribe_id"
  ],
  "page": 1,
  "per_page": 20,
  "federal_agency_ids": [
    "9700|2100-A"
  ],
  "federal_agency_ids_operator": "not_in"
}
```

Pattern D: Find agencies similar to a known agency. Tool: `Search_Federal_Agencies`

```json
{
  "search_mode": "semantic",
  "fields_to_return": [
    "govtribe_id"
  ],
  "page": 1,
  "per_page": 20
}
```

Pattern E: Get match count and reusable result URLs before row retrieval. Tool: `Search_Federal_Agencies`

```json
{
  "query": "health research",
  "search_mode": "keyword",
  "per_page": 0
}
```

Then rerun with `per_page > 0` and the same filters to fetch rows.


---

# 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-federal-agencies.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.
