# 21st-dev/codex-plugin architecture

> Architecture diagram of the GitHub repository 21st-dev/codex-plugin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/21st-dev/codex-plugin
- Repository: https://github.com/21st-dev/codex-plugin

## Overview

#### Purpose and Distribution

This repository is a self-hosted Codex plugin marketplace entry for 21st.dev. It connects Codex agents to the hosted 21st component/design platform so they can discover, generate, install, publish, and manage UI assets rather than manually authoring them.

Plugin discovery and installation are defined by:
- `marketplace.json`
- `.codex-plugin/plugin.json`

#### Plugin Entry Points

`.codex-plugin/plugin.json` is the primary plugin manifest. It registers the bundled skills and the `21st` MCP integration with Codex.

`.mcp.json` is the runtime connection entry point for the remote MCP server. The repository contains no local application server or executable; Codex invokes the hosted service directly.

#### Remote MCP Boundary

The central integration boundary is the remote 21st MCP endpoint at `https://21st.dev/api/mcp`, configured in:
- `.mcp.json`
- `.codex-plugin/plugin.json`

Codex authenticates requests using `API_KEY_21ST`, supplied as a bearer token. The remote service owns search, retrieval, AI generation, usage, bookmarks/lists, teams, and component/theme/template write operations. This repository supplies registration and agent guidance, not the implementations of those tools.

#### Skill Routing Layer

Four Markdown skills provide task-specific operating guidance to the Codex agent:
- `skills/21st-cli-use/SKILL.md`
- `skills/21st-ai/SKILL.md`
- `skills/21st-registry/SKILL.md`
- `skills/21st-design-sync/SKILL.md`

They are intended to activate in projects containing `components.json`, creating a project-level boundary: 21st workflows apply when a compatible component-oriented project is detected.

#### Core Workflows

1. **Search and consume assets:** `21st-cli-use` directs search, component retrieval, and installation/addition flows.
2. **Generate and refine UI:** `21st-ai` guides use of hosted AI generation, iterative changes, and code retrieval.
3. **Publish and administer registry assets:** `21st-registry` covers publishing and management of reusable components and related assets.
4. **Synchronize design tokens:** `21st-design-sync` publishes local project design tokens as a 21st theme.

These workflows route agent intent through either the 21st CLI guidance or MCP tools; resulting code/assets cross from 21st.dev into the user’s local project.

#### Infrastructure and Commercial Boundaries

The required external runtime is Codex with plugin and MCP support. The required external service is 21st.dev, including its MCP API and API-key authentication.

Metadata search is free, while component code access, AI generation, and mutating operations are metered by 21st.dev. Agents should therefore treat retrieval/generation/write calls as potentially billable remote operations, distinct from local skill interpretation.

