Skip to main content
Glama
lengbone

MCP Visual Language

by lengbone

MCP 自动图片分析服务器

基于 GLM-4.5V 模型的 MCP (Model Context Protocol) 服务器,提供智能图片分析功能,支持文件路径和剪贴板两种输入方式。

功能特性

  • 🤖 智能获取: 自动从文件路径或剪贴板获取图片

  • 💻 代码内容提取: 从图片中提取代码文本

  • 🏗️ 架构分析: 分析代码的结构和设计模式

  • 🐛 错误检测: 识别代码中的错误和问题

  • 📚 文档生成: 自动生成代码文档

  • 🔍 语言识别: 自动识别编程语言

  • 🎯 专注代码: 专门优化用于代码图片分析

Related MCP server: glm-vision-mcp-server

技术栈

  • 运行时: Node.js 18+

  • 框架: TypeScript

  • 模型: GLM-4.5V (智谱 AI)

  • 图片处理: Sharp

  • 协议: MCP (Model Context Protocol)

安装配置

1. 安装依赖

pnpm install

2. 配置环境变量

复制 .env.example.env 并填入配置:

cp .env.example .env

编辑 .env 文件:

# 智谱 AI API 配置
ZHIPUAI_API_KEY=your_zhipuai_api_key_here
ZHIPUAI_BASE_URL=https://open.bigmodel.cn/api/paas/v4

# MCP 服务器配置
MCP_SERVER_NAME=mcp-vl
MCP_SERVER_VERSION=1.0.0

# 日志级别
LOG_LEVEL=info

3. 获取智谱 AI API Key

  1. 访问 智谱 AI 开放平台

  2. 注册账号并创建 API Key

  3. 将 API Key 填入 .env 文件

4. 构建项目

pnpm run build

使用方法

在 Claude Code 中配置

方式一:使用 claude mcp add 命令(推荐)

构建项目后,使用以下命令添加 MCP 服务器:

claude mcp add mcp-vl --scope user --env ZHIPUAI_API_KEY=your_api_key_here \
    -- node /path/mcp-vl/dist/index.js

方式二:手动配置

将以下配置添加到你的 Claude Code 配置中:

{
  "mcpServers": {
    "mcp-vl": {
      "command": "node",
      "args": ["/path/mcp-vl/dist/index.js"],
      "env": {
        "ZHIPUAI_API_KEY": "your_api_key_here"
      }
    }
  }
}

Claude 提示词

## ⚠️ 图片处理规范 - 非常重要,一定要严格执行
**重要提示:在 Claude 中使用时,禁止使用 read 工具进行读取图片,因为读取图片工具失效了。请使用 mcp-vl 里的 auto_analyze_image 工具进行读取。**

可用工具

auto_analyze_image

自动获取并分析图片(支持文件路径或剪贴板)

{
  "name": "auto_analyze_image",
  "arguments": {
    "imagePath": "/path/to/image.png", // 可选,不提供则使用剪贴板
    "focusArea": "code" // "code", "architecture", "error", "documentation"
  }
}

使用方式:

  1. 文件路径: 提供图片文件路径进行分析

  2. 剪贴板: 不提供路径,自动从剪贴板获取图片

分析类型说明:

  • code: 提取代码内容,识别编程语言,分析代码结构

  • architecture: 分析代码架构设计,模块关系,设计模式

  • error: 检查代码错误,性能问题,安全隐患

  • documentation: 生成代码文档,函数说明,使用示例

开发

开发模式运行

pnpm run dev

构建项目

pnpm run build

代码检查

pnpm run lint
pnpm run typecheck

项目结构

src/
├── index.ts              # MCP 服务器主入口
├── config/
│   └── index.ts         # 配置管理
├── services/
│   ├── glm-service.ts   # GLM 模型服务
│   └── auto-image-service.ts # 自动图片分析服务
├── types/
│   └── index.ts         # TypeScript 类型定义
└── utils/
    └── logger.ts        # 日志工具
scripts/
└── test-local.ts        # 本地测试脚本

注意事项

  1. API Key 安全: 请妥善保管你的智谱 AI API Key

  2. 代码图片优化: 专门针对代码截图优化,建议使用清晰的代码截图

  3. 支持格式: JPEG, PNG, WebP, GIF 等常见格式

  4. 网络连接: 需要稳定的网络连接访问智谱 AI API

  5. 最佳实践:

    • 使用高对比度的代码编辑器主题

    • 确保代码字体清晰可见

    • 避免截图过大或过小

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

Available Tools

1 tool
auto_analyze_imageB

自动获取并分析图片(支持文件路径、网络URL或剪贴板)

ParametersJSON Schema
NameRequiredDescriptionDefault
imagePathNo图片文件路径或网络URL(可选,不提供则使用剪贴板)
focusAreaNo分析重点区域code

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions '自动获取并分析' (automatically acquire and analyze), which implies some automation and processing, but does not describe what '分析' (analyze) entails (e.g., what kind of analysis is performed, output format, potential rate limits, or authentication needs). This leaves significant gaps in understanding the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose ('自动获取并分析图片') and includes essential details (input sources) without unnecessary elaboration. It is appropriately sized for the tool's complexity, though it could be slightly more structured (e.g., by separating purpose from usage hints).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (image analysis tool with automation), no annotations, and no output schema, the description is incomplete. It does not explain what the analysis returns, how results are formatted, or any behavioral traits like error handling or performance characteristics. This makes it inadequate for an agent to fully understand the tool's context and usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds marginal value by mentioning the three input sources (file path, network URL, clipboard) for the 'imagePath' parameter, but this is largely redundant with the schema's description. It does not provide additional meaning beyond the schema, so the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: '自动获取并分析图片' (automatically acquire and analyze images). It specifies the verb '获取并分析' (acquire and analyze) and the resource '图片' (images), and mentions three input sources (file path, network URL, or clipboard). However, without sibling tools, we cannot assess differentiation, so it cannot receive a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by listing supported input sources (file path, network URL, clipboard), suggesting when to use it based on available image data. However, it lacks explicit guidance on when to use this tool versus alternatives (e.g., other image analysis tools), prerequisites, or exclusions. With no sibling tools, this is adequate but not comprehensive.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 1 tool updatev1.0.0
    • Changedauto_analyze_image1 field changed
      • changedInput schema / properties / imagePath / description
        Previous value: -"图片文件路径(可选,不提供则使用剪贴板)"New value: +"图片文件路径或网络URL(可选,不提供则使用剪贴板)"
  2. 1 tool update
    • First observedauto_analyze_image

TDQS

B3.2/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of ambiguity or overlap between tools. The tool's purpose is clearly defined as analyzing images from various sources, leaving no room for confusion or misselection.

Naming Consistency5/5

Since there is only one tool, naming consistency is inherently perfect. The tool name 'auto_analyze_image' follows a clear verb_noun pattern, and there are no other tools to compare it against for inconsistency.

Tool Count2/5

A single tool is generally too few for most server purposes, as it limits functionality and flexibility. While the tool itself might be useful, the server's scope appears thin, lacking complementary operations like image editing, filtering, or metadata extraction that would enhance coherence.

Completeness2/5

The server is severely incomplete for a visual language domain. It only provides analysis, missing essential operations such as image generation, transformation, annotation, or comparison. This gap will likely cause agent failures when broader image-related tasks are required.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers