Skip to main content
Glama
huangmiuXyz

Jimeng MCP Server

generateImage

Create AI-generated images using text prompts via the Jimeng MCP Server. Customize dimensions, enhance with super-resolution, and add watermarks or return image URLs with a 24-hour validity.

Instructions

调用即梦AI生成图像

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
heightNo图像高度,默认值:512
logo_infoNo水印信息
promptYes生成图像的文本描述
req_keyNo取固定值: jimeng_high_aes_general_v21_Ljimeng_high_aes_general_v21_L
return_urlNo输出是否返回图片链接(链接有效期为24小时)
seedNo随机种子,默认值:-1
use_pre_llmNo开启文本扩写,针对输入prompt进行扩写优化,如果输入prompt较短建议开启,如果输入prompt较长建议关闭
use_srNo文生图+AIGC超分
widthNo图像宽度,默认值:512

Implementation Reference

  • MCP tool handler for 'generateImage'. Invokes the generateImage helper, processes the image URLs into MCP resource format, and handles errors.
    async (params) => {
      try {
        const imageUrls = await generateImage(params);
    
        // 如果没有返回URL数组,返回错误信息
        if (!imageUrls || (Array.isArray(imageUrls) && imageUrls.length === 0)) {
          return {
            content: [{ type: "text", text: "图像生成失败:未能获取图像URL" }],
            isError: true
          };
        }
    
        // 定义正确的类型
        type ContentItem = { type: "resource"; resource: { uri: string; blob: string; mimeType: string } }
    
        // 将返回的图像URL转换为MCP响应格式
        const responseContent: ContentItem[] = []
    
        if (typeof imageUrls === 'string') {
          // 单个URL的情况
          responseContent.push({
            type: "resource",
            resource: {
              uri: imageUrls,
              blob: '',
              mimeType: ''
            }
          });
        } else if (Array.isArray(imageUrls)) {
          // URL数组的情况
          for (const url of imageUrls) {
            responseContent.push({
              type: "resource",
              resource: {
                uri: url,
                mimeType: '',
                blob: ''
              }
            });
          }
        }
    
        return {
          content: responseContent
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [{ type: "text", text: `图像生成失败: ${errorMessage}` }],
          isError: true
        };
      }
    }
  • Zod input schema for the 'generateImage' tool parameters.
    {
      prompt: z.string().describe("生成图像的文本描述"),
      req_key: z.string().default("jimeng_high_aes_general_v21_L").describe("取固定值: jimeng_high_aes_general_v21_L"),
      width: z.number().optional().default(512).describe("图像宽度,默认值:512"),
      height: z.number().optional().default(512).describe("图像高度,默认值:512"),
      seed: z.number().optional().default(-1).describe("随机种子,默认值:-1"),
      use_sr: z.boolean().optional().default(true).describe("文生图+AIGC超分"),
      use_pre_llm: z.boolean().optional().default(true).describe("开启文本扩写,针对输入prompt进行扩写优化,如果输入prompt较短建议开启,如果输入prompt较长建议关闭"),
      return_url: z.boolean().optional().default(true).describe("输出是否返回图片链接(链接有效期为24小时)"),
      logo_info: z.object({
        add_logo: z.boolean().optional().describe("是否添加水印,默认不添加"),
        position: z.number().optional().describe("水印位置:0-右下角 1-左下角 2-左上角 3-右上角"),
        language: z.number().optional().describe("水印语言:0-中文(AI生成) 1-英文(Generated by AI)"),
        opacity: z.number().optional().describe("水印透明度:0-1,默认0.3"),
        logo_text_content: z.string().optional().describe("水印文字内容")
      }).optional().describe("水印信息")
    },
  • src/server.ts:20-22 (registration)
    Registration of the 'generateImage' tool on the MCP server with name and description.
    server.tool(
      "generateImage",
      "调用即梦AI生成图像",
  • Core helper function in JimengApiClient that performs the actual image generation by calling the Volcengine (JiMeng AI) API with proper parameters, authentication, and error handling.
    public async generateImage(params: ImageGenerationParams): Promise<any> {
      // 验证环境变量
      const credentialError = this.validateCredentials();
      if (credentialError) {
        throw new Error(credentialError);
      }
    
    
    
      const timestamp = new Date().toISOString().replace(/[-:]|\.\d{3}/g, '');
    
      const requestParams = {
        prompt: params.prompt,
        req_key: params.req_key || ' jimeng_high_aes_general_v21_L',
        ...(params.width && { width: params.width.toString() }),
        ...(params.height && { height: params.height.toString() }),
        ...(params.seed && { seed: params.seed.toString() }),
        ...({ use_sr: params.use_sr !== undefined ? Boolean(params.use_sr) : true }),
        ...({ use_pre_llm: params.use_pre_llm !== undefined ? Boolean(params.use_pre_llm) : true }),
        ...({ return_url: params.return_url !== undefined ? Boolean(params.return_url) : true }),
        ...(params.logo_info !== undefined && {
          logo_info: JSON.stringify({
            AddLogo: params.logo_info.add_logo,
            Position: params.logo_info.position,
            Language: params.logo_info.language,
            Opacity: params.logo_info.opacity,
            LogoTextContent: params.logo_info.logo_text_content
          })
        }),
      };
    
      try {
        // 发送API请求
        const response = await this.iamService.fetchOpenAPI<ImageResponse>({
          Action: this.API_ACTION,
          Version: this.API_VERSION,
          data: requestParams,
          method: 'POST',
          timeout: 1800000
        }, {
          serviceName: this.API_SERVICE,
          defaultVersion: this.API_VERSION
        })
        if (response.ResponseMetadata?.Error) {
          throw new Error(`${response.ResponseMetadata.Error.Code}: ${response.ResponseMetadata.Error.Message}`)
        }
        return (response as unknown as ImageResponse).data.image_urls || ''
      } catch (error) {
        if (axios.isAxiosError(error) && error.response) {
          throw new Error(`即梦AI图像生成API错误: ${error.response.data}`)
        } else {
          throw new Error('即梦AI图像生成请求失败:' + error)
        }
      }
    }
  • TypeScript interface defining the ImageGenerationParams, matching the tool schema.
    interface ImageGenerationParams {
      prompt: string;
      req_key: string; // 取固定值: jimeng_high_aes_general_v21_L
      width?: number; // 默认值:512
      height?: number; // 默认值:512
      seed?: number; // 默认值:-1
      use_sr?: boolean; // 文生图+AIGC超分
      use_pre_llm?: boolean; // 开启文本扩写,会针对输入prompt进行扩写优化,如果输入prompt较短建议开启,如果输入prompt较长建议关闭
      return_url?: boolean; // 输出是否返回图片链接 (链接有效期为24小时)
      logo_info?: LogoInfo; // 水印信息
    }
Behavior1/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but provides none. It doesn't mention whether this is a read or write operation, what permissions might be required, rate limits, costs, response format, or any behavioral characteristics. The description is completely silent on all behavioral aspects beyond the basic action implied by the name.

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

Conciseness2/5

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

While technically concise with just one short phrase, this represents under-specification rather than effective conciseness. The single sentence doesn't earn its place by providing meaningful information - it's essentially just a translation of the tool name. Good conciseness balances brevity with information density, which this description fails to achieve.

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

Completeness1/5

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

For a complex image generation tool with 9 parameters, no annotations, and no output schema, the description is completely inadequate. It provides no information about what the tool returns, how to interpret results, error conditions, or any context needed to use the tool effectively. The agent would have to rely entirely on the input schema with no guidance about the tool's purpose or behavior.

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 schema description coverage is 100%, meaning all parameters are well-documented in the schema itself. The description adds no parameter information whatsoever, so it neither compensates for gaps nor adds value beyond the schema. This meets the baseline of 3 when the schema does all the work, but the description contributes nothing additional.

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

Purpose2/5

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

The description '调用即梦AI生成图像' is a tautology that essentially restates the tool name 'generateImage' in Chinese. It provides no additional specificity about what kind of image generation this is, what model or service it uses, or what distinguishes it from other image generation tools. While it does include the verb '生成' (generate) and resource '图像' (image), it lacks any meaningful differentiation or detail.

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

Usage Guidelines1/5

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

The description provides absolutely no guidance on when to use this tool, what scenarios it's designed for, or any prerequisites or constraints. There are no sibling tools mentioned, so differentiation isn't required, but the description fails to give any context about appropriate use cases, limitations, or alternatives.

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/huangmiuXyz/jimeng-mcp'

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