Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
20e922a
feat: add mcp server
Justineo Jun 20, 2025
b49738e
refactor: extract separate tools file
Justineo Jul 18, 2025
a3f0322
fix: fix mcp stdio binding, adjust tool registration and error handling
Justineo Nov 17, 2025
58063a4
feat: implement wss with multiple port candidates and improved error …
Justineo Nov 17, 2025
9bbd345
feat: build mcp cli, improve tool registration types
Justineo Nov 17, 2025
8e935c4
refactor: improve directory resolution and logging setup in shared mo…
Justineo Nov 17, 2025
efbfdf6
feat: enhance configuration parsing for WS ports and tool timeout
Justineo Nov 17, 2025
2a863dd
docs: add Node.js version requirement to README
Justineo Nov 17, 2025
b2a8492
fix: update SelectOption interface to provide default type and adjust…
Justineo Nov 17, 2025
03fa49e
feat: integrate MCP functionality and code generation improvements
Justineo Nov 19, 2025
8b74a15
feat: update configuration for MCP, enhance build process and logging
Justineo Nov 19, 2025
b6a4d87
feat: add ensureFile function to manage lock file creation
Justineo Nov 19, 2025
606dba9
feat: enhance MCP connection management with document visibility hand…
Justineo Nov 19, 2025
73661b6
feat: implement MCP section with segmented control for enabling/disab…
Justineo Nov 20, 2025
e38a576
feat: enhance MCP connection management with idle and window focus ha…
Justineo Nov 20, 2025
51750b8
feat: refine MCP connection logic to incorporate runtime mode checks
Justineo Nov 20, 2025
8025892
feat: enhance Badge component with dynamic tone and variant props, im…
Justineo Nov 20, 2025
5205e47
feat: enhance MCP badge with active/inactive states and corresponding…
Justineo Nov 20, 2025
13cdc6d
feat: implement MCP client management with dynamic icons and deep lin…
Justineo Nov 20, 2025
c105794
feat: enhance MCP client configuration with deep link support and dyn…
Justineo Nov 21, 2025
460a6e0
feat: update MCP section with new toggle functionality and improved l…
Justineo Nov 21, 2025
c9b59d0
feat: enhance copy functionality with customizable messages for comma…
Justineo Nov 21, 2025
1815561
feat: reorganize MCP utilities and define tool handlers with new schema
Justineo Nov 22, 2025
606b013
feat: remove SelectionNode, implement new MCP tools for codegen, scre…
Justineo Nov 22, 2025
738c52d
refactor: use semantic tree utilities
Justineo Nov 22, 2025
934f302
refactor: simplify node type checks and improve readability in semant…
Justineo Nov 22, 2025
2b3cd97
feat: implement get_code (wip), move /mcp -> /mcp-server, /utils/mcp …
Justineo Nov 22, 2025
5128621
feat: update handleGetCode to accept multiple nodes and refactor stri…
Justineo Nov 22, 2025
9b58c19
feat: enhance type definitions and code generation utilities
Justineo Nov 24, 2025
c2f7a17
feat: improve variable handling and refactor code for better readabil…
Justineo Nov 24, 2025
03a2c9e
feat: resolve depth limit in handleGetStructure for improved tree bui…
Justineo Nov 24, 2025
ea4a58b
feat: simplify token definitions by removing unused properties and re…
Justineo Nov 24, 2025
99d6802
fix: fix duplicated identifier issue
Justineo Nov 24, 2025
a491db3
feat: deduplicate variable tokens in resolveVariableTokens function
Justineo Nov 24, 2025
f38957d
feat: enhance token handling and CSS variable normalization
Justineo Nov 24, 2025
2b40d12
feat: improve tailwind codegen, support rich text
Justineo Nov 24, 2025
87dc5d5
feat: enhance tailwind utility functions for improved grid and displa…
Justineo Nov 25, 2025
7ae8ff2
chore: rerun pnpm install
Justineo Nov 25, 2025
1c12550
feat: enhance MCP client configuration with support for brand color a…
Justineo Nov 25, 2025
d493c5b
refactor: update ESLint configuration, run format
Justineo Nov 25, 2025
a0b0c9d
feat: update MCP configuration to include deep link for TRAE and modi…
Justineo Nov 25, 2025
c75e460
feat: enhance tailwind utility functions to support border color hand…
Justineo Nov 26, 2025
23ccf7d
feat: enhance style to tw, refactor and reorganize code
Justineo Nov 27, 2025
d76be4e
refactor: enhance CSS utility functions and Tailwind configuration
Justineo Nov 28, 2025
e882020
feat: refactor code generation and style handling for improved backgr…
Justineo Nov 28, 2025
d7480aa
refactor: use number utility for consistent numeric formatting
Justineo Nov 28, 2025
83e6590
refactor: streamline comments and enhance regex patterns for backgrou…
Justineo Nov 28, 2025
5e4bb7c
refactor: replace normalizeComparableValue with canonicalizeValue for…
Justineo Nov 28, 2025
56de72a
refactor: replace KEEP_PX_PROPS array with Set for improved performan…
Justineo Nov 28, 2025
ec9c10b
refactor: update tailwind utility functions and enhance shorthand par…
Justineo Nov 28, 2025
4c70c43
refactor: enhance variable handling and normalize CSS values in rende…
Justineo Nov 28, 2025
1d7a43a
refactor: integrate CodegenConfig and streamline variable handling in…
Justineo Nov 28, 2025
9f7bd36
refactor: revert codegenOptions
Justineo Nov 28, 2025
d31f75a
refactor: enhance variable handling by integrating CodegenConfig and …
Justineo Nov 28, 2025
9e0d5bf
refactor: remove unused functions and hardcode variable resolution in…
Justineo Nov 28, 2025
8957c89
refactor: enhance style processing by adding injectFills option and u…
Justineo Nov 28, 2025
90897a6
refactor: centralize MCP configuration and enhance port candidate han…
Justineo Nov 28, 2025
5a4a87b
refactor: implement payload size checks for structure and token defin…
Justineo Nov 28, 2025
a113a76
refactor: improve error messages for payload size limits in structure…
Justineo Nov 28, 2025
02fc412
refactor: improve SVG string decoding in collectSceneData function
Justineo Nov 28, 2025
b1ee220
feat: update parameter handling to use single nodeId instead of nodeI…
Justineo Nov 28, 2025
69c758a
fix: fix SVG/image size scaling in code generation
Justineo Nov 28, 2025
93261e9
feat: enhance style processing and rendering logic with new preproces…
Justineo Nov 30, 2025
80bfa26
feat: enhance component serialization with inline option and compact …
Justineo Dec 1, 2025
570ee90
feat: enhance text style handling and improve component serialization…
Justineo Dec 1, 2025
bb1bad4
feat: enhance grid layout handling and improve component serializatio…
Justineo Dec 1, 2025
e95663c
feat: enhance token handling by exporting token reference functions a…
Justineo Dec 1, 2025
3d396e3
feat: enhance GetCodeParametersSchema by adding resolveTokens option …
Justineo Dec 2, 2025
6dc7264
feat: add shadow stripping functionality for non-renderable fills
Justineo Dec 2, 2025
8ccdd29
feat: add asset upload functionality and HTTP server
Justineo Dec 4, 2025
fb2e4f0
feat: implement asset upload and download functionality with HTTP ser…
Justineo Dec 4, 2025
6c3fc71
feat: enhance asset management with improved upload handling, metadat…
Justineo Dec 4, 2025
b2bab6d
feat: standardize mime type property across asset handling and improv…
Justineo Dec 4, 2025
95d659a
chore: update package versions
Justineo Dec 4, 2025
248ff99
feat: enhance error handling with detailed logging for socket closure…
Justineo Dec 4, 2025
04f7325
feat: enhance tool metadata definitions and add asset handling capabi…
Justineo Dec 5, 2025
ead927a
feat: hide get_assets, add resource links to get_code output
Justineo Dec 5, 2025
13dc4a5
feat: refactor tool metadata handling and enhance MCP instructions fo…
Justineo Dec 5, 2025
e92f061
feat: enhance MCP instructions and update tool definitions for improv…
Justineo Dec 5, 2025
4feff67
feat: add MCP server documentation and enhance parameter descriptions…
Justineo Dec 5, 2025
a1d78e5
chore: update version to 0.3.0 and enhance README with setup instruct…
Justineo Dec 5, 2025
5470315
feat: improve selection synchronization and add border shorthand pars…
Justineo Dec 6, 2025
3a28c67
feat: enhance auto layout inference and improve border shorthand parsing
Justineo Dec 6, 2025
5f80cf7
feat: refactor Figma readiness checks and enhance recovery handling
Justineo Dec 6, 2025
c784d57
feat: enhance layout hint logic to consider display styles and class …
Justineo Dec 6, 2025
e7f3ba7
feat: improve Figma recovery logic and visibility handling
Justineo Dec 6, 2025
7c537ef
feat: enhance data hint composition and add toPascalCase utility func…
Justineo Dec 6, 2025
7142098
fix: correct variable initialization in mergeAttributes function
Justineo Dec 6, 2025
5b903a3
feat: export syncSelection function and add runtimeMode watcher
Justineo Dec 8, 2025
8e4512f
feat: improve asset upload logging and enhance SVG attribute extraction
Justineo Dec 8, 2025
545e821
chore: bump version for mcp-server
Justineo Dec 8, 2025
274aa25
feat: update MCP server to use latest version and improve logging
Justineo Dec 8, 2025
1f361bb
feat: update code snippet summary formatting to use backticks for lan…
Justineo Dec 8, 2025
51cd163
feat: remove MCP instructions file and update related schemas and typ…
Justineo Dec 9, 2025
40e1ef2
chore: bump mcp version
Justineo Dec 9, 2025
950bfe9
build: add loader configuration for markdown files in build script
Justineo Dec 9, 2025
94a61e4
refactor: reorganize modules for get_code tool
Justineo Dec 9, 2025
ef9d22e
refactor: improve worker-related module organization and naming
Justineo Dec 9, 2025
bbc3e30
feat: add deep link guard and support fallbackDeepLink
Justineo Dec 9, 2025
7f7f404
refactor: streamline style processing pipeline and remove unused options
Justineo Dec 10, 2025
0c2f27e
refactor: simplify isWrapper function and extract helper methods for …
Justineo Dec 10, 2025
e0a9233
feat: update MCP hash pattern and length for asset validation
Justineo Dec 10, 2025
e2ec93d
feat: enhance token handling and improve type definitions for better …
Justineo Dec 11, 2025
3d8d82d
feat: enhance token entry structure and improve resolved value handling
Justineo Dec 11, 2025
a26e7f3
feat: improve Figma availability handling with dedicated announcement…
Justineo Dec 11, 2025
3714748
chore: bump mcp-server version
Justineo Dec 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions .eslintrc.cjs

