search_logos
Find company logos by searching for brand names. Get matching companies with their domains and logo URLs for use in projects.
Instructions
Search for company logos by brand name or company name. Returns a list of matching companies with their domains and logo URLs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The brand or company name to search for (e.g., 'Google', 'Apple', 'Microsoft') |
Implementation Reference
- src/index.ts:35-99 (handler)The asynchronous handler function for the 'search_logos' tool. It fetches search results from the Logo.dev API using the provided query, processes the response, formats the results with logo URLs, and returns them as JSON text content or an error message.async ({ query }) => { try { const response = await fetch( `${LOGO_DEV_API_BASE}/search?q=${encodeURIComponent(query)}`, { headers: { Authorization: `Bearer ${config.apiKey}`, }, } ); if (!response.ok) { throw new Error(`Logo.dev API error: ${response.status} ${response.statusText}`); } const data = await response.json(); const results = Array.isArray(data) ? data : []; if (results.length === 0) { return { content: [ { type: "text" as const, text: `No logos found for "${query}". Try a different search term.`, }, ], }; } const formattedResults = results.map((company: any) => ({ name: company.name || "Unknown", domain: company.domain || "Unknown", logoUrl: company.domain ? `${LOGO_DEV_IMG_BASE}/${company.domain}?token=${config.apiKey}` : null, })); return { content: [ { type: "text" as const, text: JSON.stringify( { query, count: formattedResults.length, results: formattedResults, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text" as const, text: `Error searching logos: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }
- src/index.ts:32-34 (schema)The input schema for the 'search_logos' tool, defining a single required string parameter 'query' with a descriptive help text.{ query: z.string().describe("The brand or company name to search for (e.g., 'Google', 'Apple', 'Microsoft')"), },
- src/index.ts:29-100 (registration)The registration of the 'search_logos' tool on the MCP server using server.tool(), specifying the tool name, description, input schema, and handler function.server.tool( "search_logos", "Search for company logos by brand name or company name. Returns a list of matching companies with their domains and logo URLs.", { query: z.string().describe("The brand or company name to search for (e.g., 'Google', 'Apple', 'Microsoft')"), }, async ({ query }) => { try { const response = await fetch( `${LOGO_DEV_API_BASE}/search?q=${encodeURIComponent(query)}`, { headers: { Authorization: `Bearer ${config.apiKey}`, }, } ); if (!response.ok) { throw new Error(`Logo.dev API error: ${response.status} ${response.statusText}`); } const data = await response.json(); const results = Array.isArray(data) ? data : []; if (results.length === 0) { return { content: [ { type: "text" as const, text: `No logos found for "${query}". Try a different search term.`, }, ], }; } const formattedResults = results.map((company: any) => ({ name: company.name || "Unknown", domain: company.domain || "Unknown", logoUrl: company.domain ? `${LOGO_DEV_IMG_BASE}/${company.domain}?token=${config.apiKey}` : null, })); return { content: [ { type: "text" as const, text: JSON.stringify( { query, count: formattedResults.length, results: formattedResults, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text" as const, text: `Error searching logos: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } } );