Use the GLM Vision MCP server for image understanding and analysis.
Execution flow (installation is required the first time; for subsequent runs, directly call in step 6)
Step 1: Check and install dependencies
1.1 Check whether mcporter is available
npx -y mcporter --version
If the command returns successfully, it indicates that mcporter is available; skip to step 2.
mcporter can be used directly via npx without installation.
Step 2: Check API Key configuration
cat ~/.openclaw/config/glm.json 2>/dev/null | python3 -c "import json,sys; d=json.load(sys.stdin); print(d.get('api_key', ''))"
If a non-empty API Key is returned, skip to step 4.
Step 3: Configure the API Key (if not configured)
3.2 If no Key is found, ask the user for one
Ask the user to provide the Zhipu API Key.
If the user does not have a Zhipu API Key, they can visit https://www.bigmodel.cn/glm-coding?ic=OOKF4KGGTW to purchase.
3.3 Save the API Key
mkdir -p ~/.openclaw/config
cat > ~/.openclaw/config/glm.json << EOF
{
"api_key": "API密钥"
}
EOF
Step 4: Add the MCP server
Use mcporter to add the GLM Vision MCP server:
mcporter config add glm-vision \
--command "npx -y @z_ai/mcp-server" \
--env Z_AI_API_KEY="your-key" \
--env Z_AI_MODE="ZHIPU" \
--env HOME="$PWD"
Note: Replace your-key with the actual Zhipu API Key.HOME Set the environment variable to the current working directory to avoid log file permission issues.
Step 5: Test the connection
mcporter list
Confirm that the glm-vision server has been added successfully.
Step 6: Use MCP to process images
6.1 Prepare the image
Place the image in an accessible path, for example:
~/.openclaw/workspace/images/图片名.jpg- Or use a URL
6.2 Use mcporter to call the MCP tool
Use mcporter to call the MCP service:
mcporter call glm-vision.analyze_image prompt="<对图片的提问>" image_source="<图片路径或URL>"
Example:
# 描述图片内容
mcporter call glm-vision.analyze_image prompt="详细描述这张图片的内容" image_source="~/image.jpg"
# 使用 URL
mcporter call glm-vision.analyze_image prompt="这张图片展示了什么?" image_source="https://example.com/image.jpg"
# 提取图片中的文字
mcporter call glm-vision.extract_text_from_screenshot image_source="~/screenshot.png"
# 诊断错误截图
mcporter call glm-vision.diagnose_error_screenshot prompt="分析这个错误" image_source="~/error.png"
6.3 API parameter description
| Parameter | Description | Type |
|---|---|---|
| image_source | Image path or URL | string (required) |
| prompt | Question about the image | string (required) |
Supported tools
Important note: If any issues arise, the official documentation shall prevail Official documentation: https://docs.bigmodel.cn/cn/coding-plan/mcp/vision-mcp-server
The GLM Vision MCP server provides the following tools:
ui_to_artifact- Convert UI screenshots into code, prompts, design specifications, or natural language descriptionsextract_text_from_screenshot- Use advanced OCR capabilities to extract and recognize text from screenshotsdiagnose_error_screenshot- Parse error pop-ups, stack traces, and log screenshots, and provide localization and repair suggestionsunderstand_technical_diagram- Generate structured interpretations for technical diagrams such as architecture diagrams, flowcharts, UML, and ER diagramsanalyze_data_visualization- Read dashboards and statistical charts, and extract trends, anomalies, and business pointsui_diff_check- Compare two UI screenshots to identify visual differences and implementation deviationsanalyze_image- General image understanding capabilities, suitable for visual content not covered by specialized toolsvideo_analysis- Support video scene analysis in formats such as MP4/MOV/M4V, capturing key frames, events, and key points
MCP configuration
MCP server name:glm-vision
MCP server configuration:@z_ai/mcp-server
Environment variables:
Z_AI_API_KEY- Zhipu API Key (required)Z_AI_MODE- Service platform selection, default isZHIPU