solidworks_mcp.ui.services.parameter_repair_service¶
solidworks_mcp.ui.services.parameter_repair_service ¶
Parameter validation and repair service for checkpoint tool parameters.
Validates checkpoint planned actions against known tool signatures and provides repair suggestions or auto-completion strategies for missing parameters.
Attributes¶
TOOL_PARAM_SCHEMAS
module-attribute
¶
TOOL_PARAM_SCHEMAS: dict[str, dict[str, Any]] = {'create_part': {'required': ['part_name'], 'optional': [], 'description': 'Create a new part document.'}, 'create_assembly': {'required': ['assembly_name'], 'optional': [], 'description': 'Create a new assembly document.'}, 'open_model': {'required': ['model_path'], 'optional': [], 'description': 'Open an existing SolidWorks model.'}, 'create_sketch': {'required': ['sketch_plane'], 'optional': ['sketch_name'], 'description': 'Create a sketch on the specified plane.'}, 'exit_sketch': {'required': [], 'optional': [], 'description': 'Exit the current sketch.'}, 'save_file': {'required': ['file_path'], 'optional': [], 'description': 'Save the active document.'}, 'add_line': {'required': ['line_mm'], 'optional': [], 'description': 'Add a line to the current sketch.', 'aliases': [['line_start_mm', 'line_end_mm']]}, 'add_rectangle': {'required': ['rectangle_mm'], 'optional': [], 'description': 'Add a rectangle to the current sketch.'}, 'add_circle': {'required': ['circle_center_mm', 'circle_radius_mm'], 'optional': [], 'description': 'Add a circle to the current sketch.'}, 'add_arc': {'required': ['arc_center_mm', 'arc_start_mm', 'arc_end_mm'], 'optional': [], 'description': 'Add an arc to the current sketch.'}, 'add_centerline': {'required': ['centerline_mm'], 'optional': [], 'description': 'Add a centerline to the current sketch.'}, 'create_extrusion': {'required': ['depth'], 'optional': ['sketch_name', 'thin_feature', 'thin_thickness', 'thin_thickness_mm', 'both_directions', 'auto_fillet_corners', 'fillet_corners_radius'], 'description': 'Create an extrusion from the current sketch.', 'aliases': [['depth_mm']]}, 'create_cut': {'required': ['depth'], 'optional': ['sketch_name', 'blind_or_through'], 'description': 'Create a cut (subtractive feature) from the current sketch.', 'aliases': [['depth_mm']]}, 'create_cut_extrude': {'required': ['depth'], 'optional': [], 'description': 'Create a cut extrusion from the current sketch.', 'aliases': [['depth_mm']]}, 'export_image': {'required': ['file_path', 'format_type'], 'optional': ['width', 'height', 'view_orientation'], 'description': 'Export the current model as an image.', 'aliases': [['export_image']]}, 'check_sketch_fully_defined': {'required': [], 'optional': ['sketch_name'], 'description': 'Check if the current or named sketch is fully defined.'}}
Classes¶
ParameterRepairResult ¶
ParameterRepairResult(is_valid: bool, missing_keys: list[str] | None = None, suggestions: dict[str, Any] | None = None, repaired_plan: dict[str, Any] | None = None, message: str = '')
Result of parameter validation and repair.
Source code in src/solidworks_mcp/ui/services/parameter_repair_service.py
Functions:¶
_generate_repair_suggestions ¶
Generate repair suggestions for incomplete planned actions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_name
|
str
|
Name of the tool. |
required |
planned
|
dict[str, Any]
|
Current planned-action dict. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with suggested parameter values or instructions. |
Source code in src/solidworks_mcp/ui/services/parameter_repair_service.py
attempt_auto_repair ¶
attempt_auto_repair(planned: dict[str, Any], tool_name: str, context: dict[str, Any] | None = None) -> ParameterRepairResult
Attempt automatic repair of incomplete parameters based on context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
planned
|
dict[str, Any]
|
Checkpoint planned-action dict. |
required |
tool_name
|
str
|
Name of the tool. |
required |
context
|
dict[str, Any] | None
|
Optional context dict with hints (e.g., previous sketch plane). |
None
|
Returns:
| Type | Description |
|---|---|
ParameterRepairResult
|
ParameterRepairResult with repaired plan or failure details. |
Source code in src/solidworks_mcp/ui/services/parameter_repair_service.py
build_repair_instruction_text ¶
Build human-readable repair instruction text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
validation
|
ParameterRepairResult
|
ParameterRepairResult with missing keys and suggestions. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted instruction text for user display. |
Source code in src/solidworks_mcp/ui/services/parameter_repair_service.py
validate_checkpoint_parameters ¶
Validate that a planned action has all required parameters for a tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
planned
|
dict[str, Any]
|
Checkpoint planned-action dict. |
required |
tool_name
|
str
|
Name of the tool being validated. |
required |
Returns:
| Type | Description |
|---|---|
ParameterRepairResult
|
ParameterRepairResult with validation status and repair suggestions. |