Skip to main content
Glama
matthewdtowles

iwantmymtg-mcp

get_cost_basis

Retrieve the FIFO cost basis for a Magic: The Gathering card by providing card ID or set code and number, including foil finish.

Instructions

Get FIFO cost basis for a specific card+finish for the authenticated user. Pass either cardId or (setCode, setNumber). Requires IWMM_API_KEY.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cardIdNo
setCodeNo
setNumberNo
isFoilNo

Implementation Reference

  • The handler function for get_cost_basis tool. Calls the IWMM API's cost-basis endpoint with either a cardId or (setCode, setNumber) plus isFoil flag.
    handler: (input: { cardId?: string; setCode?: string; setNumber?: string; isFoil: boolean }) => {
      const query = { isFoil: input.isFoil };
      const path = input.cardId
        ? `/api/v1/transactions/cost-basis/${encodeURIComponent(input.cardId)}`
        : `/api/v1/transactions/cost-basis/${encodeURIComponent(input.setCode!)}/${encodeURIComponent(input.setNumber!)}`;
      return apiFetch({ path, query, authenticated: true });
    },
  • Input schema for get_cost_basis: accepts optional cardId, setCode, setNumber, and a default-false isFoil boolean. Uses .refine() to require either cardId or both setCode+setNumber.
    inputSchema: z
      .object({
        cardId: z.string().optional(),
        setCode: z.string().optional(),
        setNumber: z.string().optional(),
        isFoil: z.boolean().default(false),
      })
      .refine((v) => !!v.cardId || (!!v.setCode && !!v.setNumber), {
        message: "Provide either cardId, or both setCode and setNumber.",
      }),
  • Registration of getCostBasisTool in the tools array, making it available as an MCP tool named 'get_cost_basis'.
    getCostBasisTool,
  • Import of getCostBasisTool from the transactions module into the central tool registry.
      getCostBasisTool,
    } from "./transactions.js";
  • The apiFetch helper used by the handler to make HTTP requests to the IWMM API with authentication.
    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;
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so description carries full burden. Describes it as a read operation ('Get') and specifies authentication need. Does not disclose error behavior, rate limits, or what happens if card not found. Adequate but not detailed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single, concise sentence that is front-loaded with the primary action and resource. No unnecessary words; every part earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema is provided. Description explains input parameters but does not specify return format, error handling, or behavior for missing data. For a tool with 4 parameters and no required ones, it is minimally complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so description adds value by explaining the relationship between parameters (either cardId or setCode+setNumber) and linking isFoil to 'finish'. However, does not describe parameter types or constraints beyond what is in schema. Below high coverage but above low.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states verb 'Get', resource 'FIFO cost basis', and identifies constraints (specific card+finish, authenticated user). It also provides two identification methods, distinguishing it from sibling tools like get_inventory_quantities or get_portfolio_breakdown.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly instructs to pass either cardId or (setCode, setNumber), and mentions authentication requirement. However, lacks guidance on when to use this over alternative tools or when not to use it, which would improve context for an AI agent.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/matthewdtowles/iwantmymtg-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server