Main entry points: [`.codex-plugin/plugin.json`](https://github.com/21st-dev/codex-plugin/blob/main/.codex-plugin/plugin.json) (Plugin manifest), [`skills/21st-design-sync/SKILL.md`](https://github.com/21st-dev/codex-plugin/blob/main/skills/21st-design-sync/SKILL.md) (Design sync skill), [`skills/21st-cli-use/SKILL.md`](https://github.com/21st-dev/codex-plugin/blob/main/skills/21st-cli-use/SKILL.md) (CLI use skill), [`skills/21st-ai/SKILL.md`](https://github.com/21st-dev/codex-plugin/blob/main/skills/21st-ai/SKILL.md) (AI skill)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_package["Plugin package"]
  node_marketplace["Marketplace entry<br/>marketplace metadata<br/>[marketplace.json]"]
  node_plugin_manifest["Plugin manifest<br/>[plugin.json]"]
  node_mcp_config["MCP connection config<br/>MCP config<br/>[.mcp.json]"]
  node_cli_skill["CLI use skill<br/>agent skill<br/>[SKILL.md]"]
  node_ai_skill["AI skill<br/>agent skill<br/>[SKILL.md]"]
  node_registry_skill["Registry skill<br/>agent skill<br/>[SKILL.md]"]
  node_design_sync_skill["Design sync skill<br/>agent skill<br/>[SKILL.md]"]
end

subgraph group_codex["Codex runtime"]
  node_codex_agent{{"Codex agent<br/>agent runtime"}}
  node_api_key["API_KEY_21ST<br/>bearer credential"]
end

subgraph group_remote["21st.dev"]
  node_mcp_endpoint{{"21st MCP API<br/>remote MCP endpoint"}}
  node_hosted_platform[("21st asset platform<br/>hosted platform")]
end

subgraph group_project["User project"]
  node_compatible_project["Compatible project<br/>local project"]
  node_local_assets["Installed code and tokens<br/>local assets"]
end

node_marketplace -->|"discovers"| node_plugin_manifest
node_plugin_manifest -->|"registers with"| node_codex_agent
node_plugin_manifest -->|"bundles"| node_cli_skill
node_plugin_manifest -->|"bundles"| node_ai_skill
node_plugin_manifest -->|"bundles"| node_registry_skill
node_plugin_manifest -->|"bundles"| node_design_sync_skill
node_plugin_manifest -->|"configures"| node_mcp_endpoint
node_mcp_config -->|"connects to"| node_mcp_endpoint
node_cli_skill -->|"guides"| node_codex_agent
node_ai_skill -->|"guides"| node_codex_agent
node_registry_skill -->|"guides"| node_codex_agent
node_design_sync_skill -->|"guides"| node_codex_agent
node_compatible_project -.->|"activates"| node_cli_skill
node_compatible_project -.->|"activates"| node_ai_skill
node_compatible_project -.->|"activates"| node_registry_skill
node_compatible_project -.->|"activates"| node_design_sync_skill
node_codex_agent -->|"invokes tools"| node_mcp_endpoint
node_api_key -->|"bearer auth"| node_mcp_endpoint
node_mcp_endpoint -->|"serves platform operations"| node_hosted_platform
node_hosted_platform -->|"delivers assets"| node_local_assets
node_design_sync_skill -->|"publishes themes"| node_hosted_platform
node_local_assets -->|"added to"| node_compatible_project

click node_marketplace "https://github.com/21st-dev/codex-plugin/blob/main/marketplace.json"
click node_plugin_manifest "https://github.com/21st-dev/codex-plugin/blob/main/.codex-plugin/plugin.json"
click node_mcp_config "https://github.com/21st-dev/codex-plugin/blob/main/.mcp.json"
click node_cli_skill "https://github.com/21st-dev/codex-plugin/blob/main/skills/21st-cli-use/SKILL.md"
click node_ai_skill "https://github.com/21st-dev/codex-plugin/blob/main/skills/21st-ai/SKILL.md"
click node_registry_skill "https://github.com/21st-dev/codex-plugin/blob/main/skills/21st-registry/SKILL.md"
click node_design_sync_skill "https://github.com/21st-dev/codex-plugin/blob/main/skills/21st-design-sync/SKILL.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_marketplace,node_plugin_manifest,node_mcp_config,node_cli_skill,node_ai_skill,node_registry_skill,node_design_sync_skill toneBlue
class node_codex_agent,node_api_key toneAmber
class node_mcp_endpoint,node_hosted_platform toneMint
class node_compatible_project,node_local_assets toneRose
```

## Components

### Plugin package

Repository-supplied registration and agent guidance.

- [Marketplace entry](https://github.com/21st-dev/codex-plugin/blob/main/marketplace.json): marketplace metadata · `marketplace.json`
- [Plugin manifest](https://github.com/21st-dev/codex-plugin/blob/main/.codex-plugin/plugin.json): plugin manifest · Registers skills and the 21st MCP integration. · `.codex-plugin/plugin.json`
- [MCP connection config](https://github.com/21st-dev/codex-plugin/blob/main/.mcp.json): MCP config · Points Codex to the hosted MCP endpoint. · `.mcp.json`
- [CLI use skill](https://github.com/21st-dev/codex-plugin/blob/main/skills/21st-cli-use/SKILL.md): agent skill · Guides search, retrieval, and installation. · `skills/21st-cli-use/SKILL.md`
- [AI skill](https://github.com/21st-dev/codex-plugin/blob/main/skills/21st-ai/SKILL.md): agent skill · Guides hosted UI generation and refinement. · `skills/21st-ai/SKILL.md`
- [Registry skill](https://github.com/21st-dev/codex-plugin/blob/main/skills/21st-registry/SKILL.md): agent skill · Guides publishing and registry administration. · `skills/21st-registry/SKILL.md`
- [Design sync skill](https://github.com/21st-dev/codex-plugin/blob/main/skills/21st-design-sync/SKILL.md): agent skill · Guides publishing local design tokens as a theme. · `skills/21st-design-sync/SKILL.md`

### Codex runtime

- **Codex agent**: agent runtime · Interprets skills and invokes configured MCP tools.
- **API_KEY_21ST**: bearer credential · Authenticates remote MCP requests.

### 21st.dev

Hosted MCP service and asset platform.

- **21st MCP API**: remote MCP endpoint · Provides search, retrieval, generation, and write tools.
- **21st asset platform**: hosted platform · Owns components, themes, templates, teams, lists, and usage.

### User project

- **Compatible project**: local project · Workflows apply when the project contains components.json.
- **Installed code and tokens**: local assets · Retrieved components and synchronized design assets.

## Connections

- Marketplace entry → Plugin manifest: discovers
- Plugin manifest → Codex agent: registers with
- Plugin manifest → CLI use skill: bundles
- Plugin manifest → AI skill: bundles
- Plugin manifest → Registry skill: bundles
- Plugin manifest → Design sync skill: bundles
- Plugin manifest → 21st MCP API: configures
- MCP connection config → 21st MCP API: connects to
- CLI use skill → Codex agent: guides
- AI skill → Codex agent: guides
- Registry skill → Codex agent: guides
- Design sync skill → Codex agent: guides
- Compatible project → CLI use skill: activates
- Compatible project → AI skill: activates
- Compatible project → Registry skill: activates
- Compatible project → Design sync skill: activates
- Codex agent → 21st MCP API: invokes tools · Retrieval, generation, and writes may be metered.
- API_KEY_21ST → 21st MCP API: bearer auth
- 21st MCP API → 21st asset platform: serves platform operations
- 21st asset platform → Installed code and tokens: delivers assets
- Design sync skill → 21st asset platform: publishes themes
- Installed code and tokens → Compatible project: added to
