# Search Pipelines

`Search_Pipelines` returns GovTribe pipeline records with owner, creator, and stage context so callers can navigate and manage capture workflows.

## When To Use

Typical questions this tool answers well:

* Which pipeline matches a specific pipeline name?
* Which pipelines are owned by or created by a specific user?
* Which stage IDs exist inside a pipeline so I can create a pursuit in the right stage?
* Which pipelines should be included or excluded by explicit GovTribe IDs?
* How many pipelines match filters before fetching full rows?

## Required Reading

1. [Search\_Query\_Guide](https://docs.govtribe.com/user-guide/mcp/guides/search_query_guide): Required before setting free-text query strings.

## 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`
* `owner_ids`: Filter by owners. Use GovTribe IDs.
  * `type`: `array<string>`
  * `required`: `no`
  * `default`: `n/a`
* `owner_ids_operator`: Choose whether to include or exclude values for Owner GovTribe IDs.
  * `type`: `null|string`
  * `required`: `no`
  * `default`: `in`
  * `options`: `in`, `not_in`
* `creator_ids`: Filter by creators. Use GovTribe IDs.
  * `type`: `array<string>`
  * `required`: `no`
  * `default`: `n/a`
* `creator_ids_operator`: Choose whether to include or exclude values for Creator GovTribe IDs.
  * `type`: `null|string`
  * `required`: `no`
  * `default`: `in`
  * `options`: `in`, `not_in`
* `pipeline_ids`: Include or exclude results by GovTribe IDs.
  * `type`: `array<string>`
  * `required`: `no`
  * `default`: `n/a`
* `pipeline_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`: `updated_at`, `created_at`, `_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_type`, `govtribe_url`, `name`, `description`, `created_at`, `updated_at`, `owner`, `creator`, `stages`

## 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 omits row/pagination keys and returns `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`
  * `description`
  * `created_at`
  * `updated_at`
  * `owner`
  * `creator`
  * `stages`
* Relationship retrieval map:
  * `creator`
    * `resource_type`: `user`
    * `tool`: `Search_Users`
    * `filter`: `user_ids`
    * `nested_keys`: `govtribe_id`, `govtribe_type`, `name`, `email`
  * `owner`
    * `resource_type`: `user`
    * `tool`: `Search_Users`
    * `filter`: `user_ids`
    * `nested_keys`: `govtribe_id`, `govtribe_type`, `name`, `email`
  * `stages`
    * `resource_type`: `stage`
    * `tool`: `Search_Stages`
    * `filter`: `stage_ids`
    * `nested_keys`: `govtribe_id`, `govtribe_type`, `govtribe_url`, `name`, `type`

## Usage Patterns

Pattern A: Resolve a pipeline by exact pipeline name. Tool: `Search_Pipelines`

```json
{
  "query": "\"Demo Pipeline\"",
  "fields_to_return": [
    "govtribe_id"
  ],
  "page": 1,
  "per_page": 10
}
```

Pattern B: Find pipelines owned by a specific user (after resolving user ID with `Search_Users`). Tool: `Search_Pipelines`

```json
{
  "query": "",
  "fields_to_return": [
    "govtribe_id"
  ],
  "owner_ids": [
    "<USER_ID>"
  ],
  "owner_ids_operator": "in",
  "page": 1,
  "per_page": 25
}
```

Pattern C: Exclude known pipelines while searching by descriptive text. Tool: `Search_Pipelines`

```json
{
  "query": "capture workflow for grants and state procurement",
  "fields_to_return": [
    "govtribe_id"
  ],
  "page": 1,
  "per_page": 20,
  "pipeline_ids": [
    "<PIPELINE_ID_1>",
    "<PIPELINE_ID_2>"
  ],
  "pipeline_ids_operator": "not_in"
}
```

Pattern D: Get match count and reusable result links without fetching rows. Tool: `Search_Pipelines`

```json
{
  "query": "",
  "per_page": 0
}
```

Pattern E: Find a destination pipeline and extract a triage-stage ID for pursuit creation. Tool: `Search_Pipelines`

```json
{
  "query": "\"AI Test\"",
  "fields_to_return": [
    "govtribe_id"
  ],
  "page": 1,
  "per_page": 10
}
```

Then select `data[0].stages` entry where `type` is `triage` (or the desired non-terminal `user` stage) and pass that stage ID into `Create_Pursuit`.
