get_set_cards
Retrieve all cards from a specific Magic: The Gathering set with pagination and sorting. Specify set code, page size, and sorting criteria to display results, including prioritization for Chinese cards.
Instructions
获取特定系列的所有卡牌,支持分页和排序。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| order | No | 排序字段 (例如: collector_number, name, -mv) | |
| page | No | 页码 (默认 1) | |
| page_size | No | 每页数量 (默认 20,最大 100) | |
| priority_chinese | No | 是否优先显示中文卡牌 (默认 true) | |
| set_code | Yes | 系列代码,例如 'NEO'、'MOM' |
Implementation Reference
- index.ts:371-397 (handler)The handler function that implements the logic for fetching cards from a specific set using the SBWSZ API, supporting pagination, sorting, and Chinese priority.async function handleGetSetCards( setCode: string, page?: number, pageSize?: number, order?: string, priorityChinese?: boolean, config?: z.infer<typeof configSchema> ) { // 构建基础 URL let url = `${config?.apiUrl || BASE_URL}/set/${encodeURIComponent(setCode.toUpperCase())}/cards`; // 添加查询参数 const params = new URLSearchParams(); if (page !== undefined) params.append('page', page.toString()); if (pageSize !== undefined) params.append('page_size', pageSize.toString()); if (order !== undefined) params.append('order', order); if (priorityChinese !== undefined) params.append('priority_chinese', priorityChinese.toString()); // 如果有查询参数,添加到 URL const queryString = params.toString(); if (queryString) { url += `?${queryString}`; } const response = await fetch(url); return handleSbwszResponse(response); }
- index.ts:203-237 (schema)The tool schema defining the name, description, input schema, and annotations for the get_set_cards tool.const GET_SET_CARDS_TOOL: Tool = { name: "get_set_cards", description: "获取特定系列的所有卡牌,支持分页和排序。", inputSchema: { type: "object", properties: { set_code: { type: "string", description: "系列代码,例如 'NEO'、'MOM'" }, page: { type: "integer", description: "页码 (默认 1)" }, page_size: { type: "integer", description: "每页数量 (默认 20,最大 100)" }, order: { type: "string", description: "排序字段 (例如: collector_number, name, -mv)" }, priority_chinese: { type: "boolean", description: "是否优先显示中文卡牌 (默认 true)" } }, required: ["set_code"] }, annotations: { title: "获取特定系列的所有卡牌", readOnlyHint: true, openWorldHint: true } };
- index.ts:269-276 (registration)Registration of the get_set_cards tool in the SBWSZ_TOOLS array used for listing available tools.const SBWSZ_TOOLS = [ GET_CARD_BY_SET_AND_NUMBER_TOOL, SEARCH_CARDS_TOOL, GET_SETS_TOOL, GET_SET_TOOL, GET_SET_CARDS_TOOL, HZLS_TOOL ] as const;
- index.ts:518-527 (registration)The switch case in the CallToolRequestSchema handler that dispatches calls to the get_set_cards handler function.case "get_set_cards": { const { set_code, page, page_size, order, priority_chinese } = args as { set_code: string; page?: number; page_size?: number; order?: string; priority_chinese?: boolean; }; return await handleGetSetCards(set_code, page, page_size, order, priority_chinese, config); }