Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ All tools are prefixed with `pcm_`. Every tool except `pcm_update_save` and `pcm
| **pcm_get_save_schema** | List every table inside a `.cdb` save file, with its ID and name, plus the total table count. |
| **pcm_get_table_schema** | Inspect a single table by name. Returns its columns (name, SQL type, NOT NULL and primary key flags) and its row count. Use `pcm_get_save_schema` first to discover available table names. |
| **pcm_get_player_info** | Get the active human player and their team from a save file. Returns the player login plus team details (name, resolved division name, resolved country name, evaluation and manager). |
| **pcm_search_cyclist** | Search for a cyclist by first name and/or last name (case-insensitive partial match). Returns up to 10 matches with all ratings (plain, mountain, medium mountain, downhilling, cobble, time trial, prologue, sprint, acceleration, endurance, resistance, recuperation, hill, baroudeur, current ability) and the resolved country name. `mediumMountain` and `currentAbility` are `null` on saves that pre-date those columns. |
| **pcm_search_cyclist** | Search for a cyclist by first name and/or last name (case-insensitive partial match). Returns up to 10 matches with all ratings (plain, mountain, medium mountain, downhilling, cobble, time trial, prologue, sprint, acceleration, endurance, resistance, recuperation, hill, baroudeur, current ability) and the resolved country name; a `truncated` flag signals when more matches exist. `mediumMountain` and `currentAbility` are `null` on saves that pre-date those columns. |
| **pcm_get_team_roster** | List a team's roster (defaults to the active player's team when `teamId` is omitted). Joins DYN_cyclist with its active DYN_contract_cyclist and STA_type_rider; per rider returns name, country, age (derived from birth date and the current game date), rider type, overall ability, contract end year, wage, market value and all per-terrain ability ratings. Ordered by overall ability, highest first. Errors if `teamId` does not exist. |
| **pcm_search_team** | Search for a team by name (case-insensitive partial match against both the full name and short name). Returns up to 10 matches with the resolved division name, country name, evaluation and general manager. |
| **pcm_search_team** | Search for a team by name (case-insensitive partial match against both the full name and short name). Returns up to 10 matches with the resolved division name, country name, evaluation and general manager; a `truncated` flag signals when more matches exist. |
| **pcm_query_save** | Run a read-only SQL query (`SELECT` / `WITH … SELECT` only) against any table in a save file. Write/DDL statements are rejected. Results are capped (default 100, max 1000 rows). |
| **pcm_update_save** | Apply a single `INSERT`/`UPDATE`/`DELETE` statement to a save and write the modified database to a **new** `.cdb` at `outputPath`. The source save is never overwritten (`outputPath` must differ from `savePath`); `SELECT`, schema changes (`DROP`/`CREATE`/`ALTER`) and stacked statements are rejected. Returns the written path and the number of rows changed. |
| **pcm_update_cyclist_ratings** | Change one or more ability ratings of a cyclist (by `IDcyclist`) and write the modified database to a **new** `.cdb` at `outputPath`. Takes a `ratings` object where each field is optional (`plain`, `mountain`, `mediumMountain`, `downhilling`, `cobble`, `timeTrial`, `prologue`, `sprint`, `acceleration`, `endurance`, `resistance`, `recuperation`, `hill`, `baroudeur`; 55–85) — only the fields provided are changed. Returns the written path and the cyclist's full ratings after the update. Setting `mediumMountain` is rejected on saves that pre-date that column. |
Expand Down
19 changes: 16 additions & 3 deletions src/tools/search-cyclist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,23 @@ const cyclistSchema = z.object({
),
});

const MAX_RESULTS = 10;

const outputSchema = z.object({
cyclists: z.array(cyclistSchema).describe("Matching cyclists"),
truncated: z
.boolean()
.describe(
`Whether more matches exist beyond the ${MAX_RESULTS} returned — narrow the search with a longer name to see them`,
),
});

export function registerSearchCyclist(server: McpServer): void {
server.registerTool(
"pcm_search_cyclist",
{
title: "Search PCM cyclist by name",
description:
"Search for a cyclist in a Pro Cycling Manager `.cdb` save file by first name and/or last name (case-insensitive partial match). Returns up to 10 matching cyclists with all their ratings and their country name.",
description: `Search for a cyclist in a Pro Cycling Manager \`.cdb\` save file by first name and/or last name (case-insensitive partial match). Returns up to ${MAX_RESULTS} matching cyclists with all their ratings and their country name; \`truncated\` is true when more matches exist beyond the ${MAX_RESULTS} returned.`,
inputSchema: {
savePath: z.string().describe("Absolute path to the .cdb save file"),
firstName: z
Expand Down Expand Up @@ -73,10 +79,12 @@ export function registerSearchCyclist(server: McpServer): void {
LEFT JOIN STA_country co ON r.fkIDcountry = co.IDcountry
WHERE LOWER(c.gene_sz_lastname) LIKE LOWER(:lastName)
AND LOWER(c.gene_sz_firstname) LIKE LOWER(:firstName)
LIMIT 10`,
ORDER BY c.gene_sz_lastname, c.gene_sz_firstname, c.IDcyclist
LIMIT ${MAX_RESULTS + 1}`,
Comment thread
mpicciolli marked this conversation as resolved.
);

const cyclists: z.infer<typeof cyclistSchema>[] = [];
let truncated = false;
try {
const first = firstName.trim();
const last = lastName.trim();
Expand All @@ -90,6 +98,10 @@ export function registerSearchCyclist(server: McpServer): void {
});

while (stmt.step()) {
if (cyclists.length >= MAX_RESULTS) {
truncated = true;
break;
}
const row = stmt.getAsObject();
cyclists.push({
id: Number(row.IDcyclist),
Expand All @@ -107,6 +119,7 @@ export function registerSearchCyclist(server: McpServer): void {

const output: z.infer<typeof outputSchema> = {
cyclists,
truncated,
};
return output;
}),
Expand Down
19 changes: 16 additions & 3 deletions src/tools/search-team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,23 @@ const teamSchema = z.object({
.describe("General manager name (gene_sz_manager_general)"),
});

const MAX_RESULTS = 10;

const outputSchema = z.object({
teams: z.array(teamSchema).describe("Matching teams"),
truncated: z
.boolean()
.describe(
`Whether more matches exist beyond the ${MAX_RESULTS} returned — narrow the search with a longer name to see them`,
),
});

export function registerSearchTeam(server: McpServer): void {
server.registerTool(
"pcm_search_team",
{
title: "Search PCM team by name",
description:
"Search for a team in a Pro Cycling Manager `.cdb` save file by name (case-insensitive partial match against both the full name and the short name). Returns up to 10 matching teams with their division name, country name, evaluation and general manager.",
description: `Search for a team in a Pro Cycling Manager \`.cdb\` save file by name (case-insensitive partial match against both the full name and the short name). Returns up to ${MAX_RESULTS} matching teams with their division name, country name, evaluation and general manager; \`truncated\` is true when more matches exist beyond the ${MAX_RESULTS} returned.`,
inputSchema: {
savePath: z.string().describe("Absolute path to the .cdb save file"),
name: z
Expand Down Expand Up @@ -65,10 +71,12 @@ export function registerSearchTeam(server: McpServer): void {
LEFT JOIN STA_country c ON t.fkIDcountry = c.IDcountry
WHERE LOWER(t.gene_sz_name) LIKE LOWER(:name)
OR LOWER(t.gene_sz_shortname) LIKE LOWER(:name)
LIMIT 10`,
ORDER BY t.gene_sz_name, t.IDteam
LIMIT ${MAX_RESULTS + 1}`,
Comment thread
mpicciolli marked this conversation as resolved.
);

const teams: z.infer<typeof teamSchema>[] = [];
let truncated = false;
try {
const query = name.trim();
if (query.length === 0) {
Expand All @@ -78,6 +86,10 @@ export function registerSearchTeam(server: McpServer): void {
stmt.bind({ ":name": `%${query}%` });

while (stmt.step()) {
if (teams.length >= MAX_RESULTS) {
truncated = true;
break;
}
const row = stmt.getAsObject();
teams.push({
id: Number(row.id),
Expand All @@ -95,6 +107,7 @@ export function registerSearchTeam(server: McpServer): void {

const output: z.infer<typeof outputSchema> = {
teams,
truncated,
};
return output;
}),
Expand Down
Loading
Loading