MCP worker service and interactive widget
The hosted MCP worker makes the thesvg icon catalog available to AI clients over HTTPS. It accepts MCP requests on a Cloudflare Worker, finds brand or UI icon data, fetches SVG content only when needed, and can show search results as a visual widget in clients that support the Apps SDK.
Service boundary
The service is the HTTPS counterpart to the local stdio MCP server. It gives web-based AI clients one public endpoint for icon discovery and retrieval without requiring a local process or project access.
Request lifecycle
The worker keeps request handling stateless because each request can use the same catalog snapshot and does not need session data. The root and health paths provide a small status response. MCP traffic passes through a client check before the MCP handler processes the request.
This diagram shows how an HTTPS request moves from a client to either a health response or an MCP tool result.
flowchart LR
Client[AI client] --> Worker[HTTPS worker]
Worker --> Health{Root or health path?}
Health -->|yes| Status[Service status]
Health -->|no| MCPPath{MCP path?}
MCPPath -->|yes| Limit[Client rate check]
Limit -->|blocked| TooMany[429 response]
Limit -->|allowed| Handler[Stateless MCP handler]
MCPPath -->|no| Handler
Handler --> Tool[Icon tool]
Tool --> Result[Text or structured result]
The MCP route is /mcp. The service does not require authentication, so availability control comes from the rate-limit boundary and from the limits of the backing icon data and CDN.
References: packages/…/index.ts• L42-48 packages/…/index.ts• L318-350 packages/…/README.md• L3-7 packages/…/README.md• L61
Icon data access
The worker uses a build-time snapshot of the main icon registry for fast brand discovery. The snapshot supplies names, slugs, aliases, categories, brand colors, licenses, links, and available variants. It is refreshed when the worker is built or deployed rather than fetched for each request.
The UI icon set uses a separate index. The worker fetches that index on the first UI request and caches it in memory. A UI index failure affects only UI requests, so brand discovery can continue.
The package prepares the brand snapshot before development, build, test, and deploy commands. This keeps local checks and deployed output based on the same source registry while preserving the worker's offline-capable brand catalog model.
Catalog lookup
The brand data layer turns the registry into a compact icon index. Search uses fuzzy matching across the slug, display name, and aliases. Exact slug lookup supports follow-up actions after a search. Category results count the icons in each category and sort the counts from high to low.
The UI data layer searches slugs, titles, tags, and categories. It also validates the requested look and builds URLs for the available UI SVG files. UI category results use the same count-based discovery pattern.
The catalog builds public SVG URLs, so discovery tools do not need a network call. get_icon fetches SVG markup for the selected brand variant or UI look from the public service. That fetch has a ten-second time limit. get_icon_url only returns a URL.
References: packages/…/icons-data.ts• L6-16 packages/…/icons-data.ts• L18-65 packages/…/icons-data.ts• L68-79 packages/…/icons-data.ts• L88-135 packages/…/ui-data.ts• L1-4 packages/…/ui.ts• L7-11 packages/…/ui.ts• L68-132 packages/…/ui-tools.ts• L61-115 packages/…/index.ts• L167-184 packages/…/index.ts• L257-281 packages/…/package.json• L18-28 packages/…/README.md• L21-25 packages/…/README.md• L36-38
Tool surface
The worker exposes five tools that support the main AI icon workflow. A client can start with broad discovery, confirm a slug and presentation, then request either reusable content or a URL.
| Tool | Purpose | Data or network need |
|---|---|---|
search_icons | Find brand or UI icons by name, slug, alias, tag, or category. | Brand or UI index; also returns widget data. |
list_categories | Show categories and icon counts for the selected kind. | Brand snapshot or UI index. |
list_variants | Show brand variants or UI looks for one icon with their URLs. | Brand snapshot or UI index. |
get_icon_url | Return a URL for embedding a brand variant or UI look. | Brand snapshot or UI index; no SVG fetch. |
get_icon | Return SVG markup with details for a brand variant or UI look. | Brand or UI index plus the public SVG service. |
Every tool accepts the optional kind value brand or ui. brand is the default. A brand variant is a presentation such as default or mono; a UI look is a presentation such as outline or glass. The other tool inputs guide the client from search to an exact asset.
The tools return readable text for an AI client. Search also returns structured content for the visual surface. An unknown slug or unavailable presentation returns an error that guides the client back to search or variant discovery. UI tool helpers turn index and SVG failures into error results, which keeps a UI outage from affecting brand tools.
References: packages/…/index.ts• L50-63 packages/…/index.ts• L92-147 packages/…/index.ts• L150-205 packages/…/index.ts• L208-237 packages/…/index.ts• L240-283 packages/…/index.ts• L285-313 packages/…/ui-tools.ts• L1-26 packages/…/README.md• L9-25
Input contracts
The shared slug-and-variant contract is used by brand get_icon and get_icon_url. It requires a slug and uses default when the caller does not provide a brand variant. Search limits results to a caller-selected range from one to one hundred, with twenty as the default.
For UI requests, get_icon and get_icon_url use the optional look input and default to outline. list_variants lists the valid UI looks instead of brand variants. An unknown UI look returns the valid look names so the client can correct its next request.
These schemas keep the tool descriptions useful to AI clients. Shared lookup helpers keep missing-icon guidance consistent across the brand and UI paths.
References: packages/…/index.ts• L50-63 packages/…/index.ts• L99-110 packages/…/index.ts• L157-160 packages/…/index.ts• L215-222 packages/…/index.ts• L247-250 packages/…/ui-tools.ts• L61-68 packages/…/ui-tools.ts• L96-103 packages/…/ui-tools.ts• L118-129 packages/…/README.md• L21-25
Rate limiting
The worker can apply a per-client sliding-window limit before any MCP tool runs. It uses Cloudflare's native rate-limit binding when the deployment enables it. The client key comes first from Cloudflare's connecting-IP header, then from the first forwarded IP, with unknown as the final fallback.
The binding is optional in the default deployment. If it is absent or its check fails, the worker allows the request and records the failure. When the binding rejects a request, the worker returns HTTP 429 with a short retry instruction instead of invoking the MCP handler.
References: packages/…/rate-limit.ts• L1-13 packages/…/rate-limit.ts• L15-60 packages/…/index.ts• L331-345 packages/…/wrangler.jsonc• L11-26 packages/…/README.md• L51-61
Interactive widget
The search_icons tool has an optional visual result surface for MCP clients that support the OpenAI Apps SDK. The worker registers one HTML resource and links the tool to it with MCP metadata. The other four tools remain text-only so their responses stay usable in clients without widget support.
Search result display
The search result includes a query, a result count, and a small icon record for each match. Each record has a slug, name, and ready-to-use URL. Brand results use the brand CDN URL, while UI results use the outline UI URL. The widget reads this structured result through the host's tool-output interface and renders a responsive thumbnail grid.
The HTML is a shared shell rather than a page generated for one search. This lets the same resource render new results when the host reports a tool-output change. Empty results produce a clear empty state instead of an empty grid.
References: packages/…/widget.ts• L18-51 packages/…/widget.ts• L53-139 packages/…/index.ts• L71-89 packages/…/index.ts• L92-147 packages/…/ui-tools.ts• L28-59 packages/…/README.md• L40-49
Integration relationships
The hosted worker belongs to the external developer-tool family but serves a different transport and client group from the local MCP package. The local package covers stdio clients such as desktop assistants. The worker covers HTTPS connectors such as web-based AI clients. Most server behavior can evolve separately because the runtimes and transports differ, while the UI data layer is shared to keep UI index and look rules aligned.
The local counterpart is distributed as the @thesvg/mcp-server package. Its package lifecycle copies the shared icon registry into the server build so local MCP clients use the same brand catalog source as the hosted service.
- Developer tools and editor integrations gives the parent view of catalog integrations.
- CLI and MCP tools explains the local CLI and stdio MCP boundaries.
- Editor, launcher, and browser extensions covers integrations that run inside editors, launchers, browsers, and design tools.
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the copied brand catalog, the source icon registry, and the public brand CDN release aligned so search results describe assets that can be fetched.
- Keep the UI index shape, look names, UI SVG paths, and shared UI data behavior aligned between the worker and the local MCP package.
- Keep the five tool names,
kindandlookinputs, input limits, default presentations, and error guidance aligned with MCP clients that learn the contract from the schemas. - Keep the
search_iconsstructured-content shape, widget metadata, resource URI, and widget reader aligned for both brand and UI records so a search result does not become a blank visual surface. - Keep the
/mcproute, rate-limit binding name, client-key rules, and 429 response behavior aligned with the deployed connector configuration. - Keep the worker's HTTPS boundary separate from the stdio server when either transport changes; shared UI data rules are the exception and must remain compatible.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The bundled brand catalog is older than the public CDN release. | AI clients can miss brand icons or receive variant data that does not match the available SVG files. | Refresh the worker catalog whenever the source registry or brand CDN release changes. |
| The UI index is unavailable or has an unexpected shape. | UI searches, look lists, and UI retrieval return errors, but brand tools continue to work. | Keep the UI index reachable and preserve its required icon and look fields. |
| A slug, brand variant, or UI look is not present in the selected index. | The tool cannot provide the requested asset and returns an error result. | Search first, then list variants or looks before requesting content or a URL. |
The public SVG service is slow or unavailable during get_icon. | Discovery and URL generation still work, but raw SVG content is not returned. | Use get_icon_url when the caller only needs the embed URL. |
| The rate-limit binding rejects a request. | The client receives HTTP 429 and no tool runs. | Honor the retry response and keep the binding limit suited to expected connector use. |
| The rate-limit binding is missing or fails. | Requests pass without protection from the configured limit. | Provision the binding in the deployment and monitor its check failures. |
| Widget metadata or structured content changes without the matching widget update. | An Apps SDK client can show no thumbnails or an empty state for valid search results. | Treat the resource URI, metadata keys, and { slug, name, url } record as one contract. |
Key files
| File | Why to read it |
|---|---|
| packages/…/index.ts | Defines the HTTPS request boundary, MCP tools, kind selection, result flow, and widget registration. |
| packages/…/icons-data.ts | Explains the bundled brand catalog, search behavior, category counts, and brand CDN URL boundary. |
| packages/…/ui-data.ts | Connects the worker to the lazy, cached UI index and shared UI data rules. |
| packages/…/ui-tools.ts | Shows how UI search, look lookup, URL generation, and SVG retrieval map to tool results. |
| packages/…/widget.ts | Defines the Apps SDK resource, search-output shape, and thumbnail display. |
| packages/…/tool-schemas.ts | Defines the shared slug and brand variant input contract. |
| packages/…/tool-helpers.ts | Defines common text, error, and missing-icon results. |
| packages/…/rate-limit.ts | Defines client keys and the optional fail-open rate check. |
| packages/…/wrangler.jsonc | Shows the Worker deployment boundary and optional rate-limit binding. |
| packages/…/package.json | Shows the worker lifecycle commands that refresh the bundled brand catalog and run checks. |
| packages/…/README.md | Gives the service purpose, connector context, data refresh model, UI contract, and deployment constraints. |