Skip to main content
Glama
matthewdtowles

iwantmymtg-mcp

get_portfolio_breakdown

Break down your MTG collection value by dimension like set, rarity, type, format, or cost-basis to see portfolio distribution and gain/loss buckets.

Instructions

Get the user's collection value broken down by a dimension. Premium-gated. Requires IWMM_API_KEY.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
byYesDimension to break down by. 'cost-basis' buckets are gain/loss/at-cost.

Implementation Reference

  • The handler function that executes get_portfolio_breakdown logic. It validates the 'by' parameter (enum: set, rarity, type, format, cost-basis) and calls apiFetch to GET /api/v1/portfolio/breakdown with the query parameter.
    export const getPortfolioBreakdownTool = {
      name: "get_portfolio_breakdown",
      description:
        "Get the user's collection value broken down by a dimension. Premium-gated. Requires IWMM_API_KEY.",
      inputSchema: z.object({
        by: z
          .enum(["set", "rarity", "type", "format", "cost-basis"])
          .describe("Dimension to break down by. 'cost-basis' buckets are gain/loss/at-cost."),
      }),
      handler: ({ by }: { by: string }) =>
        apiFetch({ path: "/api/v1/portfolio/breakdown", query: { by }, authenticated: true }),
    };
  • Input schema defining the 'by' parameter as a zod enum restricted to 'set', 'rarity', 'type', 'format', or 'cost-basis'.
    inputSchema: z.object({
      by: z
        .enum(["set", "rarity", "type", "format", "cost-basis"])
        .describe("Dimension to break down by. 'cost-basis' buckets are gain/loss/at-cost."),
  • Tool is registered in the tools array (index 76), making it discoverable via ListToolsRequestSchema and callable via CallToolRequestSchema.
    getPortfolioBreakdownTool,
    refreshPortfolioTool,
  • A name-to-tool lookup map (toolsByName) is built from the tools array, enabling fast dispatch when a tool is called by name.
    export const toolsByName: Record<string, ToolDefinition> = Object.fromEntries(
      tools.map((t) => [t.name, t]),
    );
  • Helper apiFetch function that constructs the URL, adds auth headers, and performs the HTTP request. Used by the handler to call the external 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;
    }
Behavior2/5

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

No annotations present, so description must fully convey behavior. It mentions premium gating and API key, but lacks details on output format, rate limits, or error scenarios.

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?

Two sentences, no wasted words, purpose front-loaded. Extremely concise.

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?

With one fully described parameter and no output schema, the description is minimally adequate. Could benefit from response format details and error conditions.

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 100% with a well-described enum parameter. Description adds no extra meaning beyond schema, meeting baseline.

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

Purpose4/5

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

Clearly states verb 'get' and resource 'collection value broken down by a dimension'. However, does not explicitly differentiate from siblings like get_portfolio_summary.

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

Usage Guidelines2/5

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

Provides authentication requirement ('Premium-gated. Requires IWMM_API_KEY') but no explicit guidance on when to use vs alternatives or when not to use.

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