Skip to main content
Glama
matthewdtowles

iwantmymtg-mcp

record_transaction

Record a buy or sell transaction for MTG cards. Automatically adjusts inventory by adding or subtracting quantities.

Instructions

Record a buy or sell transaction. By default this also adjusts inventory (BUY adds, SELL subtracts). This is a real write. Requires IWMM_API_KEY.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cardIdYesInternal IWMM card UUID.
typeYes
quantityYes
pricePerUnitYesPer-unit price in USD.
isFoilYes
dateYesISO 8601 date (YYYY-MM-DD).
sourceNoWhere the transaction happened (e.g. 'TCGPlayer', 'LGS').
feesNo
notesNo
skipInventorySyncNoIf true, record the transaction without adjusting inventory. Default false - transactions normally update inventory.

Implementation Reference

  • The main handler for the record_transaction tool. It sends a POST request to /api/v1/transactions with the validated input body, requiring authentication. The handler accepts a transactionCreate schema (cardId, type, quantity, pricePerUnit, isFoil, date, optional source/fees/notes/skipInventorySync) and calls apiFetch.
    export const recordTransactionTool = {
      name: "record_transaction",
      description:
        "Record a buy or sell transaction. By default this also adjusts inventory (BUY adds, SELL subtracts). This is a real write. Requires IWMM_API_KEY.",
      inputSchema: transactionCreate,
      handler: (input: z.infer<typeof transactionCreate>) =>
        apiFetch({ path: "/api/v1/transactions", method: "POST", body: input, authenticated: true }),
    };
  • The Zod input schema (transactionCreate) for record_transaction, defining validation rules for cardId (string UUID), type (BUY/SELL), quantity (positive int), pricePerUnit (non-negative number), isFoil (boolean), date (ISO 8601), and optional source, fees, notes, skipInventorySync fields.
    const transactionCreate = z.object({
      cardId: z.string().describe("Internal IWMM card UUID."),
      type: z.enum(["BUY", "SELL"]),
      quantity: z.number().int().min(1),
      pricePerUnit: z.number().min(0).describe("Per-unit price in USD."),
      isFoil: z.boolean(),
      date: z.string().describe("ISO 8601 date (YYYY-MM-DD)."),
      source: z.string().optional().describe("Where the transaction happened (e.g. 'TCGPlayer', 'LGS')."),
      fees: z.number().min(0).optional(),
      notes: z.string().optional(),
      skipInventorySync: z
        .boolean()
        .optional()
        .describe("If true, record the transaction without adjusting inventory. Default false - transactions normally update inventory."),
    });
  • recordTransactionTool is imported from transactions.ts and registered in the tools array under 'Transactions (auth)' section. Also mapped in toolsByName for dispatch by the server.
    listTransactionsTool,
    recordTransactionTool,
  • The ToolDefinition interface that recordTransactionTool conforms to, defining the shape: name, description, inputSchema, and handler.
    export interface ToolDefinition {
      name: string;
      description: string;
      inputSchema: z.ZodTypeAny;
      handler: (input: any) => Promise<unknown>;
  • The apiFetch helper function used by the handler to make authenticated HTTP requests to the IWMM backend API with bearer token authorization.
    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;
    }
Behavior4/5

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

Without annotations, the description discloses key traits: it is a real write, requires authentication, and adjusts inventory by default. It also hints at the skipInventorySync parameter. However, it does not cover idempotency, rollback, or side effects beyond inventory.

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

Conciseness4/5

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

The description is succinct with two sentences, front-loading the main purpose. It is efficient but lacks some details that could be included without bloat, such as notes on required parameters.

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?

Given the tool's complexity (10 params, write operation, no annotations or output schema), the description is incomplete. It omits return value, error behavior, and parameter constraints beyond what the schema provides, leaving gaps for an AI agent.

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 coverage is only 50%, so the description must compensate. It adds meaning for 'type' (BUY adds, SELL subtracts) and 'skipInventorySync' (default false updates inventory), but many parameters like quantity, fees, and notes remain unelaborated. Partial addition of value.

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?

The description clearly states the verb 'Record' and the resource 'transaction', and distinguishes between buy/sell types. It explicitly mentions inventory adjustment, setting it apart from other transaction tools like delete_transaction or update_transaction.

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

Usage Guidelines3/5

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

The description explains the default behavior (inventory adjustment) and indicates it's a real write requiring an API key, but does not compare this tool to alternatives like add_inventory or update_inventory for inventory-specific tasks. No explicit 'when to use' vs siblings.

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