Skip to main content
Glama

GLM Vision MCP

一个基于 TypeScript 的 MCP 服务,将视觉模型接口封装为 AI 客户端可以调用的工具。支持本地图片、远程媒体、OCR,以及视频与文件分析请求。

工程重点: stdio 协议集成、媒体输入转换、参数校验、请求超时与结构化错误返回。

flowchart LR
  Client[支持 MCP 的客户端] -->|stdio| Server[GLM Vision MCP]
  Server --> Input[本地文件或 URL]
  Server -->|HTTPS| Model[视觉模型接口]
  Model --> Server
  Server --> Client

工具

名称

功能

analyze_image

单图理解与自定义提问

analyze_images

最多 6 张图片的对比分析

ocr_image

提取图片文字

analyze_video

提交视频分析请求

analyze_file

提交 PDF 或其他文件的分析请求

媒体类型能否被处理、输入大小及输出质量取决于所配置的模型接口。文件与视频支持尚需针对具体提供商验证。

Related MCP server: dsh-vision

本地运行

需要 Node.js 22 或更新版本。

npm ci
npm run build
npm test

在 MCP 客户端中配置以下示例,将路径改为本机绝对路径,将 Key 放在自己的本地配置中:

{
  "mcpServers": {
    "glm-vision": {
      "command": "node",
      "args": ["/absolute/path/mcp-glm-vision/dist/index.js"],
      "env": {
        "ZHIPU_API_KEY": "your-api-key"
      }
    }
  }
}

环境变量:ZHIPU_API_KEY(必需)、GLM_MODEL、GLM_API_URL、GLM_TIMEOUT_MS。默认模型为 glm-4.6v-flash,默认超时为 120 秒。额度和价格以提供商当前说明为准。

.env 文件不会被服务自动加载。直接调试时可以使用 Node 的 --env-file:

node --env-file=.env scripts/demo.js test-assets/test.png "请描述图片"

关键实现

  • src/index.ts:工具声明、请求分发与参数检查。

  • src/glm.ts:本地文件转 data URL、媒体消息构造、HTTP 请求与超时处理。

  • scripts/test-server.js:启动子进程,验证初始化、工具发现和缺少 Key 的错误路径。

本地文件会读取并编码后发送到模型提供商;仅应输入你有权处理的文件。本地大文件在编码后超过限制时会返回错误。当前 HTTP 超时覆盖等待响应头的阶段,尚未覆盖响应体读取全过程。

验证范围

协议冒烟测试与 TypeScript 构建不需要 API Key。示例测试图片为 1×1 像素,只用于请求链路测试,不能作为识别效果评估。真实模型输出没有包含在自动化测试结果中。

来源与署名见 SOURCE_AND_CREDITS.md。

Available Tools

5 tools
analyze_fileA

用 GLM-4.6V-Flash 分析文件(PDF/文档等,本地路径会自动转成 data URL)。

Inputs: source (required), prompt.

analyze_imageA

用 GLM-4.6V-Flash(免费视觉模型)分析单张图片。source 可以是本地路径或 http(s) 图片 URL。

Inputs: source (required), prompt, thinking.

analyze_imagesA

用 GLM-4.6V-Flash 同时分析多张图片(按顺序传入,2~6 张为宜)。本地路径或 URL 均可。

Inputs: sources (required), prompt.

analyze_videoB

用 GLM-4.6V-Flash 分析视频(建议用公网可访问的 URL,如 mp4)。

Inputs: source (required), prompt.

ocr_imageB

OCR:识别图片中的文字(适合截图、票据、书页等)。

Inputs: source (required), prompt.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 5 tools

    Disambiguation3/5

    The four analyze_* tools are separated only by input modality (image, images, video, file), and analyze_image vs analyze_images differs only in count, which invites misselection. ocr_image is clearly distinct. Descriptions help somewhat, but an agent could easily pick analyze_images for a single image or analyze_file for an image file.

    Naming Consistency5/5

    All tools follow a consistent verb_noun snake_case pattern (analyze_image, analyze_images, analyze_video, analyze_file, ocr_image). The naming is predictable and readable throughout.

    Tool Count4/5

    Five tools is a reasonable, well-scoped set for a vision analysis server. It is slightly thin—analyze_image and analyze_images could arguably be merged into one tool with a list parameter—but no tool is superfluous.

    Completeness4/5

    The surface covers the main modalities: single image, multiple images, video, document, and OCR. Minor gaps remain (no batch OCR, no video-from-local-path handling, no result caching/follow-up operations), but core vision workflows are covered.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables image analysis via OpenAI-compatible vision APIs, supporting local files, URLs, and base64 inputs with intelligent tiling for high-resolution images. Provides a secure, configurable MCP stdio server for structured vision analysis.
      110 npm
      3
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Provides a unified image-understanding tool for AI assistants without native vision, letting them analyze screenshots, error messages, UI layouts, and documents via multiple vision LLM providers. It supports local files, remote URLs, Data URIs, OCR, multi-crop processing, and standard MCP clients.
      473 npm
      MIT