Skip to content

feat: Blocks fork hardening — deps, no telemetry, per-request Figma token, rename to @blocksuser/mcp-figma - #1

Draft
cubeorgdev[bot] wants to merge 19 commits into
mainfrom
feat/blocks-fork-hardening
Draft

cubeorgdev[bot] wants to merge 19 commits into
mainfrom
feat/blocks-fork-hardening

Conversation

@cubeorgdev

@cubeorgdev cubeorgdev Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Hardens the fork for use as the Figma MCP server inside Blocks sandboxes (plan "Repo 4"). 15 commits, each one logical step; review in order.

What changes

  • Dependency audit 111 advisories (1 critical) → 0: @modelcontextprotocol/sdk ^1.32.2 (server API unchanged), undici ^7.30.1, express ^5.3.0, js-yaml ^4.3.2, zod 4, @jimp/* ^1.6.1, @figma/rest-api-spec ^0.47.0, plus pnpm.overrides for the transitive stragglers (proxy-addr, body-parser, qs, path-to-regexp, hono, @hono/node-server, express-rate-limit, ip-address, fast-uri). pnpm audit --prod --audit-level=high is now a CI gate; dependabot runs weekly. Upstream PR chore(deps): clear pnpm audit advisories in the production tree GLips/Figma-Context-MCP#405 was inspected and superseded.
  • Tombstone test keeps child_process / exec() out of src/ (CVE-2025-53967 / CVE-2025-15061 were that curl fallback).
  • Telemetry removed (PostHog, posthog-node, --no-telemetry, the FRAMELINK_TELEMETRY / DO_NOT_TRACK opt-outs). stdio mode no longer auto-loads ./.env from its cwd (a user repo's .env must not override the host-injected token); --env <path> still works.
  • Credentials resolved on every request (the Linear model): token file (--figma-oauth-token-file / FIGMA_OAUTH_TOKEN_FILE, default ~/.config/figma/.oauth_token) > FIGMA_OAUTH_TOKEN > FIGMA_API_KEY. On a 401 the credential is re-resolved; if it changed the request is retried once, otherwise (or on a second 401) the tool returns an actionable error that names get_new_figma_token and the one-live-token-per-app-per-user rule. 403 / 429 handling and HTTP-mode per-request header auth are unchanged.
  • Figma API congruence: rest-api-spec 0.47 (SLOT component properties handled explicitly, no more as casts hiding the widened union) and upstream PRs feat: fetch multiple Figma nodes in one get_figma_data call GLips/Figma-Context-MCP#404 (multi-node get_figma_data), fix: envInt returns NaN for non-numeric env vars GLips/Figma-Context-MCP#410, fix: preserve node rotation, true size, ink bounds, and explicit line breaks GLips/Figma-Context-MCP#420, fix: pass unknown paint types through marked instead of throwing GLips/Figma-Context-MCP#421 (unknown paint types pass through), fix: emit valid CSS for text shadows GLips/Figma-Context-MCP#427 cherry-picked. Reviewer note: fix: preserve node rotation, true size, ink bounds, and explicit line breaks GLips/Figma-Context-MCP#420 adds geometry=paths to file/node fetches (needed for ink bounds), which enlarges responses on vector-heavy files.
  • Five read-only REST tools for parity with the official Figma MCP where it matters to coding agents: whoami, get_figma_comments, get_figma_file_versions, get_figma_dev_resources, get_figma_components_and_styles. No write tools.
  • Renamed to @blocksuser/mcp-figma (bin mcp-figma), repo links → BlocksOrg. README gets a "Blocks fork" section (why it exists, how to merge upstream) and documents the credential contract.
  • Publishing mirrors BlocksOrg/mcp-linear: release-please and OIDC trusted publishing are gone. scripts/publish.sh <patch|minor|major> [--rc] [--dry-run] is mcp-linear's local publish script ported to pnpm (bump package.json + server.json, build, pnpm publish --access public --tag latest|rc; dry-run verified: 0.13.2 → 0.14.0, 15-file tarball), and .github/workflows/publish.yml is a manual workflow_dispatch (bump = patch / minor / major) that type-checks, tests, builds, bumps package.json + server.json, tags vX.Y.Z, creates the GitHub Release and runs pnpm publish --access public with the NPM_TOKEN secret. Nothing publishes on merge. /release command, CLAUDE.md and CONTRIBUTING.md updated.

Gates on HEAD

pnpm type-check clean · pnpm test 304 passed / 1 skipped (live-API suite gated on RUN_FIGMA_INTEGRATION) · pnpm build OK · pnpm audit --prod "No known vulnerabilities found".

Before the first release

  • Add the NPM_TOKEN repository secret (only needed for the GitHub workflow path) (the same @blocksuser org token mcp-linear publishes with).
  • 0.14.0-rc.2 is already published under the rc dist-tag (locally, via scripts/publish.sh minor --rc). For the stable release, publish v0.14.0 either locally (npm login as an @blocksuser member, ./scripts/publish.sh minor, then commit the bump, tag v0.14.0, git push --follow-tags) or by running the Publish to npm workflow with minor. --access public is set in both.
  • Then add "@blocksuser/mcp-figma": "^0.14.0" to every dependencies/*.package.json in BlocksOrg/agents and re-point orchestration-svc's src/mcp/directory.json entry from figma-developer-mcp@0.13.2 to @blocksuser/mcp-figma (drop the Dockerfile preinstall and the telemetry env; orchestration-svc #1733 ships with the upstream pin as a stopgap).

Companion PRs: orchestration-svc #1733, agents #574, client-monorepo #1258.

🤖 Generated with BLOCKS!

tomislav-blocks and others added 15 commits November 19, 2026 17:25
CVE-2025-53967 and CVE-2025-15061 were a curl fallback built with
child_process.exec. The code is already gone; this keeps it gone through
future upstream cherry-picks.

🤖 Generated with BLOCKS!
- @modelcontextprotocol/sdk 1.29.0 -> ^1.32.2 (OAuth credential leak to the
  wrong AS, unbounded request body, task/session binding); server API unchanged
- undici ^7.30.1, express ^5.3.0, js-yaml ^4.3.2, zod ^4.6.6 (memory
  exhaustion on oversized collections; schemas needed no changes)
- @figma/rest-api-spec ^0.47.0 (May-Oct 2026 API additions)
- @jimp/* ^1.6.1: moves jimp off file-type 16 (ASF parser loop) on its own
- pnpm.overrides for transitives upstream ranges still allow: proxy-addr
  (critical, IP spoofing), body-parser, qs, path-to-regexp, hono,
  @hono/node-server, express-rate-limit, ip-address, fast-uri, and zod for
  @jimp/types (it only validates jimp's own option objects; image tests pass)
- CI: pnpm audit --prod --audit-level=high gate; dependabot weekly (npm +
  actions)

Supersedes upstream PR GLips#405 (older versions of the same overrides).

🤖 Generated with BLOCKS!
A Blocks-maintained fork must not phone home: drop src/telemetry (PostHog)
and posthog-node, the --no-telemetry flag, FRAMELINK_TELEMETRY / DO_NOT_TRACK,
and the per-call outcome hooks that only existed to feed it. The
validateToolInput monkey patch stays, reduced to its user-facing half
("Invalid <field>: <message>"), as src/mcp/validation-errors.ts.

A stdio server is spawned with an arbitrary cwd — in a Blocks sandbox the
user's repository — so it no longer auto-loads ./.env (dotenv's override:true
would let a repo file replace the host-injected credentials). An explicit
--env <path> still loads; HTTP mode and the fetch CLI keep the implicit load.

🤖 Generated with BLOCKS!
parseInt("abc", 10) returns NaN which propagated as a valid number
through the config system — setting PORT=abc would try to listen on
port NaN. added isNaN check so non-numeric values are skipped.

(cherry picked from commit 1fe9b8b)

🤖 Generated with BLOCKS!
parsePaint threw on any paint type outside its known set, and the throw
failed the entire get_figma_data request. Paint types absent from the
REST spec reach real files (Figma code-component CUSTOM paints, observed
2026-08-22), so one such paint on one node made a whole file/subtree
uncapturable.

Unknown paint types now return { type, unknownPaint: true, raw } with
the original paint preserved, log an error line, and leave the rest of
the simplification untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
(cherry picked from commit 5fdb960)

🤖 Generated with BLOCKS!
(cherry picked from commit ad28cd4)

🤖 Generated with BLOCKS!
… breaks

(cherry picked from commit db3081a)

🤖 Generated with BLOCKS!
(cherry picked from commit 11df79a)

🤖 Generated with BLOCKS!
(cherry picked from commit 78e6168)

🤖 Generated with BLOCKS!
Normalize both API response shapes into a common slice list so
parseAPIResponse aggregates roots/components/styles declaratively, and
make the metrics pass (countNamedStyles, detectVariables) skip null node
entries so a partial miss (some ids resolve, some don't) no longer
crashes with a TypeError after simplify. Also surface skipped ids via
Logger, tighten the nodeId regex grammar, and add cross-node dedup +
partial-miss regression tests.

(cherry picked from commit d96cfb9)

🤖 Generated with BLOCKS!
A multi-node fetch where some ids resolve and others don't previously
only logged the gap server-side, so the LLM could act on an incomplete
design as if it were complete. Carry missingNodeIds onto SimplifiedDesign
(present only when non-empty, so the common case costs no tokens) and
render a MISSING_NODES line in the tree format; YAML/JSON pick it up via
metadata.

(cherry picked from commit 5637d60)

🤖 Generated with BLOCKS!
The spec now types ComponentProperty.value / ComponentPropertyDefinition
.defaultValue as boolean | string | SlotContentId (new SLOT kind). The two
casts in built-in.ts had been hiding the union; the simplifiers now take the
spec types and narrow on the property kind, so a SLOT guid can never reach
the flat name -> scalar output. VariableValue's new VariableComposedColor
needs nothing: no code narrows VariableValue.

Also reconciles the endpoint assertions from upstream GLips#404 with the
geometry=paths query upstream GLips#420 added (the two PRs never met upstream).

🤖 Generated with BLOCKS!
… on 401

Figma keeps one live access token per app per user, so a refresh by the
issuer (the Blocks OAuth monitor) kills the token a long-running server read
at startup. FigmaService now takes a CredentialSource evaluated per request:
token file (--figma-oauth-token-file / FIGMA_OAUTH_TOKEN_FILE, default
~/.config/figma/.oauth_token) -> --figma-oauth-token / FIGMA_OAUTH_TOKEN ->
--figma-api-key / FIGMA_API_KEY. On a 401 it re-resolves and retries once
only if the token changed; otherwise (or on a second 401) it throws a message
that names get_new_figma_token and the one-token rule.

HTTP per-request header auth is unchanged (fixed for that request). The
static FigmaAuthOptions triple is still accepted everywhere, wrapped as a
constant source, so existing callers and tests are untouched. The 403 and
429 messages are as before.

🤖 Generated with BLOCKS!
package name / bin (figma-mcp) / repository / homepage / mcpName and
server.json now point at BlocksOrg; the release workflow's owner gate follows,
pnpm publish gets --access public (scoped first publish), and the MCP registry
steps are non-fatal (the registry listing is optional for the fork). README
gains a Blocks fork section (why it exists, how to merge upstream) and the
install snippets use the new package; FUNDING.yml (upstream's sponsor
button) is removed.

🤖 Generated with BLOCKS!
…gma MCP

whoami (GET /v1/me), get_figma_comments, get_figma_file_versions,
get_figma_dev_resources and get_figma_components_and_styles, each a lean YAML
projection of the Figma response (author handle instead of the user object,
pinned node id, reply threading; empty/null fields dropped). They share one
SimpleTool contract so registration is a loop, and all carry readOnlyHint.
No write tools.

🤖 Generated with BLOCKS!
@cubeorgdev

cubeorgdev Bot commented Nov 19, 2026

Copy link
Copy Markdown
Author

This pull request was created from a Blocks session.

View in dashboard | View on desktop

Created as a draft. To change this setting visit Git Settings.

Comment thread src/config.ts
`- FIGMA_OAUTH_TOKEN_FILE: ${figmaOauthTokenFile.value || "(disabled)"} (source: ${configSources.figmaOauthTokenFile})`,
);
if (credential?.kind === "oauth") {
console.log(`- OAuth token: ${maskApiKey(credential.token)} (source: ${credential.source})`);
Comment thread src/config.ts
`- FIGMA_API_KEY: ${maskApiKey(auth.figmaApiKey)} (source: ${configSources.figmaApiKey})`,
);
} else if (credential) {
console.log(`- API key: ${maskApiKey(credential.token)} (source: ${credential.source})`);
function stubFigmaResponse(makeResponse: () => Response) {
const realFetch = globalThis.fetch;
fetchMock = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
if (String(input).startsWith("https://api.figma.com")) {
@cubeorgdev

cubeorgdev Bot commented Nov 19, 2026

Copy link
Copy Markdown
Author

Test from the pr-update-automation automation.

…se-please)

`publish.yml` (workflow_dispatch, bump = patch|minor|major) type-checks,
tests, builds, bumps package.json + server.json, commits and tags
`vX.Y.Z`, creates the GitHub Release with generated notes and runs
`pnpm publish --access public` with the org `NPM_TOKEN` secret — the same
one-button flow BlocksOrg/mcp-linear uses. Release-please config, the
OIDC trusted-publishing job and the MCP-registry publish step are removed;
CLAUDE.md, CONTRIBUTING.md and the /release command describe the new flow.

🤖 Generated with BLOCKS!
Same arguments and behaviour as BlocksOrg/mcp-linear/scripts/publish.sh
(`<patch|minor|major> [--rc]`, rc dist-tag, rc-number bump when already an
rc), plus `--dry-run` and the server.json version sync. Force-added: the
upstream .gitignore ignores scripts/ wholesale while tracking the files in it.

🤖 Generated with BLOCKS!
… on PATH

mcp-linear is an npm project, so its publish.sh never needed pnpm; this fork is
pnpm-only (lockfile, packageManager pin, overrides, prepack). The script now uses
the pinned pnpm through npx when none is installed and runs install when
node_modules is missing, so a machine with only Node + npm can publish.

🤖 Generated with BLOCKS!
…er/mcp-linear)

Published as @blocksuser/mcp-figma@0.14.0-rc.2; package.json / server.json
now carry that name and version, and every reference (bin, README, publish
script, issue template, tests) follows.

🤖 Generated with BLOCKS!
@cubeorgdev cubeorgdev Bot changed the title feat: Blocks fork hardening — deps, no telemetry, per-request Figma token, rename to @blocksuser/figma-mcp feat: Blocks fork hardening — deps, no telemetry, per-request Figma token, rename to @blocksuser/mcp-figma Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants