glm-vision-mcp

glm-vision-mcp

An MCP server that leverages Zhipu's free GLM-4.6V-Flash vision model to enable image, video, and file understanding (OCR, table parsing, defect detection, document Q&A, and more) across MCP-compatible clients like Codex and Claude Desktop.

Category
Visit Server

README

glm-vision-mcp

自建的 MCP(Model Context Protocol)服务器,底层调用智谱免费视觉模型 GLM-4.6V-Flash(glm-4.6v-flash,OpenAI 兼容接口)。任何支持 MCP 的客户端(Codex、Claude Desktop 等)都可以直接调用图片/视频/文件理解能力。

⚠️ 隐私与安全:调用本服务器时,图片、视频、PDF/Word 等文件的完整内容会发送到智谱云端处理。请勿上传身份证、银行卡、合同、内部办公文件等涉密资料;普通截图、公开文档可正常使用。API Key 只放在本地 .env(已被 .gitignore 排除),切勿提交到仓库。

详细安装、配置、注册与使用示例见 USAGE.md。

功能

工具 用途
analyze_image 单张或多张图片理解:OCR、复杂表格解析、内容理解、缺陷检测、Image2Prompt 等
analyze_video 视频内容理解、关键帧描述、时间线生成
analyze_file PDF / TXT / Word 等文档问答、对比、关键信息抽取
check_config 检查 API Key、模型、接口地址是否就绪

支持本地文件路径(自动转成 data URI)、http(s) URL、data URI;支持思考模式开关(enabled / disabled / auto)。

调用前会自动做本地校验:文件大小(图片 20 MB / 视频 500 MB / 文件 50 MB)、图片分辨率(上限 5000 万像素)、加密 PDF、视频时长(30 分钟,需本机有 ffprobe)。超限会在上传前直接给出中文提示,不浪费请求。

快速开始

  1. 到 智谱开放平台 注册并创建 API Key(GLM-4.6V-Flash 免费)。

  2. 复制 .env.example 为 .env,填入你的 Key:

    ZHIPU_API_KEY=你的_API_KEY
    
  3. 安装依赖并启动:

    python -m venv .venv
    .venv\Scripts\python.exe -m pip install -r requirements.txt
    .venv\Scripts\python.exe server.py
    

    也可以直接双击 run.bat(自动建虚拟环境、装依赖、启动)。

  4. 自检(不需要 Key):

    .venv\Scripts\python.exe tests\smoke_test.py
    

    正常会输出可用工具列表。

注册到 MCP 客户端

核心就是让客户端用以下命令拉起本服务器:

command: <项目绝对路径>\.venv\Scripts\python.exe
args:    ["<项目绝对路径>\\server.py"]

Codex CLI(~/.codex/config.toml)

[mcp_servers.glm-vision]
command = "C:\\path\\to\\glm-vision-mcp\\.venv\\Scripts\\python.exe"
args = ["C:\\path\\to\\glm-vision-mcp\\server.py"]
cwd = "C:\\path\\to\\glm-vision-mcp"

Codex 桌面版

在「设置 → MCP 服务器」中新增一条,command 填 .venv\Scripts\python.exe 的绝对路径,args 填 server.py 的绝对路径。

Claude Desktop(claude_desktop_config.json)

{
  "mcpServers": {
    "glm-vision": {
      "command": "C:\\path\\to\\glm-vision-mcp\\.venv\\Scripts\\python.exe",
      "args": ["C:\\path\\to\\glm-vision-mcp\\server.py"]
    }
  }
}

API Key 放在项目 .env 里即可,客户端进程会自动读取,不需要写进客户端配置。

可选配置

通过环境变量或 .env 覆盖:

GLM_BASE_URL=https://open.bigmodel.cn/api/paas/v4
GLM_MODEL=glm-4.6v-flash

常用问题

  • API Key 无效或已过期(401/403):检查 ZHIPU_API_KEY 配置,去智谱平台重新生成。
  • 余额或免费额度不足(402):到智谱开放平台查看账户额度。
  • 限流/访问量过大(429/1305):免费模型高峰期常见,服务器会自动重试,仍失败请稍后再试。
  • 内容过大(413):本地前置校验已拦截大部分超限文件;仍出现请进一步压缩。
  • 服务端故障(5xx):智谱服务暂时不可用,稍后重试。
  • “未配置 API Key”:.env 没创建,或变量名不是 ZHIPU_API_KEY。
  • 不支持同时输入:GLM-4.6V-Flash 不允许图片、视频、文件混用,一次调用只传一种类型。
  • 启动后无输出:stdio 模式下服务器静默等待客户端连接,属正常现象。

测试

rem 单元测试(请求构造、图片编码、响应解析,mock 方式,不需要 Key)
.venv\Scripts\python.exe -m unittest discover -s tests -v

rem MCP 握手测试(启动 stdio 服务器并列出工具,不需要 Key)
.venv\Scripts\python.exe tests\smoke_test.py

rem 真实调用测试(需要 .env 里有 Key,会自动重试限流)
.venv\Scripts\python.exe tests\live_test.py <你的图片路径>

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured