Skip to main content
Glama

extract_logo

Extract logo icon URLs from website URLs to identify and retrieve brand logos automatically from any given webpage.

Instructions

从指定网站URL提取Logo图标链接

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes要提取Logo的网站URL

Implementation Reference

  • The primary handler function for the 'extract_logo' MCP tool. It validates the input URL, extracts logo candidates using LogoExtractor, selects the best one, and returns a JSON-formatted response with the logo details.
    private async handleExtractLogo(args: any) {
      const { url } = args;
    
      if (!url || typeof url !== 'string') {
        throw new Error('请提供有效的网站URL');
      }
    
      // 提取Logo候选项
      const candidates = await this.logoExtractor.extractLogoCandidates(url);
    
      if (candidates.length === 0) {
        return {
          content: [
            {
              type: 'text',
              text: `未能从网站 ${url} 找到任何Logo图标。`,
            },
          ],
        };
      }
    
      // 选择最佳Logo
      const bestLogo = this.logoExtractor.selectBestLogo(candidates);
    
      // 直接返回Logo链接信息
      const responseData = {
        message: 'Logo提取成功,已返回可直接下载的Logo链接。',
        websiteUrl: url,
        logoUrl: bestLogo.url,
        logoType: bestLogo.type,
        logoSource: bestLogo.source,
        logoScore: bestLogo.score,
      };
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(responseData, null, 2),
          },
        ],
      };
    }
  • The schema definition for the 'extract_logo' tool, specifying the required 'url' input parameter.
    {
      name: 'extract_logo',
      description: '从指定网站URL提取Logo图标链接',
      inputSchema: {
        type: 'object',
        properties: {
          url: {
            type: 'string',
            description: '要提取Logo的网站URL',
          },
        },
        required: ['url'],
      },
    },
  • src/index.ts:64-86 (registration)
    Registration of the tool call handler, which dispatches to handleExtractLogo when 'extract_logo' is called.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      try {
        switch (name) {
          case 'extract_logo':
            return await this.handleExtractLogo(args);
          case 'analyze_logo_candidates':
            return await this.handleAnalyzeCandidates(args);
          default:
            throw new Error(`未知的工具: ${name}`);
        }
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `错误: ${error instanceof Error ? error.message : '未知错误'}`,
            },
          ],
        };
      }
    });
  • src/index.ts:29-62 (registration)
    Registration in ListTools response, listing 'extract_logo' with its schema.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: 'extract_logo',
            description: '从指定网站URL提取Logo图标链接',
            inputSchema: {
              type: 'object',
              properties: {
                url: {
                  type: 'string',
                  description: '要提取Logo的网站URL',
                },
              },
              required: ['url'],
            },
          },
          {
            name: 'analyze_logo_candidates',
            description: '分析网站的所有Logo候选项并返回详细信息',
            inputSchema: {
              type: 'object',
              properties: {
                url: {
                  type: 'string',
                  description: '要分析的网站URL',
                },
              },
              required: ['url'],
            },
          },
        ],
      };
    });
  • Core helper function that implements the logo extraction logic: fetches website, parses with cheerio, collects candidates from favicons, apple icons, OG images, logo images, 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 [];
      }
    }
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 states what the tool does (extract logo link) but doesn't describe how it works, potential errors, rate limits, authentication needs, or output format. For a tool with no annotations, this leaves significant gaps in understanding its behavior and constraints.

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

Conciseness5/5

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

The description is a single, clear sentence in Chinese that directly states the tool's function without unnecessary words. It is front-loaded with the core purpose and efficiently communicates the essential information, making it highly concise and well-structured.

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 lack of annotations and output schema, the description is incomplete for effective tool use. It doesn't explain what the extracted logo link looks like (e.g., URL format, image type), potential failure modes, or how it interacts with the sibling tool. For a tool with no structured metadata, more contextual detail is needed.

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?

The input schema has 100% description coverage, with the single parameter 'url' clearly documented as '要提取Logo的网站URL' (website URL to extract logo from). The description adds no additional semantic context beyond what's in the schema, such as URL format requirements or examples. With high schema coverage, 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: '从指定网站URL提取Logo图标链接' (Extract logo icon link from specified website URL). It specifies both the action (extract) and the resource (logo icon link from URL), making the purpose unambiguous. However, it doesn't explicitly differentiate from its sibling tool 'analyze_logo_candidates', which appears related but has a different function.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention the sibling tool 'analyze_logo_candidates' or any other tools, nor does it specify prerequisites, limitations, or typical use cases. The agent must infer usage from the tool name and description alone.

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

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