This file was deleted.

6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!-- markdownlint-disable MD033 -->

# Changelog

## 0.14.0

- Added MCP server support to let agents/IDEs pull code, structure, and screenshots from your current Figma selection.

## 0.13.1

- Fixed select component style under dark mode.
Expand Down
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,47 @@ Current available plugins:
<!-- availablePlugins:end -->
<!-- prettier-ignore-end -->

## MCP server

TemPad Dev ships an [MCP](https://modelcontextprotocol.io/) server so agents/IDEs can pull code and context directly from the node you have selected in Figma. With the TemPad Dev panel open and MCP enabled, the server exposes:

- `get_code`: High-fidelity JSX/Vue + TailwindCSS code output by default, plus attached assets and the codegen preset/config used.
- `get_structure`: A structural outline (ids, types, geometry) for the current selection.
- `get_screenshot`: A PNG capture with a `resourceUri` and direct HTTP download URL.
- `tempad-assets` resource template (`asset://tempad/{hash}`) for any binaries returned by the tools above.

### Setup guide

1. Requirements: Node.js 18+ and TemPad Dev running in a Figma tab.
2. In TemPad Dev, open **Preferences → MCP server** and toggle **Enable MCP server**.
3. Use the quick actions in Preferences to install/connect, or add the server manually to your MCP client as a stdio command:

```json
{
"mcpServers": {
"TemPad Dev": {
"command": "npx",
"args": ["-y", "@tempad-dev/mcp@latest"]
}
}
}
```

For CLI-style installers, the equivalent commands are `claude mcp add --transport stdio "TemPad Dev" -- npx -y @tempad-dev/mcp@latest` or `codex mcp add "TemPad Dev" -- npx -y @tempad-dev/mcp@latest`.

4. Keep the TemPad Dev tab active while using MCP. If you have multiple Figma files (and thus multiple TemPad Dev extensions) open, click the MCP badge in the TemPad Dev panel to activate the correct file for your agent.

### Configuration

Optional environment variables for `@tempad-dev/mcp`:

- `TEMPAD_MCP_TOOL_TIMEOUT` (default `15000`): Tool call timeout in milliseconds.
- `TEMPAD_MCP_AUTO_ACTIVATE_GRACE` (default `1500`): Delay before auto-activating the sole connected extension.
- `TEMPAD_MCP_MAX_ASSET_BYTES` (default `8388608`): Maximum upload size for captured assets/screenshots (bytes).
- `TEMPAD_MCP_RUNTIME_DIR` (default `${TMPDIR}/tempad-dev/run`): Where the hub stores its socket/lock files.
- `TEMPAD_MCP_LOG_DIR` (default `${TMPDIR}/tempad-dev/log`): Where MCP logs are written.
- `TEMPAD_MCP_ASSET_DIR` (default `${TMPDIR}/tempad-dev/assets`): Storage for exported assets referenced by `resourceUri`.

<details>
<summary><h3>Inspect TemPad component code</h3></summary>

Expand Down
2 changes: 1 addition & 1 deletion build/readme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function getDomain(url: string) {
try {
const { hostname } = new URL(url)
return hostname
} catch (error) {
} catch {
console.error('Invalid URL:', url)
return null
}
Expand Down
131 changes: 0 additions & 131 deletions codegen/codegen.ts

This file was deleted.

67 changes: 67 additions & 0 deletions codegen/requester.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
let id = 0

export type RequestMessage<T = unknown> = {
id: number
payload: T
}

export type ResponseMessage<T = unknown> = {
id: number
payload?: T
error?: unknown
}

type PendingRequest<T = unknown> = {
resolve: (result: T) => void
reject: (reason?: unknown) => void
}

const pending = new Map<number, PendingRequest>()

type WorkerClass = {
// Bundler-provided worker classes expose a zero-arg constructor
new (): Worker
}

type WorkerRequester<T = unknown, U = unknown> = (payload: T) => Promise<U>

const cache = new WeakMap<WorkerClass, unknown>()

export function createWorkerRequester<T, U>(Worker: WorkerClass) {
if (cache.has(Worker)) {
return cache.get(Worker) as WorkerRequester<T, U>
}

const worker = new Worker()

worker.onmessage = ({ data }: MessageEvent<ResponseMessage<U>>) => {
const { id, payload, error } = data

const request = pending.get(id)
if (request) {
if (error) {
request.reject(error)
} else {
request.resolve(payload)
}
pending.delete(id)
}
}

const request: WorkerRequester<T, U> = function (payload: T): Promise<U> {
return new Promise((resolve, reject) => {
pending.set(id, {
resolve: (result) => resolve(result as U),
reject
})

const message: RequestMessage<T> = { id, payload }
worker.postMessage(message)
id++
})
}

cache.set(Worker, request)

return request
}
Loading