Skip to main content

apply_fix

Applies an AST codemod for design-system violations: the applied-fix counterpart to suggest_fixes.

Reference

Parameters

  • Name
    code
    Type
    string · required
    Description

    The source to repair (TSX/JSX)

  • Name
    rules
    Type
    array · optional
    Description

    Restrict to specific rule ids (default: all)

  • Name
    applyBreaking
    Type
    boolean · optional
    Description

    Also write breaking transforms (default false)

  • Name
    injectImports
    Type
    boolean · optional
    Description

    Inject component imports for rewritten elements (default true)

Returns

{
  changed
  fixed
  diff
  applied[]
  skipped[]
  importsAdded[]
  warnings[]
}

Description

Applies an AST codemod for design-system violations: the applied-fix counterpart to suggest_fixes.

Where suggest_fixes proposes fixes for an agent to apply by hand, apply_fix performs the transform (recast-based, not regex) and returns the rewritten code plus a unified diff. Scope v1: the forbidden-primitive element class. Text-like native input becomes Input (non-breaking). Native checkbox/select/button are breaking (button's intent-correct preset is a judgment call), returned as opt-in proposals. Non-breaking high-confidence transforms apply by default; breaking ones apply only when applyBreaking:true.

Parameters:

  • code (required): the source to repair (TSX/JSX)
  • rules (optional): restrict to specific rule ids (default: all)
  • applyBreaking (optional): also write breaking transforms (default false)
  • injectImports (optional): add component imports for rewritten elements (default true)

Re-run validate_code on the result.

Source

Defined in packages/mcp/src/tools.ts. The request handler lives alongside its registration in packages/mcp/src/tools/.

Was this page helpful?

Last reviewed by @jschuyler