get_icon_repos
Retrieve all available icon repository names from the Iconify API for designers and developers to access SVG icons through natural language requests.
Instructions
get all icon repo NAME
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:24-46 (handler)The handler function for the 'get_icon_repos' tool. It calls getIconRepoNames() to fetch icon repositories and returns their names as a JSON string in the response content, or an error message if failed.server.tool("get_icon_repos", "get all icon repo NAME", {}, async () => { const allRepos = await getIconRepoNames(); if (!allRepos) { return { content: [ { type: "text", text: "Failed to Get Repo Infos", }, ], }; } return { content: [ { type: "text", text: JSON.stringify(Object.keys(allRepos)), }, ], }; });
- src/index.ts:24-46 (registration)Registration of the 'get_icon_repos' tool using server.tool(), including empty schema {} and inline handler.server.tool("get_icon_repos", "get all icon repo NAME", {}, async () => { const allRepos = await getIconRepoNames(); if (!allRepos) { return { content: [ { type: "text", text: "Failed to Get Repo Infos", }, ], }; } return { content: [ { type: "text", text: JSON.stringify(Object.keys(allRepos)), }, ], }; });
- src/fetcher.ts:1-16 (helper)Helper function getIconRepoNames() that fetches the list of all icon repositories from the Iconify API./** get all icon repo names */ export async function getIconRepoNames<T>(): Promise<T | null> { try { const res = await fetch(`https://api.iconify.design/collections`, { method: "GET", }); if (!res.ok) { throw new Error(`HTTP error! status: ${res.status}`); } return (await res.json()) as T; } catch (error) { console.error("Error making request:", error); return null; } }