Zhipu AI Image Generator MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Zhipu AI Image Generator MCP Servergenerate an image of a serene mountain lake at sunset, size 1024x1024"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
智谱AI图像生成MCP服务器
这是一个基于MCP (Model Context Protocol) 的服务器,提供智谱AI CogView4图像生成功能。
功能
使用智谱AI的CogView4模型根据文本提示词生成图片
支持多种图片尺寸:1024x1024、768x768、576x1024
自动保存生成的图片到本地
generated_images文件夹
安装
克隆项目:
git clone https://github.com/lisy09/zhipu_image_mcp.git
cd zhipu_image_mcp使用uv安装依赖:
# 如果尚未安装uv,请先安装:curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync激活虚拟环境:
source .venv/bin/activate # Linux/Mac
# 或
.venv\Scripts\activate # Windows配置
在使用前,需要设置智谱AI的API密钥:
export ZHIPU_API_KEY="your_api_key_here"或者在Windows上:
set ZHIPU_API_KEY=your_api_key_here使用方法
启动MCP服务器
python cogview_server.py服务器启动后,可以通过MCP协议调用以下工具:
generate_cogview4_image
根据文本提示词生成图片。
参数:
prompt(必需): 用于生成图片的详细中文描述size(可选): 图片尺寸,可选值:'1024x1024'、'768x768'、'576x1024',默认为'1024x1024'
示例:
{
"prompt": "一只戴着宇航员头盔的猫漂浮在太空中,背景是璀璨的星河",
"size": "1024x1024"
}生成的图片将保存在generated_images文件夹中,文件名格式为:cogview4_image_YYYYMMDD_HHMMSS.png
在IDE中配置MCP服务器
在RooCode中使用
打开RooCode设置
找到MCP服务器配置选项
添加新的MCP服务器配置:
{
"zhipu-image-mcp": {
"command": "python",
"args": ["/path/to/your/zhipu_image_mcp/cogview_server.py"],
"env": {
"ZHIPU_API_KEY": "your_api_key_here"
}
}
}将
/path/to/your/zhipu_image_mcp替换为项目的实际路径将
your_api_key_here替换为你的智谱AI API密钥保存配置并重启RooCode
配置完成后,你就可以在RooCode中直接使用智谱AI图像生成功能了。
在Claude Code中使用
打开Claude Code设置
找到MCP服务器配置
添加以下配置:
{
"mcpServers": {
"zhipu-image-mcp": {
"command": "python",
"args": ["/path/to/your/zhipu_image_mcp/cogview_server.py"],
"env": {
"ZHIPU_API_KEY": "your_api_key_here"
}
}
}
}将
/path/to/your/zhipu_image_mcp替换为项目的实际路径将
your_api_key_here替换为你的智谱AI API密钥保存配置并重启Claude Code
配置完成后,你就可以在Claude Code中直接使用智谱AI图像生成功能了。
通用配置注意事项
确保Python路径正确,可以使用绝对路径:
/usr/bin/python3或which python查看路径确保项目路径使用绝对路径,避免相对路径导致的问题
API密钥可以通过环境变量设置,也可以直接在配置中指定
如果使用虚拟环境,确保命令指向虚拟环境中的Python:
/path/to/.venv/bin/python
依赖安装确认
在配置MCP服务器之前,请确保已经安装了所有依赖:
在项目中安装依赖(推荐):
cd /path/to/your/zhipu_image_mcp uv sync # 或者 pip install -r requirements.txt使用虚拟环境的Python路径:
{ "command": "/path/to/your/zhipu_image_mcp/.venv/bin/python", "args": ["/path/to/your/zhipu_image_mcp/cogview_server.py"] }或者全局安装依赖:
pip install mcp zai-sdk验证依赖安装:
python -c "import mcp; import zai; print('依赖安装成功')"
如果IDE无法找到依赖,建议使用虚拟环境的完整Python路径,这样可以确保使用正确的依赖环境。
依赖
mcp>=1.0.0
zai-sdk>=0.1.0
requests
python>=3.8
许可证
MIT License
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
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/lisy09/zhipu_image_mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server