CLI and MCP tools
The CLI and Model Context Protocol (MCP) packages make theSVG icon catalog available to two external workflows. The CLI helps a developer find brand or UI icons and add them to a project. The MCP server gives AI clients a way to search icons, inspect variants or looks, retrieve SVG content, and build embed URLs. They extend the catalog beyond the website while keeping command-line project changes separate from AI tool calls.
Tool boundaries
The tools are separate public Node packages with separate user-facing commands. Each package adapts the same icon concepts for a different consumer, while brand, UI, and flag icons remain separate package concerns within each workflow.
Published package boundaries
The CLI package @thesvg/cli at version 0.8.2 publishes the thesvg command from packages/…/index.ts. The MCP package @thesvg/mcp-server at version 0.9.2 publishes the thesvg-mcp command from packages/…/index.ts. Both packages support Node.js 18 or newer and publish compiled files from their own dist directories.
| Package | Primary consumer | Entry point | Main boundary |
|---|---|---|---|
@thesvg/cli | Developer at a shell prompt | thesvg | Reads brand or UI catalog data and writes selected icons into the current project. |
@thesvg/mcp-server | MCP-aware AI client | thesvg-mcp | Serves brand and UI icon tools through standard input and output. |
The package split keeps local project writes within the CLI workflow. The MCP boundary instead returns information or content that an AI client can use as part of a wider task. Flags are catalog results but point users to the separate @thesvg/flags package for framework components. In both packages, a UI request follows a UI-specific path so a UI data failure does not change brand behavior.
References: packages/…/package.json• L1-5 packages/…/package.json• L24-30 packages/…/package.json• L42-48 packages/…/package.json• L1-5 packages/…/package.json• L27-32 packages/…/package.json• L51-57 packages/…/index.ts• L1-23 packages/…/index.ts• L1-10
Command-line workflow
The CLI is a network client for the hosted icon catalogs. It helps a developer discover a brand icon or UI icon, choose a variant or look, and place the result in a project in the form that the project needs.
This diagram shows how a shell command turns catalog data into either displayed results or a file in the developer’s project.
flowchart LR
User[Developer] --> CLI[thesvg command]
CLI --> Registry[Hosted icon catalogs]
Registry --> Discover[List or search results]
Discover --> User
CLI --> Add[add command]
Add --> Choice[Icon and variant or look]
Choice --> SVG[Hosted SVG content]
SVG --> Format[SVG, React JSX, or Vue output]
Format --> Project[Project icon file]
Registry discovery
The list command shows available brand icons and can narrow results by category. The search command finds brand matches by name, slug, or keyword. The --ui option sends either command to the UI catalog, where results use a UI icon category and tags. Flag results also show guidance for the separate @thesvg/flags package instead of the generic icon packages. All paths give the developer the slug needed by add, so discovery leads directly to file acquisition or to the package that owns the flag component.
References: packages/…/list.ts• L5-9 packages/…/list.ts• L40-80 packages/…/search.ts• L5-9 packages/…/search.ts• L39-69 packages/…/search.ts• L191-192 packages/…/api.ts• L92-124 packages/…/ui.ts• L97-121 packages/…/flag-hint.ts• L1-10
Project output
The add command accepts one or more brand icon slugs and an optional variant. A ui:<slug> argument selects a UI icon, and --look selects its visual look, with outline as the default. Both kinds save the selected SVG as a raw file or wrap it as a typed React component or a Vue single-file component. UI files receive a ui- name prefix so they do not replace a brand file with the same slug.
When a result is a flag, the command also points the developer to @thesvg/flags and its per-flag React import. This guidance keeps flag framework use at the package that owns those components while preserving the CLI’s ability to fetch and write an SVG.
Without a directory option, the command chooses public/icons, src/icons, or icons based on the project shape. This output step makes the CLI different from a catalog viewer. Its final result is a local asset that the developer can use in the project.
References: packages/…/add.ts• L17-75 packages/…/add.ts• L78-100 packages/…/add.ts• L103-169 packages/…/add.ts• L187-205 packages/…/api.ts• L232-268 packages/…/ui.ts• L123-179 packages/…/flag-hint.ts• L1-10
MCP workflow
The MCP server exposes the icon catalogs as named tools for Claude Desktop, Cursor, Claude Code, and other MCP-aware clients. A client starts the published command and uses the server to find an icon, inspect its variants or UI looks, and obtain content or a URL for a larger AI-assisted task.
This diagram shows which requests use the bundled brand catalog, which requests use the remote UI catalog, and which requests need SVG data from a host.
flowchart LR
Client[AI or MCP client] --> Server[thesvg-mcp]
Server --> Index[Bundled brand registry]
Index --> Search[Search brand icons]
Index --> Variants[List brand variants]
Index --> Categories[List brand categories]
Index --> URL[Build brand URL]
Server --> UiIndex[Remote UI index]
UiIndex --> UiSearch[Search UI icons]
UiIndex --> UiLooks[List UI looks]
UiIndex --> UiCategories[List UI categories]
UiIndex --> UiURL[Build UI URL]
Server -->|brand get_icon| CDN[jsDelivr SVG CDN]
Server -->|UI get_icon| UiSite[UI SVG host]
Search --> Client
Variants --> Client
Categories --> Client
URL --> Client
UiSearch --> Client
UiLooks --> Client
UiCategories --> Client
UiURL --> Client
CDN --> Client
UiSite --> Client
MCP tool surface
The server presents five focused tools. Each tool accepts kind, which defaults to brand; kind: "ui" switches the request to UI icons. Together they support a simple AI workflow: find an icon, confirm its variants or looks, then return SVG content or an embeddable URL. Results for flag slugs add guidance for the separate @thesvg/flags package when the response can lead to a component choice.
| Tool | Capability | Data need |
|---|---|---|
search_icons | Find brand icons or UI icons and return basic metadata. | Bundled brand registry or remote UI index. |
get_icon | Return SVG markup with icon metadata and its URL. | Brand lookup plus CDN fetch, or UI lookup plus UI host fetch. |
list_variants | Show brand variants or UI looks for one icon. | Bundled brand registry or remote UI index. |
get_icon_url | Return an embeddable icon URL without fetching SVG content. | Brand lookup or remote UI index. |
list_categories | Show brand or UI categories with icon counts. | Bundled brand registry or remote UI index. |
The tool inputs form a small contract with the AI client. Unknown slugs and unavailable variants or looks produce an error result that directs the client toward search or discovery. Flag search and icon results can also name @thesvg/flags rather than suggesting @thesvg/icons or a generic framework package.
References: packages/…/index.ts• L127-147 packages/…/index.ts• L149-228 packages/…/index.ts• L301-374 packages/…/index.ts• L437-451 packages/…/ui-tools.ts• L37-137 packages/…/flag-hint.ts• L1-22
Catalog and host boundary
The MCP server bundles a brand registry snapshot when the package is built. Search, variant lookup, category counts, and brand URL creation can then work without a startup network call. UI tools use a separate index fetched lazily from the current UI catalog and cache it for later requests. Both get_icon paths fetch SVG content only when the client asks for raw content.
Flag results use the shared catalog for discovery but do not imply that flag components are part of the bundled generic icon packages. Their result guidance points to @thesvg/flags, which owns the framework imports and related flag forms.
This split gives AI clients fast brand catalog access while keeping raw SVG retrieval as a separate network-dependent action. UI requests have their own network boundary, so a UI outage can surface as a UI tool error without affecting brand tools. A brand registry refresh must keep the bundled snapshot and pinned CDN release aligned; a UI catalog change must keep its index, looks, and hosted SVG paths aligned.
References: packages/…/index.ts• L14-19 packages/…/index.ts• L55-84 packages/…/index.ts• L195-212 packages/…/index.ts• L284-305 packages/…/ui.ts• L1-11 packages/…/ui.ts• L59-92 packages/…/ui-tools.ts• L54-105 packages/…/flag-hint.ts• L8-21
Workflow relationships
The CLI and MCP tools serve different actors but use the same catalog concepts: slug, title, category, variant or look, and SVG asset. The CLI ends by creating a local project file. MCP ends by giving an AI client information, a URL, or SVG content for a larger task. Brand and UI requests stay distinct so each catalog can use its own metadata and delivery source. Flag results add a third package boundary because discovery is shared but framework components belong to @thesvg/flags.
- The parent page Developer tools and editor integrations places these packages with other external workflow adapters.
- Editor, launcher, and browser extensions covers integrations that act inside editors, launchers, browsers, and design tools.
- MCP worker service and widget covers the hosted MCP service and its widget workflow.
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the CLI registry contract, icon variant names, and hosted SVG paths aligned.
- Keep UI catalog looks,
ui:selection, UI file prefixes, and hosted UI SVG paths aligned. - Keep flag slugs, flag result hints, and the
@thesvg/flagsper-flag import paths aligned across CLI and MCP output. - Keep the CLI output formats and file names valid for the framework syntax that each format promises.
- Refresh the MCP bundled registry and its pinned CDN release together so metadata and SVG content describe the same icon set.
- Keep the MCP UI index, look names, UI URL format, and UI host release aligned.
- Preserve the
thesvgandthesvg-mcpcommand names when package entrypoints or publish layouts change. - Keep MCP tool names,
kindandlookinput schemas, and error guidance aligned because AI clients use them as an interaction contract. - Keep each package's
bin, published files, build output, and Node.js engine requirement aligned when package metadata changes.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The hosted brand registry is unavailable or has an unexpected shape. | CLI discovery and icon download cannot find the requested asset. | Preserve registry response checks and report the network or shape error. |
| The MCP package uses an old bundled registry after the CDN release changes. | AI clients can miss icons or receive metadata that does not match the SVG source. | Rebuild the package when the registry or pinned CDN release changes. |
A flag result points to a generic icon package instead of @thesvg/flags. | A developer or AI client may choose an import path that does not contain the flag component. | Keep flag detection and hint text aligned with the published flags package paths. |
| A user or AI client selects a variant that an icon does not provide. | The requested asset cannot be returned in that form. | Discover variants before selecting one and keep the available-variant data current. |
The CDN is unavailable during brand get_icon. | MCP can still search and build known URLs but cannot return SVG markup. | Use get_icon_url when a URL is enough. |
| The UI index or UI SVG host is unavailable. | UI search, look discovery, or UI content requests fail while brand tools remain usable. | Keep UI requests on their isolated path and use brand tools when the task does not need a UI icon. |
| A UI look is not present in the current UI index. | The client cannot build or fetch the requested UI asset. | Use list_variants with kind: "ui" before requesting a look. |
| A package build no longer places the compiled entrypoint at the published command path. | npx and configured MCP clients cannot start the tool. | Keep package command mappings and build output paths in sync. |
Key files
| File | Why to read it |
|---|---|
| packages/…/package.json | Defines the published CLI package, shell command, build boundary, and runtime requirement. |
| packages/…/README.md | Describes the CLI user workflow, commands, output formats, and project output locations. |
| packages/…/index.ts | Defines the command-line entrypoint and command paths. |
| packages/…/api.ts | Defines the CLI boundary to brand registry metadata and SVG content. |
| packages/…/ui.ts | Defines the CLI boundary to UI metadata, looks, and SVG content. |
| packages/…/flag-hint.ts | Defines the package guidance shown for flag results. |
| packages/…/add.ts | Shows the path from an icon choice to a project asset. |
| packages/…/list.ts and packages/…/search.ts | Show how brand and UI discovery share command entrypoints while using separate catalog paths. |
| packages/…/writer.ts | Shows the supported file forms and output locations. |
| packages/…/package.json | Defines the published MCP package, server command, catalog build steps, dependencies, and runtime requirement. |
| packages/…/README.md | Describes AI client setup, the tool surface, the data source, and the network boundary. |
| packages/…/index.ts | Defines the MCP entrypoint, tools, brand catalog behavior, and client connection. |
| packages/…/flag-hint.ts | Defines the flag package guidance added to MCP answers. |
| packages/…/ui.ts and packages/…/ui-tools.ts | Define the UI catalog boundary and the UI-specific MCP tool results. |
| src/…/icons.json | Provides the brand catalog data represented by the CLI registry and bundled for MCP use. |