Skip to main content
Glama

hzls

Read-only

Convert text into images using Magic: The Gathering card art. Customize output with full card images or include watermark links for creative or functional use cases.

Instructions

活字乱刷(使用卡牌图像拼接句子),将输入的文本使用魔法卡牌图像拼接成图片

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cut_full_imageNo是否使用卡牌完整图像 (默认 true)
target_sentenceYes要拼接的目标句子/文本
with_linkNo是否包含链接水印 (默认 true)

Implementation Reference

  • The async function handleHzls that implements the core logic of the 'hzls' tool: constructs the API URL for /hzls endpoint with parameters, fetches the response, handles errors, converts image to base64, and returns text + image content.
    async function handleHzls(
      targetSentence: string,
      cutFullImage?: boolean,
      withLink?: boolean,
      config?: z.infer<typeof configSchema>
    ) {
      // 构建基础 URL
      let url = `${config?.apiUrl || BASE_URL}/hzls?target_sentence=${encodeURIComponent(targetSentence)}`;
    
      // 添加可选参数
      if (cutFullImage !== undefined) url += `&cut_full_image=${cutFullImage}`;
      if (withLink !== undefined) url += `&with_link=${withLink}`;
    
      try {
        const response = await fetch(url);
        
        // 处理错误响应
        if (!response.ok) {
          const errorText = await response.text().catch(() => "");
          return {
            content: [
              {
                type: "text",
                text: `HTTP 错误 ${response.status}: ${response.statusText}${errorText ? `\n响应内容: ${errorText}` : ""}`
              }
            ],
            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: `活字乱刷成功生成图片`
            },
            {
              type: "image",
              data: base64Data,
              mimeType: contentType
            }
          ],
          isError: false
        };
      } catch (error) {
        // 捕获所有其他错误(网络错误、解析错误等)
        return {
          content: [
            {
              type: "text",
              text: `活字乱刷请求失败: ${(error as Error).message}` 
            },
            {
              type: "text",
              text: `活字乱刷成功生成图片链接:\n${url}`
            }
          ],
          isError: true
        };
      }
    }
  • The Tool object HZLS_TOOL defining the 'hzls' tool: name, description, inputSchema with properties target_sentence (required), cut_full_image, with_link, and annotations.
    const HZLS_TOOL: Tool = {
      name: "hzls",
      description: "活字乱刷(使用卡牌图像拼接句子),将输入的文本使用魔法卡牌图像拼接成图片",
      inputSchema: {
        type: "object",
        properties: {
          target_sentence: {
            type: "string",
            description: "要拼接的目标句子/文本"
          },
          cut_full_image: {
            type: "boolean",
            description: "是否使用卡牌完整图像 (默认 true)"
          },
          with_link: {
            type: "boolean",
            description: "是否包含链接水印 (默认 true)"
          }
        },
        required: ["target_sentence"]
      },
      annotations: {
        title: "使用卡牌图像拼接句子",
        readOnlyHint: true,
        openWorldHint: true
      }
    };
  • index.ts:269-276 (registration)
    Registration of 'hzls' tool by including HZLS_TOOL in the SBWSZ_TOOLS array, which is returned by listTools handler.
    const SBWSZ_TOOLS = [
      GET_CARD_BY_SET_AND_NUMBER_TOOL,
      SEARCH_CARDS_TOOL,
      GET_SETS_TOOL,
      GET_SET_TOOL,
      GET_SET_CARDS_TOOL,
      HZLS_TOOL
    ] as const;
  • index.ts:528-535 (registration)
    In the CallToolRequestSchema request handler switch statement, the case for 'hzls' that extracts arguments and invokes the handleHzls function.
    case "hzls": {
      const { target_sentence, cut_full_image, with_link } = args as {
        target_sentence: string;
        cut_full_image?: boolean;
        with_link?: boolean;
      };
      return await handleHzls(target_sentence, cut_full_image, with_link, config);
    }

Tool Definition Quality

Score is being calculated. Check back soon.

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/sbwsz-mcp'

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