Skip to main content
Glama

export_buddy_card

Export your buddy card as an SVG image file. Specify the output path.

Instructions

Export your full buddy card as an SVG image file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoOutput file path (default: ./buddy-{name}-card.svg in current directory)

Implementation Reference

  • The handler function for the export_buddy_card tool. It takes an optional 'path' argument, retrieves the current buddy from S.currentBuddy, builds card lines via buildCardLines(), converts to SVG via buildSvg(), and writes the result to a file.
    handler: async (args: Record<string, unknown>) => {
      S.petBuddyStreak = 0;
      S.lastToolCalled = 'export_buddy_card';
      if (!S.currentBuddy) return 'Initialize a buddy first!';
      const b = S.currentBuddy;
      const borderColor = RARITY_HEX[b.rarity] ?? '#FFFFFF';
    
      const outputPath = args['path']
        ? resolve(String(args['path']))
        : resolve(`buddy-${sanitizeName(b.name ?? 'buddy')}-card.svg`);
      try {
        writeFileSync(outputPath, buildSvg(buildCardLines(b), borderColor));
        return `✅ Card exported to: ${outputPath}`;
      } catch (err: unknown) {
        return `❌ Export failed: ${(err as Error).message}`;
      }
    },
  • The tool definition object containing name 'export_buddy_card', description, and inputSchema (with optional 'path' string property).
    const exportBuddyCardTool = {
      tool: {
        name: 'export_buddy_card',
        description: 'Export your full buddy card as an SVG image file.',
        inputSchema: {
          type: 'object' as const,
          properties: {
            path: {
              type: 'string',
              description: 'Output file path (default: ./buddy-{name}-card.svg in current directory)',
            },
          },
        },
      },
  • Registration of the export_buddy_card tool into the dynamicTools Map via dynamicTools.set(). Also includes metadata in _def.
    dynamicTools.set('export_buddy_card', {
      ...exportBuddyCardTool,
      _def: {
        toolName: 'export_buddy_card',
        description: 'Core: Export Card SVG',
        logic: 'N/A',
        scope: 'global',
      },
    });
  • buildCardLines() helper: builds the text-based card layout (borders, stats, sprite, name, bio) from ProfileData for rendering into SVG.
    function buildCardLines(b: ProfileData): string[] {
      const dg = b.stats['DEBUGGING'] ?? 0;
  • buildSvg() helper: converts text lines into an SVG with monospace font, black background, colored borders/rarity based on rarity color.
    function buildSvg(lines: string[], borderColor: string = '#FFFFFF'): string {
      const maxLen = Math.max(...lines.map((l) => l.length), 1);
      const width = Math.ceil(maxLen * CHAR_WIDTH) + PAD_X * 2;
      const height = Math.ceil(lines.length * LINE_HEIGHT) + PAD_Y * 2;
    
      const tspans = lines
        .map((line, i) => {
          const y = PAD_Y + (i + 1) * LINE_HEIGHT;
          const isBorderLine = line.startsWith('╭') || line.startsWith('╰');
          if (isBorderLine) {
            return `    <tspan x="${PAD_X}" y="${y}" fill="${borderColor}">${escapeXml(line)}</tspan>`;
          }
          const isRarityLine = line.includes('★★');
          if (isRarityLine) {
            return `    <tspan x="${PAD_X}" y="${y}" fill="${borderColor}">${escapeXml(line)}</tspan>`;
          }
          const isSpriteContent = /[()[\]/\\_.~`|^=<>:;,@*+ω-]/.test(line);
          if (isSpriteContent && line.includes('│')) {
            const parts = line.split('│');
            const colored = parts
              .map((part) => escapeXml(part))
              .join(`<tspan fill="${borderColor}">│</tspan>`);
            return `    <tspan x="${PAD_X}" y="${y}" fill="${borderColor}">${colored}</tspan>`;
          }
          if (line.includes('│')) {
            const parts = line.split('│');
            const colored = parts
              .map((part) => escapeXml(part))
              .join(`<tspan fill="${borderColor}">│</tspan>`);
            return `    <tspan x="${PAD_X}" y="${y}">${colored}</tspan>`;
          }
          if (!line.includes('│') && !isBorderLine) {
            return `    <tspan x="${PAD_X}" y="${y}" fill="${borderColor}">${escapeXml(line)}</tspan>`;
          }
          return `    <tspan x="${PAD_X}" y="${y}">${escapeXml(line)}</tspan>`;
        })
        .join('\n');
    
      return [
        `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}">`,
        `  <rect width="${width}" height="${height}" fill="#000000" stroke="#FFFFFF" stroke-width="2" rx="10"/>`,
        `  <text font-family="'Cascadia Code','Fira Code','Courier New',monospace" font-size="${FONT_SIZE}" fill="#cdd6f4" xml:space="preserve">`,
        tspans,
        `  </text>`,
        `</svg>`,
      ].join('\n');
    }
Behavior2/5

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

No annotations are provided, so the description must disclose behavioral traits. It only states the export action, omitting details like permissions, side effects (e.g., file overwriting), or rate limits.

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?

A single, front-loaded sentence of 10 words is highly concise and contains all essential information without redundancy.

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

Completeness4/5

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

Given the tool's simplicity (1 optional parameter, no output schema), the description is adequate. It could mention file overwriting behavior, but overall it is mostly 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?

The input schema covers 100% of parameters with detailed descriptions (including default). The tool description adds no additional meaning beyond the schema, earning the baseline score.

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 tool exports the full buddy card as an SVG image file, using a specific verb and resource, distinguishing it from siblings like export_buddy_sprite.

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 does not mention when to use this tool versus alternatives like export_buddy_sprite. It lacks explicit guidance on context or exclusions, though the purpose is clear.

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/Lyellr88/buddy-mcp'

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