Skip to main content
Glama

get_card_image

Read-only

Retrieve Yu-Gi-Oh! card images by providing the card ID using the ygocdb-mcp server. Input the card ID to fetch and display the corresponding card image.

Instructions

通过卡牌ID获取游戏王卡牌的图片

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes游戏王卡牌ID,可以使用search_cards工具搜索

Implementation Reference

  • The core handler function that fetches the card image from the CDN URL, handles errors, converts the image to base64, and returns it embedded in the tool response.
    async function handleGetCardImage(id: string, config?: z.infer<typeof configSchema>) {
      const url = `https://cdn.233.momobako.com/ygopro/pics/${encodeURIComponent(id)}.jpg`;
      
      try {
        const response = await fetch(url);
        
        // 处理错误响应
        if (!response.ok) {
          return {
            content: [
              {
                type: "text",
                text: `获取卡牌图片失败: HTTP 错误 ${response.status}: ${response.statusText}`
              }
            ],
            isError: true
          };
        }
        
        // 处理成功响应 - 读取图片数据
        const buffer = await response.arrayBuffer();
        const base64Data = Buffer.from(buffer).toString('base64');
        const contentType = response.headers.get('content-type') || 'image/jpeg';
        
        // 返回图像内容
        return {
          content: [
            {
              type: "text",
              text: `卡牌图片 (ID: ${id})`
            },
            {
              type: "image",
              data: base64Data,
              mimeType: contentType
            }
          ],
          isError: false
        };
      } catch (error) {
        // 捕获所有其他错误(网络错误、解析错误等)
        return {
          content: [
            {
              type: "text",
              text: `获取卡牌图片失败: ${(error as Error).message}`
            }
          ],
          isError: true
        };
      }
    }
  • Defines the tool schema with name, description, input schema (requires 'id' string), and annotations.
    const GET_CARD_IMAGE_TOOL: Tool = {
      name: "get_card_image",
      description: "通过卡牌ID获取游戏王卡牌的图片",
      inputSchema: {
        type: "object",
        properties: {
          id: {
            type: "string",
            description: "游戏王卡牌ID,可以使用search_cards工具搜索"
          }
        },
        required: ["id"]
      },
      annotations: {
        title: "通过ID获取游戏王卡牌图片",
        readOnlyHint: true,
        openWorldHint: true
      }
    };
  • index.ts:276-278 (registration)
    Registers the listTools handler which returns the array of tools including get_card_image.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: YGOCDB_TOOLS
    }));
  • index.ts:293-296 (registration)
    In the CallToolRequestSchema handler's switch statement, registers/dispatches the 'get_card_image' tool call to the handler function.
    case "get_card_image": {
      const { id } = args as { id: string };
      return await handleGetCardImage(id, config);
    }
  • index.ts:136-140 (registration)
    Includes the get_card_image tool in the YGOCDB_TOOLS constant array used for tool listing.
    const YGOCDB_TOOLS = [
      SEARCH_CARDS_TOOL,
      GET_CARD_BY_ID_TOOL,
      GET_CARD_IMAGE_TOOL
    ] as const;
Behavior3/5

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

Annotations already provide readOnlyHint=true and openWorldHint=true, indicating safe read-only access to potentially unknown data. The description adds context about retrieving images specifically, but doesn't disclose additional behavioral traits like image format, size, error handling, or rate limits that would be valuable beyond annotations.

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?

The description is a single, efficient sentence in Chinese that directly states the tool's purpose without any fluff. It's appropriately sized and front-loaded with the core functionality, earning its place clearly.

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 low complexity (single parameter, read-only), rich annotations (readOnlyHint, openWorldHint), and 100% schema coverage, the description is reasonably complete. However, without an output schema, it doesn't explain return values (e.g., image format, error responses), leaving a minor gap for a tool that fetches binary data.

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 100%, with the parameter 'id' fully documented in the schema as '游戏王卡牌ID,可以使用search_cards工具搜索'. The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline for high schema coverage.

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?

The description clearly states the verb ('获取' - get) and resource ('游戏王卡牌的图片' - Yu-Gi-Oh card image) with specific scope ('通过卡牌ID' - via card ID). It distinguishes from sibling 'get_card_by_id' by focusing on images rather than general card data, but doesn't explicitly mention 'search_cards' as a source for IDs.

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 implies usage when needing card images specifically, and the input schema references 'search_cards' as a way to find IDs. However, it lacks explicit guidance on when to choose this tool over 'get_card_by_id' (which might also return images) or clear prerequisites beyond having a card ID.

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

Related 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/lieyanqzu/ygocdb-mcp'

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