Skip to main content
Glama

analyze_logo

Analyze website logos to extract dimensions, format, quality, and other details, with an option to return only the best logo URL for immediate use.

Instructions

分析Logo的基本信息(尺寸、格式、质量等),支持onlyBestUrl参数只返回最佳Logo的URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes要分析的网站URL
onlyBestUrlNo是否只返回最佳Logo的URL,默认为false

Implementation Reference

  • Core handler implementation for logo analysis: fetches HTML, extracts candidates from favicon, apple-touch-icon, og:image, CSS classes, brand images; validates, scores based on type/dimensions/aspect ratio, selects best candidate.
    async analyzeLogo(url: string): Promise<LogoAnalysis> {
      const startTime = Date.now();
      const analysis: LogoAnalysis = {
        url,
        candidates: [],
        extractionTime: 0,
        status: 'failed',
      };
    
      try {
        // 标准化URL
        const normalizedUrl = this.normalizeUrl(url);
        
        // 获取网页内容
        const html = await this.fetchHtml(normalizedUrl);
        const $ = cheerio.load(html);
        const baseUrl = this.getBaseUrl(normalizedUrl);
    
        // 提取各种类型的Logo候选
        const candidates: LogoCandidate[] = [];
    
        // 1. 提取favicon
        await this.extractFavicons($, baseUrl, candidates);
    
        // 2. 提取Apple Touch图标
        await this.extractAppleTouchIcons($, baseUrl, candidates);
    
        // 3. 提取OpenGraph图像
        await this.extractOpenGraphImages($, baseUrl, candidates);
    
        // 4. 提取通过CSS类名识别的Logo
        await this.extractLogoByClass($, baseUrl, candidates);
    
        // 5. 提取品牌相关图像
        await this.extractBrandImages($, baseUrl, candidates);
    
        // 过滤和评分候选Logo
        analysis.candidates = await this.filterAndScoreCandidates(candidates);
        
        // 选择最佳候选
        analysis.bestCandidate = this.selectBestCandidate(analysis.candidates);
        
        analysis.status = analysis.bestCandidate ? 'success' : 'no-logo';
        analysis.extractionTime = Date.now() - startTime;
    
        return analysis;
      } catch (error) {
        console.error('Logo分析失败:', error);
        analysis.extractionTime = Date.now() - startTime;
        return analysis;
      }
    }
  • MCP protocol handler for 'analyze_logo' tool: parses arguments, calls core analyzeLogo, handles onlyBestUrl option, returns formatted text response or error.
    private async handleAnalyzeLogo(args: any) {
      const { url, onlyBestUrl = false } = args;
      
      const analysis = await this.logoExtractor.analyzeLogo(url);
      
      if (onlyBestUrl) {
        // 只返回最佳Logo URL
        if (analysis.status === 'failed' || !analysis.bestCandidate) {
          return {
            content: [
              {
                type: 'text',
                text: `无法从 ${url} 找到Logo。请检查网站是否存在Logo或网络连接是否正常。`,
              },
            ],
          };
        }
        
        return {
          content: [
            {
              type: 'text',
              text: analysis.bestCandidate.url,
            },
          ],
        };
      } else {
        // 返回完整分析结果
        return {
          content: [
            {
              type: 'text',
              text: `Logo分析结果:\n${JSON.stringify(analysis, null, 2)}`,
            },
          ],
        };
      }
    }
  • src/index.ts:64-82 (registration)
    Registration of 'analyze_logo' tool in ListToolsRequestHandler, including name, description, and input schema.
    {
      name: 'analyze_logo',
      description: '分析Logo的基本信息(尺寸、格式、质量等),支持onlyBestUrl参数只返回最佳Logo的URL',
      inputSchema: {
        type: 'object',
        properties: {
          url: {
            type: 'string',
            description: '要分析的网站URL',
          },
          onlyBestUrl: {
            type: 'boolean',
            description: '是否只返回最佳Logo的URL,默认为false',
            default: false,
          },
        },
        required: ['url'],
      },
    },
  • TypeScript interfaces defining the structure of logo candidates and analysis results used by the tool.
    export interface LogoCandidate {
      url: string;
      type: 'favicon' | 'apple-touch-icon' | 'og:image' | 'logo-class' | 'brand-image';
      size?: { width: number; height: number };
      score: number; // 评分,用于选择最佳Logo
    }
    
    export interface LogoAnalysis {
      url: string;
      candidates: LogoCandidate[];
      bestCandidate?: LogoCandidate;
      extractionTime: number;
      status: 'success' | 'failed' | 'no-logo';
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the 'onlyBestUrl' parameter behavior but doesn't describe what happens when it's false (presumably returns full analysis), what 'best' means, potential rate limits, authentication requirements, error conditions, or output format. The description provides minimal behavioral context beyond basic functionality.

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 appropriately concise with two clear clauses: the main purpose statement and the parameter support explanation. It's front-loaded with the core functionality. However, the second clause could be slightly more integrated with the main purpose rather than appearing as an addendum.

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 no annotations, no output schema, and a tool that performs analysis (potentially complex processing), the description is insufficient. It doesn't explain what the analysis returns, what metrics are evaluated, how 'quality' is determined, or what happens when analysis fails. For an analysis tool with no structured output documentation, this leaves significant gaps.

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 minimal value beyond the schema by mentioning the 'onlyBestUrl' parameter, but doesn't provide additional semantic context about what 'best' means or how the analysis is performed. Baseline 3 is appropriate when schema does the heavy lifting.

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: '分析Logo的基本信息(尺寸、格式、质量等)' (analyze logo's basic information including dimensions, format, quality, etc.). It specifies the verb 'analyze' and resource 'logo', but doesn't explicitly differentiate from sibling tool 'get_best_logo_url' beyond mentioning the 'onlyBestUrl' parameter.

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 context through the 'onlyBestUrl' parameter explanation ('支持onlyBestUrl参数只返回最佳Logo的URL' - supports onlyBestUrl parameter to return only the best logo URL). However, it doesn't provide explicit guidance on when to use this tool versus the sibling 'get_best_logo_url' or any other alternatives, leaving the relationship ambiguous.

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

Install Server

Other 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/OnePieceLwc/logo-mcp'

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