Skip to main content
Glama

auto_analyze_image

Analyze images to extract and interpret code, architecture, errors, or documentation using file paths or clipboard input for targeted insights.

Instructions

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

Input Schema

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

Implementation Reference

  • The primary handler function that implements the tool logic: supports image input from file path, URL, or clipboard; processes and analyzes the image using GLMService; returns structured analysis result with source info.
    async autoGetAndAnalyzeImage( imagePath?: string, focusArea: 'code' | 'architecture' | 'error' | 'documentation' = 'code' ): Promise<ImageAnalysisResult & { source: string }> { try { logger.info('开始自动获取图片', { imagePath, focusArea }); let source: string; let finalImagePath: string; if (imagePath) { // 检查是否为网络URL if (this.isUrl(imagePath)) { source = 'url'; finalImagePath = await this.downloadImageFromUrl(imagePath); logger.info('从网络URL下载图片', { url: imagePath, path: finalImagePath }); } else { // 如果提供了文件路径,直接使用 source = 'file'; finalImagePath = imagePath; // 验证文件是否存在 if (!(await this.fileExists(finalImagePath))) { throw new Error(`文件不存在: ${imagePath}`); } logger.info('使用提供的文件路径', { path: finalImagePath }); } } else { // 如果没有提供文件路径,尝试从剪贴板获取 source = 'clipboard'; const clipboardImage = await this.getImageFromClipboard(); if (!clipboardImage) { throw new Error('无法获取图片:没有提供文件路径且剪贴板中没有图片'); } finalImagePath = clipboardImage; logger.info('从剪贴板获取图片', { path: finalImagePath }); } // 分析图片 const result = await this.analyzeImageFile(finalImagePath, focusArea); // 如果是剪贴板或URL下载的图片,清理临时文件 if (source === 'clipboard' || source === 'url') { await this.cleanupTempFile(finalImagePath); } return { ...result, source, }; } catch (error) { logger.error('自动获取并分析图片失败', { error }); throw new Error(`自动处理图片失败: ${error instanceof Error ? error.message : '未知错误'}`); } }
  • Input schema definition for the 'auto_analyze_image' tool, including parameters for imagePath (optional) and focusArea.
    { name: 'auto_analyze_image', description: '自动获取并分析图片(支持文件路径、网络URL或剪贴板)', inputSchema: { type: 'object', properties: { imagePath: { type: 'string', description: '图片文件路径或网络URL(可选,不提供则使用剪贴板)', }, focusArea: { type: 'string', enum: ['code', 'architecture', 'error', 'documentation'], description: '分析重点区域', default: 'code', }, }, required: [], }, },
  • src/index.ts:40-65 (registration)
    Tool registration in the ListToolsRequestHandler, exposing the tool to MCP clients.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: 'auto_analyze_image', description: '自动获取并分析图片(支持文件路径、网络URL或剪贴板)', inputSchema: { type: 'object', properties: { imagePath: { type: 'string', description: '图片文件路径或网络URL(可选,不提供则使用剪贴板)', }, focusArea: { type: 'string', enum: ['code', 'architecture', 'error', 'documentation'], description: '分析重点区域', default: 'code', }, }, required: [], }, }, ], }; });
  • src/index.ts:76-81 (registration)
    Dispatch logic in CallToolRequestHandler that routes calls to the AutoImageService handler.
    if (name === 'auto_analyze_image') { result = await this.autoImageService.autoGetAndAnalyzeImage( typedArgs.imagePath, typedArgs.focusArea || 'code' ); } else {
  • TypeScript interface defining the structure of the image analysis result returned by the tool.
    export interface ImageAnalysisResult { description?: string; content?: string; type?: string; layout?: string; issues?: string[]; details?: string; summary: string; confidence: number; metadata?: { format?: string; width?: number; height?: number; fileSize?: string; }; }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lengbone/mcp-vl'

If you have feedback or need assistance with the MCP directory API, please join our Discord server