# 21st-dev/magic-mcp architecture

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

- Interactive diagram: https://gitdiagram.com/21st-dev/magic-mcp
- Repository: https://github.com/21st-dev/magic-mcp

## Overview

This repository is a small compatibility shim, not the implementation of the hosted 21st MCP. An MCP client sends JSON-RPC over the shim’s stdio interface; the shim resolves credentials, forwards requests to the hosted endpoint over HTTP, and returns responses over stdout. The sampled source shows the request queue, authentication handling, and session-ID forwarding. Hosted MCP capabilities are documented, but their server-side implementation is not in this repository.

Main entry points: [`src/index.ts`](https://github.com/21st-dev/magic-mcp/blob/main/src/index.ts) (JSON-RPC proxy)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_client(("MCP client"))
node_stdio["Stdio input queue<br/>[index.ts]"]
node_credentials["Credential resolution<br/>[index.ts]"]
node_proxy["JSON-RPC proxy<br/>[index.ts]"]
node_hosted["21st MCP endpoint"]

node_client -->|"sends JSON-RPC"| node_stdio
node_stdio -->|"queues requests"| node_proxy
node_proxy -->|"reads key"| node_credentials
node_proxy -->|"POSTs requests"| node_hosted
node_hosted -->|"returns responses"| node_proxy
node_proxy -->|"writes replies"| node_client

click node_stdio "https://github.com/21st-dev/magic-mcp/blob/main/src/index.ts"
click node_credentials "https://github.com/21st-dev/magic-mcp/blob/main/src/index.ts"
click node_proxy "https://github.com/21st-dev/magic-mcp/blob/main/src/index.ts"

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_client toneBlue
class node_stdio toneRose
class node_credentials,node_proxy toneTeal
class node_hosted toneIndigo
```

## Components

### Other components

- **MCP client**
- [Stdio input queue](https://github.com/21st-dev/magic-mcp/blob/main/src/index.ts): `src/index.ts`
- [Credential resolution](https://github.com/21st-dev/magic-mcp/blob/main/src/index.ts): `src/index.ts`
- [JSON-RPC proxy](https://github.com/21st-dev/magic-mcp/blob/main/src/index.ts): `src/index.ts`
- **21st MCP endpoint**

## Connections

- MCP client → Stdio input queue: sends JSON-RPC (evidence: `src/index.ts`)
- Stdio input queue → JSON-RPC proxy: queues requests (evidence: `src/index.ts`)
- JSON-RPC proxy → Credential resolution: reads key (evidence: `src/index.ts`)
- JSON-RPC proxy → 21st MCP endpoint: POSTs requests (evidence: `src/index.ts`)
- 21st MCP endpoint → JSON-RPC proxy: returns responses (evidence: `src/index.ts`)
- JSON-RPC proxy → MCP client: writes replies (evidence: `src/index.ts`)
