get_set
Retrieve detailed information for a Magic: The Gathering set by providing its set code.
Instructions
Get detail for a single set by code (e.g. 'lea', 'mh3').
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes |
Implementation Reference
- src/tools/sets.ts:16-22 (handler)The 'get_set' tool handler function. Takes a set code, and fetches set details from the API via apiFetch.
export const getSetTool = { name: "get_set", description: "Get detail for a single set by code (e.g. 'lea', 'mh3').", inputSchema: z.object({ code: z.string() }), handler: ({ code }: { code: string }) => apiFetch({ path: `/api/v1/sets/${encodeURIComponent(code)}` }), }; - src/tools/sets.ts:19-19 (schema)Input schema for 'get_set' tool: requires a single string parameter 'code'.
inputSchema: z.object({ code: z.string() }), - src/tools/index.ts:55-55 (registration)The 'getSetTool' is registered in the tools array at line 55.
getSetTool, - src/tools/index.ts:90-92 (registration)Tools are also indexed by name in toolsByName for runtime lookup.
export const toolsByName: Record<string, ToolDefinition> = Object.fromEntries( tools.map((t) => [t.name, t]), ); - src/api-client.ts:26-67 (helper)The apiFetch utility used by the handler to make HTTP requests to the backend API.
export async function apiFetch<T = unknown>(req: ApiRequest): Promise<T> { const url = new URL(req.path, config.baseUrl); if (req.query) { for (const [k, v] of Object.entries(req.query)) { if (v !== undefined && v !== null && v !== "") { url.searchParams.set(k, String(v)); } } } const headers: Record<string, string> = { Accept: "application/json", "User-Agent": "iwantmymtg-mcp/0.0.1", }; if (req.authenticated) { const { requireApiKey } = await import("./config.js"); headers["Authorization"] = `Bearer ${requireApiKey()}`; } if (req.body !== undefined) { headers["Content-Type"] = "application/json"; } const res = await fetch(url, { method: req.method ?? "GET", headers, body: req.body !== undefined ? JSON.stringify(req.body) : undefined, }); if (!res.ok) { const text = await res.text(); throw new ApiError(res.status, text, { limit: res.headers.get("X-RateLimit-Limit") ?? undefined, remaining: res.headers.get("X-RateLimit-Remaining") ?? undefined, reset: res.headers.get("X-RateLimit-Reset") ?? undefined, }); } if (res.status === 204) return undefined as T; return (await res.json()) as T; }