Skip to content

Synfig MCP Repository Audit & Cleanup Plan

Phase A0 Baseline Audit (Target: v0.8.0-rc1) Systematically analyzes code bloat, files over 400 lines, stale documentation, naming inconsistencies, git topology, and dead code. Establishes the actionable refactoring roadmap for Phase A7 (Repo & UX Polish).


1. Files Over 400 Lines (Refactoring Targets)

Analysis performed across source, bridge, documentation, and test suites:

File Path Line Count Current Responsibility Proposed Phase A7 Split / Action
bridge/src/mcp_bridge/handlers.cpp 2,429 Monolithic JSON-RPC dispatcher for doc, layer, param, anim, history, render, and selection Split by domain into handlers_doc.cpp, handlers_layer.cpp, handlers_param.cpp, handlers_anim.cpp, handlers_render.cpp with a central router
server/tests/e2e/test_live_mutate.py 1,808 All live E2E mutation tests against real Synfig Studio Split into focused suites: test_live_layers.py, test_live_params.py, test_live_anim.py, test_live_security.py
server/src/synfig_mcp/tools/register.py 1,447 Monolithic MCP tool registration functions (all 52 tools in one file) Split into domain modules under synfig_mcp/tools/: doc.py, layer.py, param.py, anim.py, render.py, scene.py
docs/tools.md 1,439 Auto-generated Markdown tool reference Keep generated, but update scripts/generate_tool_docs.py to group by profile and link to topic guides
server/src/synfig_mcp/sif/parser.py 1,193 XML DOM parser, SIF document abstraction, layer models, waypoints Separate into ast.py, layers.py, values.py, and serializer.py
server/src/synfig_mcp/backend/headless.py 875 Complete headless SIF engine + CLI fallback Modularize backend delegate classes for canvas manipulation, parameters, and render jobs
server/tests/contract/test_mcp_tools.py 721 Parametrized contract tests for all tools Split into per-domain contract test modules
server/src/synfig_mcp/protocol/fake_bridge.py 655 In-memory mock TCP bridge server Split mock document storage from protocol handshake logic
server/src/synfig_mcp/backend/live.py 651 Live bridge backend adapter Keep coherent, delegate complex render polling to render pipeline
server/src/synfig_mcp/backend/base.py 409 BaseBackend abstract class Clean abstract interface; acceptable size

2. Duplicate and Stale Documentation Audit

  1. server/README.md vs Root README.md:
  2. server/README.md is an exact duplicate of the root README.md.
  3. Resolution: Replace server/README.md with a clean symlink or a minimal pointer referencing root README.md.
  4. docs/ROADMAP.md:
  5. Stale milestones referencing completed alpha targets (v0.6.0, v0.7.0) and Phase P0–P7.
  6. Resolution: Reconcile ROADMAP.md to reflect the v0.8.0-rc1 Studio-grade upgrade phases (A0 through A8).
  7. scripts/generate_tool_docs.py:
  8. Docstring states: "Generate comprehensive Markdown documentation for all 47 Synfig MCP tools", whereas 52 tools currently exist.
  9. Resolution: Update generator to introspect dynamically and group tools according to Phase A1 profiles.

3. Naming and API Inconsistencies

  1. Tool Naming (verb_noun consistency):
  2. Current names: layer_remove vs layer_delete, layer_reorder vs layer_move, scene_tree (noun phrase) vs canvas_list, import_asset vs asset_import. (Resolved in v1.0.6: the duplicate asset actions were consolidated into a single asset_import tool.)
  3. C++ Bridge methods: Accepts both layer.remove and layer.delete, layer.move and layer.reorder.
  4. Resolution: Standardize Python MCP tool names strictly on noun_verb or verb_noun convention in Phase A1 / A7.
  5. Parameter Conventions:
  6. Some layer tools accept canvas_path: str = "" while others require explicit canvas resolution.
  7. Resolution: Unify canvas targeting across all tools.
  8. Version Number Single Source of Truth:
  9. server/pyproject.toml defines 0.7.0rc3.
  10. bridge/src/mcp_bridge/handlers.cpp hardcodes 0.7.0-rc3.
  11. Resolution: Centralize version in a single file (e.g. VERSION or root metadata) injected into C++ build via CMake and read dynamically by Python packaging.

4. Git References and Branch Topology Audit

  1. Branch v1.0.0:
  2. Currently checked out branch is named v1.0.0, while origin/HEAD points to origin/main.
  3. A branch named after a future major version creates confusion with release tags.
  4. Resolution: Never delete tags. Align work on main or a dedicated release branch release/v0.8.0-rc1.
  5. Preservation of Existing Tags:
  6. Verified existing tags: v0.6.0, v0.7.0-rc1, v0.7.0-rc2, v0.7.0-rc3.
  7. Hard Rule: No existing tags will be deleted or moved. Code changes will ship strictly under the new tag v0.8.0-rc1.

5. Dead Code and Workspace Cleanup

  1. scratch/ Directory:
  2. Contains 15 ad-hoc debugging scripts from previous CI troubleshooting (check_all_jobs.py, check_ci.py, fetch_pkg_info.py, pkgs_info.json, test_win32_fs.cpp).
  3. Resolution: Move or archive these ad-hoc scripts to keep the root repository clean.
  4. dist/ Directory:
  5. Contains historical release archives from previous builds.
  6. Resolution: Retain .gitignore tracking so build artifacts are excluded from git.