# NSIP MCP Server
This project uses the NSIP MCP server for sheep genetic evaluation. The server exposes 13 tools for querying the National Sheep Improvement Program database via Model Context Protocol (stdio transport).
Configure in `.cursor/mcp.json`:
```json
{
"mcpServers": {
"nsip": {
"command": "nsip",
"args": ["mcp"]
}
}
}
```
Full reference: `docs/MCP.md`
## Tool Quick-Reference
| Tool | Purpose | Key Parameters |
|---|---|---|
| `search` | Find animals with filters | `breed_id`, `gender`, `status`, `sort_by` |
| `details` | Full EBV data for one animal | `animal_id` |
| `lineage` | Pedigree / ancestry tree | `animal_id` |
| `progeny` | Offspring list | `animal_id`, `page`, `page_size` |
| `profile` | Combined details+lineage+progeny | `animal_id` |
| `breed_groups` | List all breeds | _(none)_ |
| `trait_ranges` | Min/max EBVs for a breed | `breed_id` |
| `compare` | Side-by-side EBV comparison | `animal_ids` (2-5), `traits` |
| `rank` | Weighted multi-trait ranking | `breed_id`, `weights`, `gender`, `top_n` |
| `inbreeding_check` | COI for a potential mating | `sire_id`, `dam_id` |
| `mating_recommendations` | Find optimal mates | `animal_id`, `breed_id`, `target_traits` |
| `flock_summary` | Flock-level statistics | `flock_id`, `breed_id` |
| `database_status` | DB freshness and statuses | _(none)_ |
## Common Workflows
### Evaluate an Animal
1. Call `details` with the animal's LPN ID
2. Call `trait_ranges` with the animal's `breed_id` for breed context
3. Call `lineage` to review pedigree
### Plan a Mating
1. Call `inbreeding_check` with `sire_id` and `dam_id` -- abort if Red
2. Call `details` for both sire and dam
3. Call `mating_recommendations` for ranked alternatives
### Rank a Flock or Breed
1. Call `breed_groups` if the breed ID is unknown
2. Call `rank` with trait weights (negative for lower-is-better traits)
3. Call `compare` on top candidates
### Flock Improvement
1. Call `flock_summary` for current averages
2. Call `trait_ranges` for breed benchmarks
3. Call `rank` to find improvement sires
## Data Conventions
- **LPN IDs**: String identifiers (e.g., `430735-0032`)
- **Breed IDs**: Numeric -- use `breed_groups` to discover
- **13 EBV traits**: BWT, WWT, PWWT, YWT, FAT, EMD, NLB, NWT, PWT, DAG, WGR, WEC, FEC
- **Lower-is-better**: BWT, DAG, WEC, FEC -- use negative weights in `rank`
- **Status**: `CURRENT`, `SOLD`, `DEAD`
- **Gender**: `Male`, `Female`, `Both`
## Error Handling
- Not-found errors: verify IDs with `search` first
- Pagination: 0-indexed pages, defaults 15 (search) and 10 (progeny)
- COI thresholds: Green (<6.25%), Yellow (6.25-12.5%), Red (>12.5%)