Skip to main content
Glama

English · 中文


Features

Feature

Description

8 tools, same names

Identical tool names and parameter schemas as @z_ai/mcp-server — no prompt changes needed

Next-gen model by default

Uses glm-5v-turbo — improved accuracy and reasoning over the official glm-4.6v

Smart retry

429 / 5xx / network errors retried with exponential backoff; 4xx fails immediately — saves quota

Local result cache

LRU memory cache + optional disk persistence; same image + prompt skips the API call

.env support

dotenv loads your key from .env — no need to pass it through environment variables in development

Extended formats

Images: jpg, png, webp, gif, bmp, tiff. Video: mp4, mov, m4v, avi, mkv, webm, flv

Related MCP server: glm-vision

Quick Start

# 1. Copy and edit .env
cp .env.example .env
# Set Z_AI_API_KEY=your_coding_plan_key

# 2. Add to your MCP client
claude mcp add glm-vision-mcp \
  --env Z_AI_API_KEY=YOUR_KEY \
  -- npx -y glm-vision-mcp

Usage

The server exposes 8 vision tools through stdio. Your MCP client handles tool discovery and invocation automatically.

Claude Code

claude mcp add glm-vision-mcp \
  --env Z_AI_API_KEY=YOUR_KEY \
  -- npx -y glm-vision-mcp

OpenCode

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "glm-vision-mcp": {
      "type": "local",
      "command": ["npx", "-y", "glm-vision-mcp"],
      "environment": { "Z_AI_API_KEY": "YOUR_KEY", "Z_AI_MODE": "ZHIPU" }
    }
  }
}

Cline / Roo Code

{
  "mcpServers": {
    "glm-vision-mcp": {
      "command": "npx",
      "args": ["-y", "glm-vision-mcp"],
      "env": { "Z_AI_API_KEY": "YOUR_KEY", "Z_AI_MODE": "ZHIPU" }
    }
  }
}

Architecture

flowchart LR
    Client["MCP Client\n(Claude Code / OpenCode / Cline)"]
    Server["glm-vision-mcp\n(stdio transport)"]
    Cache["Result Cache\n(LRU + disk)"]
    Vision["VisionService\n(unified handler)"]
    Chat["ChatService\n(retry + backoff)"]
    API["GLM Vision API\n(ZHIPU / ZAI)"]

    Client --> Server
    Server --> Cache
    Cache -->|"miss"| Vision
    Cache -->|"hit"| Server
    Vision --> Chat
    Chat --> API
    API --> Vision

Configuration

Variable

Default

Description

Z_AI_API_KEY

Required

Zhipu API key (Coding Plan key or pay-as-you-go key)

ZAI_MCP_API_KEY

—

Fallback alias (auto-mapped)

Z_AI_MODE

ZHIPU

Endpoint mode — see Billing Modes

Z_AI_VISION_MODEL

glm-5v-turbo

Vision model ID

Z_AI_VISION_MODEL_TEMPERATURE

0.8

Sampling temperature

Z_AI_VISION_MODEL_TOP_P

0.6

Nucleus sampling

Z_AI_VISION_MODEL_MAX_TOKENS

32768

Max output tokens

Z_AI_TIMEOUT

300000

Request timeout (ms)

Z_AI_RETRY_COUNT

2

Max retries (retryable errors only)

GLM_VISION_CACHE

true

Enable result caching

GLM_VISION_CACHE_TTL

604800

Cache TTL in seconds (7 days)

GLM_VISION_CACHE_MAX

100

Max LRU cache entries

GLM_IMAGE_MAX_SIZE_MB

5

Max image file size

GLM_VIDEO_MAX_SIZE_MB

8

Max video file size

Billing Modes

Choose the endpoint via Z_AI_MODE:

Z_AI_MODE

Endpoint

Billing

ZHIPU (default)

https://open.bigmodel.cn/api/coding/paas/v4/

GLM Coding Plan subscription quota

ZHIPU_API

https://open.bigmodel.cn/api/paas/v4/chat/completions

Pay-as-you-go API billing

ZAI

https://api.z.ai/api/paas/v4/

International z.ai platform

Use the key that matches your billing plan: a Coding Plan key with ZHIPU, or a pay-as-you-go API key with ZHIPU_API.

Directory Structure

src/
├── core/              # Environment, chat, vision, file, cache services
│   ├── environment.ts   # Dotenv + multi-endpoint + key fallback
│   ├── chat-service.ts  # GLM API calls with smart retry
│   ├── vision-service.ts  # Unified analysis orchestration
│   ├── file-service.ts  # Validation, base64 encoding, fingerprinting
│   └── cache.ts         # LRU + disk cache
├── tools/
│   ├── definitions.ts   # 8-tool data-driven definitions
│   └── registry.ts      # Tool registration on MCP server
├── prompts/             # 8 specialized system prompts
├── types/               # Error type hierarchy
└── utils/               # Logger, sanitization, validation
tests/
scripts/
  └── smoke.ts           # End-to-end verification with real key

