# Drawstep engine · Effects · `searchLibrary` > Search library — e.g. “search your library for a card, put it into your hand, then shuffle”. Engine: Magic: The Gathering (`mtg`). This is one primitive of the Drawstep card vocabulary; field names and the discriminator are exact. Wiki page: https://drawstep.xyz/wiki/mtg/effects#searchLibrary ## Where it goes One step of an ability's `effects[]` (a spell's, a trigger's, an activated ability's, a mode's): `{ "effect": "searchLibrary", … }`. Steps resolve in order. Printed words that point here (search aliases): search your library tutor fetch. ## Fields | Field | Type | Required | Description | |---|---|---|---| | `optional` | `boolean` | no | The searcher may decline the entire search, including its shuffle (CR 701.23, 608.2d) | | `searcher` | `"searchedPlayer" \| "controller"` | no | searchedPlayer: the targeted player searches their own zones; controller: the ability's controller searches the selected players' zones ("Search its controller's graveyard, hand, and library"); otherwise you search a targeted player's zones (CR 701.19a) | | `target` | `PlayerTargetDef` | no | Declared player target whose library is searched (CR 601.2c) | | `who` | `"you" \| "controller" \| "abilityController" \| "sourceController" \| "owner" \| "eachOpponent" \| "eachPlayer" \| "target" \| "triggeringPlayer" \| "defendingPlayer" \| "attackingPlayer" \| "activePlayer" \| "re …` | no | Which player(s) — a player selector (default `you`) | | `filter` | `ObjectFilter` | no | Which objects (ObjectFilter; set fields AND together) | | `zones` | `("battlefield" \| "hand" \| "graveyard" \| "library" \| "exile" \| "stack" \| "command")[]` | no | Zones searched together; default library (CR 701.19) | | `optionalZones` | `boolean` | no | And/or: choose which listed zones to search; shuffle only when library is searched (CR 701.19) | | `findAll` | `boolean` | no | "Search … for all cards …": every card matching the quality in the searched zones is found — the searcher sees each whole zone, so nothing can be missed (CR 701.19b, Sowing Salt rulings). Use max "any" | | `finds` | `({ filter?: ObjectFilter; max?: any; forEach?: TargetDef })[]` | no | Separate finds with different qualities, excluding already found cards; one final shuffle (CR 701.19) | | `distinctNames` | `boolean` | no | Found cards must have different names (CR 201.2, 701.19b) | | `shareLandType` | `boolean` | no | CR 205.3i, 701.23b: found cards share a land type across the group; zero or one card is allowed, including one Wastes | | `destination` | `"battlefield" \| "hand" \| "graveyard" \| "library" \| "exile" \| "stack" \| "command"` | no | Zone the objects are put into | | `position` | `"top" \| "bottom" \| { fromTop: number }` | no | Place found cards here after shuffling the remaining library (CR 701.20b, 401.4, 401.7) | | `then` | `EffectDef[]` | no | Effects on the found set (affected targets), replacing the default move, before the shuffle (CR 608.2c) | | `distribute` | `{ chooser?: "opponent"; target?: PlayerTargetDef; count?: number; destination: "battlefield" \| "hand" \| "graveyard" \| "library" \| "exile" \| "stack" \| "command"; restDestination: "battlefield" \| "hand" …` | no | Choose one found card for destination and put the rest into restDestination; opponent chooses if specified (CR 608.2c) | | `tapped` | `boolean` | no | Tapped (true) or untapped (false); on an effect that puts something onto the battlefield, it enters tapped | | `controllerTarget` | `PlayerTargetDef` | no | CR 110.2a, 601.2c: "put it onto the battlefield under target player's control" - found cards enter under this declared player's control | | `reveal` | `boolean` | no | Reveal the cards found / taken | | `min` | `ValueDef` | no | Required minimum found (CR 701.19b: a search for cards may find fewer only when it cannot); a computed value for "for that many cards" (CR 107.3, 608.2h) | | `max` | `ValueDef \| "any"` | no | Default 1; computed resolution-time limit or any number of matching cards (CR 701.19) | | `shuffle` | `boolean` | no | Shuffle the library afterwards | ## Minimal form ```json {"effect":"searchLibrary"} ``` The engine reads that minimal form as: “search your library for a card, put it into your hand, then shuffle”. ## Stock examples - **Event Probe search** — “” ```json {"effect":"searchLibrary","who":"you","destination":"hand","max":1,"shuffle":false} ``` - **Rune Crown Witness** — “” ```json {"effect":"searchLibrary","who":"you","filter":{"subtypes":["Rune"]},"zones":["library","hand","graveyard"],"optionalZones":true,"then":[{"effect":"moveTo","target":{"of":"object","mode":"affected"},"destination":"battlefield","attachedTo":{"of":"object","mode":"self"}}],"min":1,"max":1,"shuffle":true} ``` - **Rhystic Search Witness** — “” ```json {"effect":"searchLibrary","who":"you","filter":{},"destination":"hand","min":1,"max":1,"shuffle":true} ``` ## Related - [Effects](https://drawstep.xyz/wiki/mtg/effects.md) — the whole topic - [Filters & targets](https://drawstep.xyz/wiki/mtg/targets.md) — how `target` / `filter` select objects and players (selection algebra) - [Values](https://drawstep.xyz/wiki/mtg/values.md) — every number kind an `amount` accepts - [Effects](https://drawstep.xyz/wiki/mtg/effects.md) — the steps a nested `effects` / `then` list may contain - [Start here](https://drawstep.xyz/wiki/mtg/start.md) — the rules, the output contract and the index of every primitive