docs: add mcp module reference to LIBRARY-API.md#79
Conversation
Adds comprehensive documentation for the mcp module including: - NsipServer struct and serve_stdio() function - analytics submodule with COI, ranking, and complementarity functions - Type definitions for CoiRating, CoiResult, SharedAncestor, RankedAnimal - prompts and resources submodules with cross-references to MCP.md This addresses the documentation gap where the public mcp module was exported but not documented in the library API reference. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Benchmark ResultsNo benchmarks configured. Add benchmarks to benches/ directory. Full results available in CI artifacts. |
Code Coverage ReportOverall Coverage: 0% SummaryFull HTML report available in CI artifacts. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #79 +/- ##
=======================================
Coverage 95.83% 95.83%
=======================================
Files 9 9
Lines 6499 6499
=======================================
Hits 6228 6228
Misses 271 271 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive API reference documentation for the mcp module to docs/reference/LIBRARY-API.md. The mcp module provides a Model Context Protocol (MCP) server implementation with livestock breeding analytics functions. While the module was already exported publicly in lib.rs, it previously lacked documentation in the library API reference.
Changes:
- Documents the
NsipServerstruct andserve_stdio()function for programmatic MCP server instantiation - Adds complete reference for the
analyticssubmodule, including 4 types (CoiRating,SharedAncestor,CoiResult,RankedAnimal) and 4 functions (calculate_coi,rank_animals,trait_complementarity,find_shared_ancestors) - Provides summaries for the
promptsandresourcessubmodules with cross-references to the full MCP documentation
| let search = client.search( | ||
| nsip::SearchCriteria::new() | ||
| .with_breed_id(486) | ||
| .with_gender("Male") | ||
| .with_status("CURRENT") | ||
| ).await?; | ||
|
|
||
| let weights = HashMap::from([ | ||
| ("BWT".to_string(), -1.0), | ||
| ("WWT".to_string(), 2.0), | ||
| ("YWT".to_string(), 1.5), | ||
| ]); | ||
|
|
||
| let ranked = rank_animals(&search.animals, &weights); |
There was a problem hiding this comment.
The example code has two issues:
-
Line 674:
client.search()should beclient.search_animals()- the method is calledsearch_animals, notsearch. -
Line 687:
&search.animalsshould be changed becauseSearchResultshas a field calledresults(of typeVec<serde_json::Value>), notanimals. Furthermore,rank_animals()expects&[AnimalDetails], butSearchResults.resultscontains raw JSON values. The example needs to deserialize the results or use a different approach to obtainAnimalDetailsobjects.
| let sire = client.details("430735-0032").await?; | ||
| let dam = client.details("430735-0089").await?; |
There was a problem hiding this comment.
The method name is incorrect. It should be client.animal_details(), not client.details(). The NsipClient does not have a details() method.
| let sire = client.details("430735-0032").await?; | |
| let dam = client.details("430735-0089").await?; | |
| let sire = client.animal_details("430735-0032").await?; | |
| let dam = client.animal_details("430735-0089").await?; |
Summary
Adds comprehensive documentation for the
mcpmodule to the Library API Reference (docs/reference/LIBRARY-API.md).Changes
This PR addresses a documentation gap where the public
mcpmodule was exported inlib.rsbut not documented in the library API reference.Added sections:
mcp Module Overview
NsipServerstruct documentationserve_stdio()function for starting the MCP serveranalytics Submodule
CoiRating,SharedAncestor,CoiResult,RankedAnimalcalculate_coi()- Wright's coefficient of inbreeding calculationrank_animals()- Weighted trait-based rankingtrait_complementarity()- Midparent EBV predictionfind_shared_ancestors()- Common ancestor detectionprompts Submodule
resources Submodule
Documentation quality:
Context
The
mcpmodule is a major feature of the nsip crate (13 tools, 7 prompts, 9 resources), but library users had no API reference for programmatic use of analytics functions or the MCP server itself. This documentation enables developers to:NsipServerprogrammaticallycalculate_coi,rank_animals,trait_complementarity) in custom applicationsDocumentation Philosophy
This follows the Diátaxis framework adopted in ADR-0003:
Testing
crates/mcp/Related Issues
Addresses documentation gap identified in repository audit. No open issues, but this improves developer experience for library users integrating NSIP analytics into custom applications.
Type: Documentation
Scope: Library API Reference
Breaking: No