Tech Stack

Layer

Technology

Runtime

Node.js ≥ 18

Language

TypeScript 5

Protocol

@modelcontextprotocol/sdk

Validation

Zod

Config

dotenv

Build

TypeScript compiler (tsc)

Dev

tsx (hot-reload), vitest (64 tests)

Contributing

Fork → branch → commit → open a pull request. Run npm test before pushing.

License

Released under the MIT License.

Available Tools

8 tools
analyze_data_visualizationA

阅读仪表盘、统计图表,提炼趋势、异常与业务要点。

仅在用户需要以下操作时使用:

  • 从图表提取洞察

  • 识别趋势与模式

  • 检测异常值

  • 提供业务影响分析

不要用于:技术架构图、UI 截图、错误诊断。

Inputs: prompt (required), image_source (required), analysis_focus.

analyze_imageA

通用图像理解能力,适配未被专项工具覆盖的视觉内容。

仅在用户需要以下操作时使用:

  • 当专项工具(UI/OCR/错误/图表/数据可视化/视频)都不适用时

  • 灵活理解任何视觉内容

  • 全面的图像描述和分析

这是兜底工具,优先使用更专业的工具。

Inputs: prompt (required), image_source (required).

analyze_videoA

使用 AI 视觉模型分析视频内容。

仅在用户需要以下操作时使用:

  • 理解视频中发生了什么

  • 提取关键时刻或动作

  • 分析视频内容、场景或序列

  • 识别视频中的对象、人物或活动

支持本地文件与远程 URL,最大 8MB,支持 MP4/MOV/M4V 等格式。

Inputs: prompt (required), video_source (required).

diagnose_error_screenshotA

解析错误弹窗、堆栈跟踪和日志截图,给出定位与修复建议。

仅在用户需要以下操作时使用:

  • 分析错误消息和堆栈跟踪

  • 定位根本原因

  • 提供可操作的修复方案

不要用于:提取代码、UI 分析、图表解读。

Inputs: prompt (required), image_source (required), context.

extract_text_from_screenshotA

使用 OCR 从截图中提取和识别文字。专门用于代码、终端输出、文档和通用文本提取。

仅在用户需要以下操作时使用:

  • 从截图提取代码(保持正确缩进与格式)

  • 提取终端输出和日志

  • 提取文档和文本内容

不要用于:UI 转 code、错误诊断、图表分析。

Inputs: prompt (required), image_source (required), programming_language.

ui_diff_checkA

对比两张 UI 截图,识别视觉差异和实现偏差。专门用于 UI 质量保证和设计到实现的验证。

仅在用户需要以下操作时使用:

  • 比较预期 UI 与实际实现

  • 识别视觉差异

  • 提供详细差异报告

  • 按严重程度排列问题优先级

需要两张图:预期/参考图 与 实际/当前图。

Inputs: prompt (required), actual_image_source (required), expected_image_source (required).

ui_to_artifactA

将 UI 截图转换为代码、提示词、设计规范或自然语言描述。

仅在用户需要以下操作时使用:

  • 从 UI 设计生成前端代码(output_type='code')

  • 创建用于 UI 复刻的 AI 提示词(output_type='prompt')

  • 提取设计规范文档(output_type='spec')

  • 获取 UI 的自然语言描述(output_type='description')

不要用于:需提取的文字/代码、错误信息、技术图表、数据可视化。

Inputs: prompt (required), output_type (required), image_source (required).

understand_technical_diagramA

分析技术图表并生成结构化解读,覆盖架构图、流程图、UML、ER 图、序列图等。

仅在用户需要以下操作时使用:

  • 分析架构图

  • 理解流程图与 UML 图

  • 解释 ER 图与序列图

  • 识别设计模式

不要用于:UI 截图、错误消息、数据可视化图表。

Inputs: prompt (required), image_source (required), diagram_type.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.3/5.0

    Scored across 8 tools

    Disambiguation5/5

    Each tool targets a distinct visual input type (UI, text, error, diagram, data viz, diff, generic, video) with explicit 'do not use for' boundaries. The generic analyze_image is clearly positioned as a fallback, preventing overlap with specialized tools.

    Naming Consistency4/5

    All names use snake_case, but verb-first pattern is inconsistent: ui_to_artifact and ui_diff_check are noun-first while others are verb-first. Still, the style is uniform and readable.

    Tool Count5/5

    8 tools is well-scoped for a vision analysis server, covering major categories of visual understanding without unnecessary bloat.

    Completeness5/5

    The tool surface covers UI conversion, OCR, error diagnosis, diagrams, data visualization, diff checking, generic image analysis, and video analysis—a comprehensive set for the domain. The fallback analyze_image ensures no dead ends.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers