AI-assisted embroidery digitizing with Inkscape, Ink/Stitch, and MCP.
Build an MCP server that helps Codex or Claude inspect and prepare artwork for embroidery workflows. The long-term workflow is:
- Image cleanup
- Background removal
- Color reduction
- Vectorization
- SVG cleanup
- Embroidery analysis
- Stitch assignment
- Preview generation
- Embroidery file export
V1 supports two workflows:
- SVG workflow: provide an SVG and the MCP cleans it, analyzes it, generates Ink/Stitch previews, exports DST/PES files, and writes operator reports.
- Image workflow: provide a PNG/JPG and the MCP reduces colors, removes a simple corner-sampled background, creates a layered SVG by color, then runs the SVG operator workflow.
Implemented:
- Python project scaffold
- MCP stdio server
validate_svgtoolcleanup_svgtoolsimulate_designtoolanalyze_designtoolcheck_environmenttoolgenerate_previewtoolgenerate_stitch_plantoolexport_embroiderytoolcreate_operator_packagetoolvectorize_imagetoolcreate_image_operator_packagetool- SVG validation tests
- Example SVG and PNG files
Deferred:
- automatic stitch assignment
- advanced photo cleanup and tracing
- thread palette matching
- Python 3.12+
- uv
- Git
- Inkscape
- Ink/Stitch
- Claude Desktop or Codex MCP configuration for MCP use
Verify local tools:
python --version
uv --version
git --version
/Applications/Inkscape.app/Contents/MacOS/inkscape --versionuv syncRun tests:
uv run pytestRun the MCP smoke test:
/Users/chrisgutierrez/.local/bin/uv run embroidery-mcp-smokeRun the MCP server:
/Users/chrisgutierrez/.local/bin/uv run embroidery-mcpThe server uses stdio transport and is intended to be launched by an MCP client.
Register with Codex:
./scripts/install-codex-mcp.shList configured Codex MCP servers:
codex mcp listInput:
{
"path": "examples/simple-text.svg"
}Output:
{
"valid": true,
"errors": [],
"warnings": [],
"stats": {
"elements": 3,
"paths": 1,
"shapes": 2,
"colors": 3
}
}The tool checks:
- file existence
- XML parseability
- SVG root element
- element, path, shape, and color counts
- obvious open path warnings
- tiny object warnings
- unsupported SVG feature warnings
Input:
{
"path": "examples/cleanup-source.svg",
"output_path": "examples/cleanup-source-cleaned.svg"
}Output:
{
"cleaned": true,
"input_path": "examples/cleanup-source.svg",
"output_path": "examples/cleanup-source-cleaned.svg",
"removed_elements": ["metadata", "title", "desc", "script", "foreignObject", "g"],
"warnings": [],
"errors": []
}The tool removes:
scriptforeignObjectmetadatatitledesc- empty groups with no attributes
Input:
{
"path": "examples/simple-text.svg"
}Output:
{
"ready": false,
"estimated_stitches": 2050,
"color_sequence": ["#1f77b4", "#111111", "#d62728"],
"warnings": ["Path appears open; open paths may create running stitches or jump risks."],
"recommendations": ["Review open paths; close filled regions or mark intentional running stitches."]
}This is a pure-Python readiness simulation. It does not run Ink/Stitch yet.
Input:
{
"path": "examples/simple-text.svg"
}Output includes object classification, color sequence, candidate counts, warnings, and operator recommendations. Stitch candidates are recommendations only; v1 does not write Ink/Stitch stitch parameters automatically.
Input:
{}Output:
{
"ready_for_inkstitch": true,
"inkscape": {
"available": true,
"path": "/Applications/Inkscape.app/Contents/MacOS/inkscape",
"version": "Inkscape 1.4.4 (dcaf3e7, 2026-05-05)"
},
"inkstitch": {
"available": true,
"app_path": "/Users/chrisgutierrez/Library/Application Support/org.inkscape.Inkscape/config/inkscape/extensions/inkstitch/inkstitch.app",
"binary_path": "/Users/chrisgutierrez/Library/Application Support/org.inkscape.Inkscape/config/inkscape/extensions/inkstitch/inkstitch.app/Contents/MacOS/inkstitch",
"match_count": 289
},
"recommendations": ["Environment is ready for Ink/Stitch-backed tools."]
}This tool checks the local Mac app path for Inkscape and common user/app extension paths for Ink/Stitch.
Input:
{
"path": "examples/simple-text.svg",
"output_path": "examples/simple-text.png"
}Output:
{
"generated": true,
"output_path": "examples/simple-text.png",
"format": "png",
"bytes": 1252,
"errors": []
}Input:
{
"path": "examples/simple-text.svg",
"output_path": "examples/simple-text.stitch-plan.svg"
}Output:
{
"generated": true,
"output_path": "examples/simple-text.stitch-plan.svg",
"format": "svg",
"errors": []
}Input:
{
"path": "examples/simple-text.svg",
"output_path": "examples/simple-text.dst",
"file_format": "dst"
}Output:
{
"exported": true,
"output_path": "examples/simple-text.dst",
"format": "dst",
"bytes": 1914,
"errors": []
}V1 verifies dst and pes.
Input:
{
"path": "examples/simple-text.svg",
"output_dir": "examples/simple-text-embroidery",
"formats": ["dst", "pes"]
}Output artifacts:
- cleaned SVG
- PNG preview
- SVG stitch plan
- DST file
- PES file
report.jsonreport.md
This is the main v1 workflow for operators.
Input:
{
"path": "examples/simple-logo.png",
"output_path": "examples/simple-logo.vectorized.svg",
"max_colors": 6,
"max_dimension": 160,
"remove_background": true
}Output:
{
"vectorized": true,
"output_path": "examples/simple-logo.vectorized.svg",
"colors": ["#1f77b4", "#d62728"],
"rectangles": 42,
"errors": []
}This creates a layered SVG with one Inkscape layer per reduced color. It is intended for logos and flat artwork first; complex photos may need manual cleanup.
Input:
{
"path": "examples/simple-logo.png",
"output_dir": "examples/simple-logo-embroidery",
"formats": ["dst", "pes"],
"max_colors": 6,
"max_dimension": 160
}This is the image-entry workflow. It writes a vectorized SVG, then produces the same cleaned SVG, previews, DST/PES files, and operator reports as create_operator_package.
Use the absolute repo path for reliability:
{
"mcpServers": {
"embroidery-mcp": {
"command": "/Users/chrisgutierrez/.local/bin/uv",
"args": [
"--directory",
"/Users/chrisgutierrez/Projects/InkStitchMCP",
"run",
"embroidery-mcp"
]
}
}
}Phase 1:
validate_svgcleanup_svgsimulate_designanalyze_designcheck_environmentgenerate_previewgenerate_stitch_planexport_embroiderycreate_operator_package
Future improvements:
- better bitmap tracing for photos
- smarter object merging and simplification
- automatic stitch parameter assignment
- thread palette matching
Phase 2:
analyze_design(svg)- warnings for tiny objects, excessive density, open paths, overlaps, and jump stitch risks
Phase 3:
assign_stitches(svg)- fill, satin, and running stitch recommendations
Phase 4:
generate_preview(svg)- PNG preview, stitch simulation, and color sequence
Phase 5:
export_embroidery(svg)- PES, DST, EXP, JEF, and VP3 export
Embroidery digitizing is both technical and artistic. AI-generated designs should be reviewed and test-stitched before production use.