Skip to main content
Glama

analyze_logo_candidates

Extract and analyze all logo candidates from a website URL to identify and return detailed information using Logo MCP's intelligent extraction system.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes要分析的网站URL

Implementation Reference

  • The primary handler function for the 'analyze_logo_candidates' tool. Validates the URL input, extracts logo candidates using LogoExtractor, assembles analysis data with candidate details and best recommendation, and returns formatted text content including a summary and JSON details.
    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), }, ], }; }
  • Input schema definition for the analyze_logo_candidates tool, specifying an object with a required 'url' string property.
    inputSchema: { type: 'object', properties: { url: { type: 'string', description: '要分析的网站URL', }, }, required: ['url'], },
  • src/index.ts:46-59 (registration)
    Registration of the 'analyze_logo_candidates' tool in the listTools response, including name, description, and input schema.
    { name: 'analyze_logo_candidates', description: '分析网站的所有Logo候选项并返回详细信息', inputSchema: { type: 'object', properties: { url: { type: 'string', description: '要分析的网站URL', }, }, required: ['url'], }, },
  • Core helper method in LogoExtractor that fetches the website, parses HTML with Cheerio, extracts potential logo candidates from various sources (favicons, apple icons, OG images, logo imgs, common paths), deduplicates, scores them, and returns sorted list. Used by the tool handler.
    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 from the list, prioritizing SVG and higher scores.
    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

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

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