Skip to main content
Glama

analyze_logo_candidates

Analyzes all logo candidates on a website to identify and extract logo icons, providing detailed information for each candidate.

Instructions

分析网站的所有Logo候选项并返回详细信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes要分析的网站URL

Implementation Reference

  • MCP tool handler for 'analyze_logo_candidates'. Validates input URL, extracts candidates using LogoExtractor, computes analysis with scores and recommendation, returns formatted text response.
    private async handleAnalyzeCandidates(args: any) { const { url } = args; if (!url || typeof url !== 'string') { throw new Error('请提供有效的网站URL'); } const candidates = await this.logoExtractor.extractLogoCandidates(url); if (candidates.length === 0) { return { content: [ { type: 'text', text: `未能从网站 ${url} 找到任何Logo候选项。`, }, ], }; } const analysis = { url: url, totalCandidates: candidates.length, candidates: candidates.map((candidate, index) => ({ index: index + 1, url: candidate.url, type: candidate.type, source: candidate.source, score: candidate.score, attributes: candidate.attributes, })), recommended: this.logoExtractor.selectBestLogo(candidates), }; return { content: [ { type: 'text', text: `Logo候选项分析完成!\n网站: ${url}\n找到 ${candidates.length} 个候选项\n推荐使用: ${analysis.recommended.source} (评分: ${analysis.recommended.score})`, }, { type: 'text', text: JSON.stringify(analysis, null, 2), }, ], }; }
  • src/index.ts:47-59 (registration)
    Tool registration entry in ListToolsRequestHandler, including name, description, and input schema definition.
    name: 'analyze_logo_candidates', description: '分析网站的所有Logo候选项并返回详细信息', inputSchema: { type: 'object', properties: { url: { type: 'string', description: '要分析的网站URL', }, }, required: ['url'], }, },
  • TypeScript interface defining the structure of logo candidates used in the analysis.
    export interface LogoCandidate { url: string; type: 'favicon' | 'apple-touch-icon' | 'og-image' | 'logo-image' | 'brand-image'; source: string; score: number; attributes: Record<string, any>; }
  • Primary helper method that performs web scraping to find all logo candidates from favicon links, apple icons, OG images, logo imgs, common paths; deduplicates and scores them.
    async extractLogoCandidates(websiteUrl: string): Promise<LogoCandidate[]> { try { const normalizedUrl = this.normalizeUrl(websiteUrl); const response = await axios.get(normalizedUrl, { headers: { 'User-Agent': this.userAgent }, timeout: 10000, maxRedirects: 5, }); const $ = cheerio.load(response.data); const candidates: LogoCandidate[] = []; const baseUrl = new URL(normalizedUrl); // 1. 提取favicon相关链接 await this.extractFaviconCandidates($, baseUrl, candidates); // 2. 提取Apple Touch Icon await this.extractAppleTouchIcons($, baseUrl, candidates); // 3. 提取OpenGraph图像 await this.extractOpenGraphImages($, baseUrl, candidates); // 4. 提取可能的Logo图像 await this.extractLogoImages($, baseUrl, candidates); // 5. 尝试常见的favicon路径 await this.extractCommonFaviconPaths(baseUrl, candidates); // 去重并评分 return this.deduplicateAndScore(candidates); } catch (error) { console.error(`提取Logo候选项时出错: ${error}`); return []; } }
  • Helper method to select the best logo candidate, prioritizing SVG and highest score.
    selectBestLogo(candidates: LogoCandidate[]): LogoCandidate { if (candidates.length === 0) { throw new Error('没有可用的Logo候选项'); } // 优先选择高分的SVG或高质量PNG const sortedCandidates = candidates.sort((a, b) => { // SVG格式加分 const aIsSvg = a.url.toLowerCase().includes('.svg') || a.attributes?.type?.includes('svg'); const bIsSvg = b.url.toLowerCase().includes('.svg') || b.attributes?.type?.includes('svg'); if (aIsSvg && !bIsSvg) return -1; if (!aIsSvg && bIsSvg) return 1; // 按分数排序 return b.score - a.score; }); return sortedCandidates[0]; }

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

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