Skip to content

feat: add pcm_get_team_roster tool - #7

Merged
mpicciolli merged 4 commits into
mainfrom
feat/add-get-team-roster-tool
Jun 29, 2026
Merged

feat: add pcm_get_team_roster tool#7
mpicciolli merged 4 commits into
mainfrom
feat/add-get-team-roster-tool

Conversation

@mpicciolli

@mpicciolli mpicciolli commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a new read-only MCP tool, pcm_get_team_roster, that lists a team's roster from a PCM .cdb save — the "show me my team" view.

  • Defaults to the active player's team (GAM_user.game_i_active = 1) when teamId is omitted; accepts an explicit teamId.
  • Errors with a clear not found message when an explicit teamId doesn't exist in DYN_team (instead of silently returning an empty roster).
  • Per cyclist returns: name, country, age, rider type (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).
  • Ordered by overall ability, highest first.

Joins DYN_cyclist with its active DYN_contract_cyclist, STA_type_rider, and STA_region/STA_country.

Implementation notes

  • Age is derived from DYN_cyclist.gene_i_birthdate and the current in-game date (GAM_config.gene_i_date), both packed as YYYYMMDD. Extracted helpers: getGameDate() (DB layer, in save-db.ts) and the pure ageFromYmd() (in helpers.ts).
  • Shared cyclist schema: the 14 per-terrain ratings, their SQL column aliases, and row mapping are factored into src/schemas/cyclist.ts (ratingsSchema / ratingsColumns() / mapRatings()) and reused by both pcm_get_team_roster and pcm_search_cyclist. Ratings are exposed flat in both tools for a consistent cyclist shape (search-cyclist's public output is unchanged).
  • Defensive PRAGMA table_info guards keep the query valid on older saves that pre-date value_f_current_ability, value_f_capital, and charac_i_medium_mountain (returned as null).
  • Stays strictly read-only via withSaveDb.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_roster tool with team resolution (explicit teamId or active player’s team) and a roster query joining cyclist/contract/type/country data.
  • Factored shared cyclist per-terrain ratings into src/schemas/cyclist.ts and reused it in pcm_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.

Comment thread src/save-db.ts
mpicciolli and others added 2 commits June 29, 2026 08:51
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@mpicciolli
mpicciolli merged commit 37bcebe into main Jun 29, 2026
2 checks passed
@mpicciolli
mpicciolli deleted the feat/add-get-team-roster-tool branch June 29, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants