Skip to content

refactor: remove Figma MCP analysis path#125

Merged
let-sunny merged 3 commits intomainfrom
refactor/remove-figma-mcp-analysis
Mar 27, 2026
Merged

refactor: remove Figma MCP analysis path#125
let-sunny merged 3 commits intomainfrom
refactor/remove-figma-mcp-analysis

Conversation

@let-sunny
Copy link
Copy Markdown
Owner

@let-sunny let-sunny commented Mar 27, 2026

Summary

Remove the Figma MCP → canicode analysis path. -1,659 lines.

canicode MCP server is kept — only the Figma MCP data input is removed.

Why

Figma MCP get_metadata returns collapsed nodes — same design produces 1 node (MCP) vs 291 nodes (CLI). Analysis via Figma MCP is meaningless:

CLI (REST API) Figma MCP
Nodes 291 1
Issues 198 0
Grade D (59%) S (100%)

What's removed

File What
src/core/adapters/figma-mcp-adapter.ts MCP XML parser + enrichment
src/core/adapters/tailwind-parser.ts Tailwind class → Figma property converter
src/core/engine/design-data-parser.ts MCP XML parsing (no other callers)
src/mcp/server.ts designData, designContext, fileKey, fileName params
docs/MCP-VS-CLI.md MCP vs CLI comparison doc
.claude/commands/calibrate-loop-deep.md Figma MCP calibration command
.claude/commands/mcp-vs-cli.md MCP vs CLI test command
.claude/skills/canicode/SKILL.md Rewritten to CLI-based workflow
src/cli/commands/init.ts --mcp option removed
src/cli/docs.ts Figma MCP setup/comparison sections removed
src/cli/index.ts --mcp help line removed
.mcpb designData, designContext, customRulesPath params removed
CLAUDE.md Figma MCP references removed
README.md Figma MCP rate limit pool, comparison table removed
docs/CALIBRATION.md calibrate-loop-deep example removed
.claude/agents/calibration/converter.md MCP tool reference removed

What's kept

  • canicode MCP server (src/mcp/) — still serves analyze, list-rules, visual-compare, version, docs tools via REST API input param
  • CLI — unchanged
  • REST API integration — the only Figma data source
  • All analysis rules and scoring

Test plan

  • 625 tests pass
  • Type check clean
  • grep -rn "Figma MCP\|get_metadata\|designData\|designContext" . --include="*.ts" --include="*.md" --include="*.json" | grep -v node_modules | grep -v worktrees — clean

Closes #124

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Removed MCP-specific guides and comparisons; updated docs to a CLI-first data source model requiring a Figma API token.
    • Deleted MCP-based calibration and MCP-vs-CLI docs; clarified offline calibration workflow.
  • Refactor

    • Removed Figma MCP integration and MCP-dependent pathways; analysis now uses the CLI/REST input model.
    • Simplified setup and help text to require a Figma API token (removed MCP setup option).
  • Chores

    • Cleaned up MCP adapters, parser modules, and associated test suites.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 46e360ca-2aa4-4451-aae0-334f54be3b6f

📥 Commits

Reviewing files that changed from the base of the PR and between a1a51b7 and a6c1f7d.

📒 Files selected for processing (2)
  • .mcpb
  • src/mcp/server.ts

📝 Walkthrough

Walkthrough

The PR removes Figma MCP as a direct design-data source across code, tests, CLI, docs, and MCP tool schema, consolidating analysis inputs to a single input (Figma URL or local fixture) requiring FIGMA_TOKEN or pre-saved fixtures; several MCP-specific parsers, enrichers, and tests were deleted.

Changes

Cohort / File(s) Summary
Core Adapter Removal
src/core/adapters/figma-mcp-adapter.ts, src/core/adapters/tailwind-parser.ts, src/core/adapters/tailwind-parser.test.ts, src/core/adapters/index.ts
Deleted MCP XML parser, Tailwind class parsing utilities, related tests, and removed re-export from adapters index.
Design Data Parser
src/core/engine/design-data-parser.ts, src/core/engine/design-data-parser.test.ts
Removed parsing logic that autodetected XML (MCP) vs REST JSON and associated tests; design data is now expected as fixture JSON or REST API output only.
MCP Server & Tool Schema
src/mcp/server.ts, .mcpb
analyze tool now requires a single input (Figma URL or fixture); removed designData, designContext, fileKey, fileName, and customRulesPath inputs; handler simplified to always load via REST/fixture path.
CLI Changes
src/cli/commands/init.ts, src/cli/index.ts, src/cli/docs.ts
Removed --mcp option and MCP setup/help; init and CLI help now present token-based setup only; docs updated to require FIGMA_TOKEN.
Calibration & Comparison Scripts
.claude/commands/calibrate-loop-deep.md, .claude/commands/mcp-vs-cli.md, .claude/commands/calibrate-loop.md, docs/MCP-VS-CLI.md
Deleted deep calibration and MCP-vs-CLI orchestration/comparison scripts and references; /calibrate-loop description adjusted to remove MCP mention.
Skills, Docs & Readme
.claude/skills/canicode/SKILL.md, CLAUDE.md, README.md, docs/CALIBRATION.md
Replaced MCP/CLI hybrid docs with REST/fixture-only workflow, updated examples and token guidance, removed MCP-specific sections; updated rule counts and categories in docs.
Tests Removed
src/core/adapters/tailwind-parser.test.ts, src/core/engine/design-data-parser.test.ts
Unit test suites that targeted MCP parsing/enrichment and Tailwind-derived style parsing were removed.
Metadata Updates
.mcpb
Tool metadata adjusted to reflect reduced rule set (29 rules / 5 categories) and input contract changes.
Other
.claude/agents/calibration/converter.md, .claude/commands/calibrate-loop-deep.md, .claude/commands/mcp-vs-cli.md
Docs and agent instructions updated/removed to eliminate MCP-based converter and workflows.

Sequence Diagram(s)

(Section intentionally omitted — changes are removals/refactors without a new multi-component sequential flow requiring visualization.)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Poem

🐰 I hop away from MCP’s small tree,
Raw REST and fixtures set the data free.
Tokens in paw, fixtures tucked tight,
Canicode dances in clearer light.
Crunching nodes, troubleshooting bites—yum, delight! 🥕✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor: remove Figma MCP analysis path' directly and clearly summarizes the main objective of this changeset.
Linked Issues check ✅ Passed The PR fully addresses all coding objectives from issue #124: removes MCP adapters, updates design-data-parser, modifies MCP server tool schema, updates CLI and documentation, while preserving canicode MCP server and analysis functionality.
Out of Scope Changes check ✅ Passed All changes are directly scoped to removing Figma MCP as an analysis input source while preserving the canicode MCP server and REST API workflow, with no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/remove-figma-mcp-analysis

Comment @coderabbitai help to get the list of available commands and usage tips.

@let-sunny let-sunny marked this pull request as ready for review March 27, 2026 05:06
@let-sunny let-sunny marked this pull request as draft March 27, 2026 05:07
Figma MCP get_metadata returns collapsed nodes (1 node vs 291 from REST API),
making MCP-based analysis meaningless (S/100% vs D/59% for same design).

Removed:
- src/core/adapters/figma-mcp-adapter.ts — MCP XML parser + enrichment
- src/core/adapters/tailwind-parser.ts — Tailwind → Figma property converter
- src/core/engine/design-data-parser.ts — MCP XML parsing (unused after removal)
- MCP server: designData/designContext params from analyze tool
- CLI: --mcp option from init, Figma MCP references from docs
- docs/MCP-VS-CLI.md, calibrate-loop-deep command, mcp-vs-cli command
- Skill: rewritten to CLI-based workflow (no Figma MCP dependency)

Kept:
- canicode MCP server (src/mcp/) — analyze via REST API input
- CLI, REST API integration, design-tree, all rules

Closes #124

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@let-sunny let-sunny force-pushed the refactor/remove-figma-mcp-analysis branch from 8129142 to e198c5f Compare March 27, 2026 05:14
Clean up stale references to the removed Figma MCP analysis path:
- .mcpb: remove designData/fileKey/fileName/customRulesPath params, MCP example
- src/cli/index.ts: remove --mcp help text
- CLAUDE.md: remove Figma MCP note and simplify calibration description
- docs/CALIBRATION.md: remove calibrate-loop-deep reference
- .claude/: remove Figma MCP mentions from calibration commands/agents
- README.md: remove "Or use MCP" rate limit advice

Made-with: Cursor
@let-sunny let-sunny marked this pull request as ready for review March 27, 2026 05:23
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
.mcpb (2)

4-4: ⚠️ Potential issue | 🟡 Minor

Rule count inconsistency with SKILL.md.

The description states "39 rules in 6 categories" but .claude/skills/canicode/SKILL.md line 61 states "29 rules across 5 categories" (Structure, Token, Component, Naming, Behavior). The README.md also confirms 29 rules across 5 dimensions.

📝 Proposed fix
-  "description": "Analyze Figma design structures for development-friendliness and AI-friendliness. Scores designs across 39 rules in 6 categories (layout, design tokens, components, naming, AI readability, handoff risk) and generates detailed HTML reports with actionable issues.",
+  "description": "Analyze Figma design structures for development-friendliness and AI-friendliness. Scores designs across 29 rules in 5 categories (structure, token, component, naming, behavior) and generates detailed HTML reports with actionable issues.",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.mcpb at line 4, The package description in the .mcpb file claims "39 rules
in 6 categories" but SKILL.md and README state "29 rules across 5 categories";
update the "description" value in the .mcpb diff to match the canonical text
used in .claude/skills/canicode/SKILL.md and README (e.g., change to "Analyze
Figma design structures for development-friendliness and AI-friendliness. Scores
designs across 29 rules in 5 categories (Structure, Token, Component, Naming,
Behavior) and generates detailed HTML reports with actionable issues.") so all
three places are consistent.

99-99: ⚠️ Potential issue | 🟡 Minor

Same rule count inconsistency in docs tool description.

This also references "39 rule IDs" which should be updated to match the actual rule count.

📝 Proposed fix
-      "description": "Get documentation on config overrides, custom rules, all 39 rule IDs with default scores, and example configurations.",
+      "description": "Get documentation on config overrides, custom rules, all 29 rule IDs with default scores, and example configurations.",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.mcpb at line 99, Update the "description" string in the .mcpb file so the
hard-coded "39 rule IDs" matches the actual rule count; locate the JSON property
named "description" (the line containing "Get documentation on config overrides,
custom rules, all 39 rule IDs with default scores, and example configurations.")
and change the numeric value to the correct count or make it dynamic/omit the
number so docs stay accurate.
src/mcp/server.ts (1)

98-104: ⚠️ Potential issue | 🟡 Minor

Telemetry source is hardcoded—should distinguish fixture vs URL.

The source field is always "url", but the input parameter can be either a Figma URL or a local fixture path. The MCP tool description explicitly states: "Provide a Figma URL or fixture path," and the internal loadFile function already distinguishes between them using isJsonFile(input) || isFixtureDir(input). The hardcoded source causes inaccurate analytics segmentation.

📊 Proposed fix

Add the import:

+import { isJsonFile, isFixtureDir } from "../core/engine/loader.js";

Then update the event at line 103:

       trackEvent(EVENTS.ANALYSIS_COMPLETED, {
         nodeCount: result.nodeCount,
         issueCount: result.issues.length,
         grade: scores.overall.grade,
         percentage: scores.overall.percentage,
-        source: "url",
+        source: isJsonFile(input) || isFixtureDir(input) ? "fixture" : "figma",
       });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/mcp/server.ts` around lines 98 - 104, The telemetry event currently
hardcodes source:"url" in the trackEvent call (EVENTS.ANALYSIS_COMPLETED);
change it to compute the source from the original input used to load the file by
reusing the same detection logic as loadFile (i.e., use isJsonFile(input) ||
isFixtureDir(input) to set source to "fixture" when true, otherwise "url"),
keeping the trackEvent call and event payload keys the same and referencing the
existing input parameter and the helper functions isJsonFile/isFixtureDir to
locate where to change it.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/cli/commands/init.ts`:
- Around line 8-10: The CLI input schema InitOptionsSchema is defined inside the
command module; extract it into a shared contracts module and import it instead:
create a new contracts file that exports InitOptionsSchema (a z.object with
token: z.string().optional()), remove the local InitOptionsSchema declaration in
the init command, and update the init command to import and use the exported
InitOptionsSchema for validation so external CLI input follows the contracts/
validation architecture.

---

Outside diff comments:
In @.mcpb:
- Line 4: The package description in the .mcpb file claims "39 rules in 6
categories" but SKILL.md and README state "29 rules across 5 categories"; update
the "description" value in the .mcpb diff to match the canonical text used in
.claude/skills/canicode/SKILL.md and README (e.g., change to "Analyze Figma
design structures for development-friendliness and AI-friendliness. Scores
designs across 29 rules in 5 categories (Structure, Token, Component, Naming,
Behavior) and generates detailed HTML reports with actionable issues.") so all
three places are consistent.
- Line 99: Update the "description" string in the .mcpb file so the hard-coded
"39 rule IDs" matches the actual rule count; locate the JSON property named
"description" (the line containing "Get documentation on config overrides,
custom rules, all 39 rule IDs with default scores, and example configurations.")
and change the numeric value to the correct count or make it dynamic/omit the
number so docs stay accurate.

In `@src/mcp/server.ts`:
- Around line 98-104: The telemetry event currently hardcodes source:"url" in
the trackEvent call (EVENTS.ANALYSIS_COMPLETED); change it to compute the source
from the original input used to load the file by reusing the same detection
logic as loadFile (i.e., use isJsonFile(input) || isFixtureDir(input) to set
source to "fixture" when true, otherwise "url"), keeping the trackEvent call and
event payload keys the same and referencing the existing input parameter and the
helper functions isJsonFile/isFixtureDir to locate where to change it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 085aace7-19b4-448d-a72d-68a84d0d80d3

📥 Commits

Reviewing files that changed from the base of the PR and between 147cf3f and a1a51b7.

📒 Files selected for processing (20)
  • .claude/agents/calibration/converter.md
  • .claude/commands/calibrate-loop-deep.md
  • .claude/commands/calibrate-loop.md
  • .claude/commands/mcp-vs-cli.md
  • .claude/skills/canicode/SKILL.md
  • .mcpb
  • CLAUDE.md
  • README.md
  • docs/CALIBRATION.md
  • docs/MCP-VS-CLI.md
  • src/cli/commands/init.ts
  • src/cli/docs.ts
  • src/cli/index.ts
  • src/core/adapters/figma-mcp-adapter.ts
  • src/core/adapters/index.ts
  • src/core/adapters/tailwind-parser.test.ts
  • src/core/adapters/tailwind-parser.ts
  • src/core/engine/design-data-parser.test.ts
  • src/core/engine/design-data-parser.ts
  • src/mcp/server.ts
💤 Files with no reviewable changes (10)
  • docs/CALIBRATION.md
  • src/core/adapters/index.ts
  • docs/MCP-VS-CLI.md
  • src/core/engine/design-data-parser.test.ts
  • src/core/engine/design-data-parser.ts
  • src/core/adapters/tailwind-parser.test.ts
  • .claude/commands/mcp-vs-cli.md
  • src/core/adapters/figma-mcp-adapter.ts
  • src/core/adapters/tailwind-parser.ts
  • .claude/commands/calibrate-loop-deep.md

Comment on lines 8 to +10
const InitOptionsSchema = z.object({
token: z.string().optional(),
mcp: z.boolean().optional(),
}).refine(
(opts) => !(opts.token && opts.mcp),
{ message: "--token and --mcp are mutually exclusive. Choose one." }
);
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Move CLI input schema to contracts/ to satisfy validation architecture rules.

InitOptionsSchema validates external CLI input, but it is defined locally in the command module. Please define/import it from contracts/ instead of declaring it here.

♻️ Proposed refactor
 import type { CAC } from "cac";
-import { z } from "zod";
+import { InitOptionsSchema } from "../../core/contracts/init-options.js";

 import {
   initAiready, getConfigPath, getReportsDir,
 } from "../../core/engine/config-store.js";
-
-const InitOptionsSchema = z.object({
-  token: z.string().optional(),
-});
// src/core/contracts/init-options.ts
import { z } from "zod";

export const InitOptionsSchema = z.object({
  token: z.string().optional(),
});

As per coding guidelines: "Validate all external inputs with Zod schemas defined in contracts/ directory".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cli/commands/init.ts` around lines 8 - 10, The CLI input schema
InitOptionsSchema is defined inside the command module; extract it into a shared
contracts module and import it instead: create a new contracts file that exports
InitOptionsSchema (a z.object with token: z.string().optional()), remove the
local InitOptionsSchema declaration in the init command, and update the init
command to import and use the exported InitOptionsSchema for validation so
external CLI input follows the contracts/ validation architecture.

- .mcpb: "39 rules in 6 categories" → "29 rules in 5 categories"
- .mcpb: "39 rule IDs" → "29 rule IDs"
- server.ts: telemetry source distinguishes fixture vs figma URL

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@let-sunny let-sunny merged commit f84d521 into main Mar 27, 2026
3 checks passed
@let-sunny let-sunny deleted the refactor/remove-figma-mcp-analysis branch March 27, 2026 05:41
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.

refactor: remove Figma MCP analysis path — keep canicode MCP server

1 participant