feat: add pcm_get_team_roster tool - #7
Merged
Conversation
…add age calculation utility
There was a problem hiding this comment.
Pull request overview
Adds a new read-only MCP tool (pcm_get_team_roster) to list a team’s roster from a PCM .cdb save, reusing shared cyclist rating schema/mapping and introducing small date/age helpers to support derived fields (age) in tool output.
Changes:
- Added
pcm_get_team_rostertool with team resolution (explicitteamIdor active player’s team) and a roster query joining cyclist/contract/type/country data. - Factored shared cyclist per-terrain ratings into
src/schemas/cyclist.tsand reused it inpcm_search_cyclist. - Added
getGameDate()+ageFromYmd()helper and corresponding unit tests; updated README/AGENTS tool listings.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/helpers.test.ts | Adds unit tests for ageFromYmd() behavior around birthdays. |
| src/tools/search-cyclist.ts | Refactors rating schema/SQL/mapping to use shared cyclist ratings helpers. |
| src/tools/index.ts | Registers the new pcm_get_team_roster tool. |
| src/tools/get-team-roster.ts | Implements the new roster tool, including team resolution, validation, and cyclist roster query/mapping. |
| src/schemas/cyclist.ts | Introduces shared Zod schema + SQL fragment + row-mapper for cyclist per-terrain ratings. |
| src/save-db.ts | Exports SaveDb type and adds getGameDate() helper used by roster tool. |
| src/helpers.ts | Adds ageFromYmd() helper for computing age from packed YYYYMMDD integers. |
| README.md | Documents the new pcm_get_team_roster tool in the tools table. |
| AGENTS.md | Updates repo guidance to include the new tool and shared cyclist ratings schema module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…-get-team-roster-tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new read-only MCP tool,
pcm_get_team_roster, that lists a team's roster from a PCM.cdbsave — the "show me my team" view.GAM_user.game_i_active = 1) whenteamIdis omitted; accepts an explicitteamId.teamIddoesn't exist inDYN_team(instead of silently returning an empty roster).STA_type_rider.CONSTANT), overall ability (note globale), contract end year, wage, market value, and all per-terrain ratings (plain, mountain, medium mountain, downhilling, cobble, time trial, prologue, sprint, acceleration, endurance, resistance, recuperation, hill, baroudeur).Joins
DYN_cyclistwith its activeDYN_contract_cyclist,STA_type_rider, andSTA_region/STA_country.Implementation notes
DYN_cyclist.gene_i_birthdateand the current in-game date (GAM_config.gene_i_date), both packed asYYYYMMDD. Extracted helpers:getGameDate()(DB layer, insave-db.ts) and the pureageFromYmd()(inhelpers.ts).src/schemas/cyclist.ts(ratingsSchema/ratingsColumns()/mapRatings()) and reused by bothpcm_get_team_rosterandpcm_search_cyclist. Ratings are exposed flat in both tools for a consistent cyclist shape (search-cyclist's public output is unchanged).PRAGMA table_infoguards keep the query valid on older saves that pre-datevalue_f_current_ability,value_f_capital, andcharac_i_medium_mountain(returned asnull).withSaveDb.