File size: 2,407 Bytes
3d23b0f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
import { z } from "zod";
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { safeToolHandler } from "./base";
import * as service from "../../atcoder/service";
/**
* Registers all AtCoder-related MCP tools.
*/
export function register(mcp: McpServer): void {
// Get user rating
mcp.tool(
"atcoder_get_rating",
"Fetches an AtCoder user's rating, rank, max rating, country, birth year, avatar, and complete rating history.",
{ username: z.string().describe("The AtCoder username") },
safeToolHandler(({ username }) => service.getUserRating(username))
);
// Get user contest history
mcp.tool(
"atcoder_get_history",
"Fetches the complete contest participation history for an AtCoder user with performance and rating changes.",
{ username: z.string().describe("The AtCoder username") },
safeToolHandler(({ username }) => service.getUserHistory(username))
);
// Get contest standings
mcp.tool(
"atcoder_get_contest_standings",
"Fetches the standings/leaderboard for a specific AtCoder contest showing all participants' scores and rankings.",
{
contestId: z.string().describe("The AtCoder contest ID (e.g., 'abc300')"),
extended: z.boolean().optional().default(false).describe("Include extended statistics (default: false)")
},
safeToolHandler(({ contestId, extended }) => service.getContestStandings(contestId, extended))
);
// Get contest results
mcp.tool(
"atcoder_get_contest_results",
"Fetches the final results and rating changes for all participants in a specific AtCoder contest.",
{ contestId: z.string().describe("The AtCoder contest ID (e.g., 'abc300')") },
safeToolHandler(({ contestId }) => service.getContestResults(contestId))
);
// Get virtual standings
mcp.tool(
"atcoder_get_virtual_standings",
"Fetches the virtual contest standings for an AtCoder contest, showing ghost participants.",
{
contestId: z.string().describe("The AtCoder contest ID (e.g., 'abc300')"),
showGhost: z.boolean().optional().default(true).describe("Include ghost participants (default: true)")
},
safeToolHandler(({ contestId, showGhost }) => service.getVirtualStandings(contestId, showGhost))
);
}
|