Overview
TemPad Dev is a monorepo containing four packages that work together to provide Figma-to-code conversion through the Model Context Protocol (MCP).Monorepo Structure
Package Roles
Extension (@tempad-dev/extension)
Location: packages/extension/
Purpose: Browser extension that runs on https://www.figma.com/* and implements MCP tool behavior.
Key directories:
mcp/- MCP tool implementations and runtimetools/- Tool handlers (get_code, get_structure, get_screenshot, token)runtime.ts- Tool routing and validationassets.ts- Asset upload integration
codegen/- Code generation pipelinecomponents/- Vue UI componentsrewrite/- Figma script rewrite rulesentrypoints/- Extension entry points (content, background, rewrite)worker/- Web worker for code generationutils/- Utility functions
- TypeScript
- Vue 3 + WXT (Web Extension Toolkit)
- WebSocket transport for MCP
- Tailwind-compatible class generation
MCP Server (@tempad-dev/mcp)
Location: packages/mcp-server/
Purpose: Hub/CLI that exposes MCP tools and proxies calls to the extension.
Key files:
src/cli.ts- MCP stdio entrypoint and Hub startupsrc/hub.ts- Tool routing, WebSocket server, MCP resourcessrc/tools.ts- Tool definitions and formatterssrc/request.ts- Pending tool call tracking and timeoutssrc/asset-store.ts- Asset index and cleanupsrc/asset-http-server.ts- HTTP upload/download
- TypeScript (Node.js 18+)
@modelcontextprotocol/sdk- WebSocket transport
- Pino logging
Plugins (@tempad-dev/plugins)
Location: packages/plugins/
Purpose: Public SDK for plugin authors to customize code generation.
Key files:
src/index.ts- Public exports (types, hooks, helpers)README.md/README.zh-Hans.md- User-facing documentation
- TypeScript
- ESM + DTS output
- Build tool: tsdown
Shared (@tempad-dev/shared)
Location: packages/shared/
Purpose: Shared contracts between extension and MCP server.
Key files:
src/mcp/constants.ts- Payload and message limitssrc/mcp/tools.ts- Tool schemas and result typessrc/mcp/protocol.ts- WebSocket message shapessrc/figma/color.ts- Color formatter utilitiessrc/index.ts- Public exports
- TypeScript
- Zod schemas
- Build tool: tsdown
Data Flow
- AI client sends MCP request to server
- MCP server proxies request to extension via WebSocket
- Extension queries Figma API and generates code
- Extension uploads assets to asset store
- Extension returns result to MCP server
- MCP server formats and returns to AI client
Cross-Package Communication
Schema Changes
When changing tool schemas or contracts:- Update
packages/sharedfirst - Update
packages/mcp-serversecond - Update
packages/extensionlast - Re-check payload limits and omission rules
Asset Pipeline
Large binaries (images, fonts) are handled through the asset pipeline:- Extension uploads to asset store
- MCP server serves via HTTP
- Results include
asset://URIs, not base64 data
Package Manager
TemPad Dev uses pnpm with workspace features:- Workspace scripts run with
pnpm -r <script> - Filter specific packages with
pnpm --filter <package> <script> - Root-level commands orchestrate cross-package operations
Build Tools
- Extension: WXT (Web Extension Toolkit)
- MCP Server: tsdown
- Plugins: tsdown
- Shared: tsdown
Testing Architecture
- Test runner: Vitest
- Browser tests: @vitest/browser-playwright + Chromium
- Coverage provider: Istanbul
- Workspace config: Root
vitest.config.ts+vitest.workspace.ts