solidworks_mcp.tools.tool_boundary¶
solidworks_mcp.tools.tool_boundary ¶
The single error boundary every MCP tool runs inside (spec: tools/error-boundary).
Tools contain business logic only. They:
- parse input with :func:
normalize_input(raises :class:InvalidInputError), - check adapter results with :func:
require_success(raises :class:ToolOperationError), and - return their success payload.
:func:tool_boundary turns anything raised into the uniform error payload -
status, message, error_type, hint and execution_time (the
adapter's timing, else the tool's own wall time) - using :class:ErrorClassifier to name the failure.
:class:ToolRegistrar applies the boundary to every tool at registration, so no
tool can forget it. It also adds each tool's support level (from
support_levels.py) to its tags and, for a beta, experimental or deprecated
tool, a warning to its successful results.
Attributes¶
NOT_SUPPORTED_HINT
module-attribute
¶
NOT_SUPPORTED_HINT = 'The active adapter cannot perform this operation. Use the real SolidWorks adapter, another tool, or do this step in SolidWorks directly.'
REQUIREMENTS
module-attribute
¶
REQUIREMENTS: Mapping[str, Requirement] = {**dict.fromkeys(_VBA_WRITERS, Requirement.NOTHING), 'compare_templates': Requirement.NOTHING, 'compare_drawing_versions': Requirement.NOTHING, 'reset_circuit_breaker': Requirement.NOTHING, 'discover_solidworks_docs': Requirement.INSTALLED, 'search_solidworks_api_help': Requirement.INSTALLED, 'lookup_api_method': Requirement.INSTALLED, 'lookup_api_interface': Requirement.INSTALLED, 'get_api_enum': Requirement.INSTALLED, 'find_related_api_members': Requirement.INSTALLED, 'list_hole_sizes': Requirement.INSTALLED}
SUPPORT_LEVELS
module-attribute
¶
SUPPORT_LEVELS: dict[str, Support] = {'calculate_mass_properties': _deprecated('get_mass_properties'), 'check_interference': _STABLE, 'get_mass_properties': _STABLE, 'verify_model': _STABLE, 'generate_vba_code': _STABLE, 'discover_solidworks_docs': _STABLE, 'find_related_api_members': _STABLE, 'lookup_api_interface': _STABLE, 'get_api_enum': _STABLE, 'lookup_api_method': _STABLE, 'search_solidworks_api_help': _STABLE, 'add_dimension': _STABLE, 'add_drawing_view': _deprecated('create_drawing_view'), 'add_note': _STABLE, 'auto_center_marks': _STABLE, 'auto_dimension_view': _STABLE, 'check_drawing': _STABLE, 'create_detail_view': _STABLE, 'create_drawing_view': _STABLE, 'create_section_view': _STABLE, 'create_technical_drawing': _STABLE, 'list_drawing_views': _STABLE, 'update_sheet_format': _STABLE, 'update_title_block': _STABLE, 'compare_drawing_versions': _STABLE, 'add_datum_tag': _STABLE, 'add_gtol': _STABLE, 'arrange_dimensions': _STABLE, 'generate_drawing_package': _STABLE, 'insert_bom_table': _STABLE, 'insert_model_dimensions': _STABLE, 'set_sheet_scale': _STABLE, 'export_flat_pattern': _STABLE, 'get_custom_properties': _STABLE, 'get_material': _STABLE, 'list_available_materials': _STABLE, 'list_model_dimensions': _STABLE, 'measure_entities': _STABLE, 'set_custom_property': _STABLE, 'set_material': _STABLE, 'export_dwg': _STABLE, 'export_iges': _STABLE, 'export_image': _STABLE, 'export_pdf': _STABLE, 'export_step': _STABLE, 'export_stl': _STABLE, 'activate_document': _STABLE, 'classify_feature_tree': _STABLE, 'get_file_properties': _deprecated('get_model_info'), 'get_model_info': _STABLE, 'get_selected_entities': _STABLE, 'list_configurations': _STABLE, 'create_configuration': _STABLE, 'activate_configuration': _STABLE, 'delete_configuration': _STABLE, 'create_exploded_view': _STABLE, 'set_exploded_view': _STABLE, 'pattern_components': _STABLE, 'mirror_components': _STABLE, 'replace_component': _STABLE, 'add_balloons': _STABLE, 'list_equations': _STABLE, 'set_equation': _STABLE, 'delete_equation': _STABLE, 'list_features': _STABLE, 'list_open_documents': _STABLE, 'load_assembly': _deprecated('open_model'), 'load_part': _deprecated('open_model'), 'pack_and_go_assembly': _STABLE, 'save_as': _STABLE, 'save_assembly': _deprecated('save_file'), 'save_body_as_part': _STABLE, 'save_file': _STABLE, 'save_as_template': _STABLE, 'save_part': _deprecated('save_file'), 'execute_macro': _STABLE, 'add_chamfer': _STABLE, 'add_fillet': _STABLE, 'add_mate': _STABLE, 'close_model': _STABLE, 'create_assembly': _STABLE, 'create_axis': _STABLE, 'create_cut_extrude': _STABLE, 'create_drawing': _STABLE, 'create_extrusion': _STABLE, 'create_loft': _STABLE, 'create_part': _STABLE, 'create_reference_plane': _STABLE, 'create_reference_point': _STABLE, 'create_revolve': _STABLE, 'create_sweep': _STABLE, 'delete_feature': _STABLE, 'get_dimension': _STABLE, 'insert_component': _STABLE, 'list_components': _STABLE, 'mirror_feature': _STABLE, 'open_model': _STABLE, 'pattern_circular': _STABLE, 'pattern_linear': _STABLE, 'create_shell': _STABLE, 'add_draft': _STABLE, 'create_rib': _STABLE, 'create_base_flange': _STABLE, 'add_edge_flange': _STABLE, 'create_sketched_bend': _STABLE, 'set_flat_pattern': _STABLE, 'create_hole': _STABLE, 'list_hole_sizes': _STABLE, 'add_cosmetic_thread': _STABLE, 'rebuild_model': _STABLE, 'rename_feature': _STABLE, 'select_face_edges': _STABLE, 'select_feature': _STABLE, 'set_component_state': _STABLE, 'set_dimension': _STABLE, 'set_units': _STABLE, 'suppress_feature': _STABLE, 'undo': _STABLE, 'reset_circuit_breaker': _STABLE, 'add_arc': _STABLE, 'add_centerline': _STABLE, 'add_circle': _STABLE, 'add_ellipse': _STABLE, 'add_sketch_text': _STABLE, 'set_sketch_text': _STABLE, 'add_sketch_fillet': _STABLE, 'add_sketch_chamfer': _STABLE, 'add_slot': _STABLE, 'sketch_trim': _STABLE, 'sketch_extend': _STABLE, 'set_construction_geometry': _STABLE, 'add_line': _STABLE, 'add_polygon': _STABLE, 'add_rectangle': _STABLE, 'add_sketch_constraint': _STABLE, 'add_sketch_dimension': _STABLE, 'add_spline': _STABLE, 'check_sketch_fully_defined': _STABLE, 'create_sketch': _STABLE, 'exit_sketch': _STABLE, 'sketch_circular_pattern': _STABLE, 'sketch_linear_pattern': _STABLE, 'sketch_mirror': _STABLE, 'sketch_offset': _STABLE, 'sketch_convert_entities': _STABLE, 'sketch_tutorial_simple_hole': _deprecated(None), 'compare_templates': _STABLE, 'generate_vba_assembly_insert': _STABLE, 'generate_vba_assembly_mates': _STABLE, 'generate_vba_batch_export': _STABLE, 'generate_vba_drawing_dimensions': _STABLE, 'generate_vba_drawing_views': _STABLE, 'generate_vba_extrusion': _STABLE, 'generate_vba_file_operations': _STABLE, 'generate_vba_macro_recorder': _STABLE, 'generate_vba_part_modeling': _STABLE, 'generate_vba_revolve': _STABLE}
TOOL_HINTS
module-attribute
¶
TOOL_HINTS: dict[str, ToolHints] = {'calculate_mass_properties': _reads('Calculate Mass Properties'), 'get_mass_properties': _reads('Get Mass Properties'), 'check_interference': _reads('Check Assembly Interference'), 'verify_model': _reads('Verify Model Against Expectations'), 'generate_vba_code': _reads('Generate VBA Code'), 'discover_solidworks_docs': _sets('Rebuild SolidWorks API Index'), 'search_solidworks_api_help': _reads('Search SolidWorks API'), 'reset_circuit_breaker': _sets('Reset Circuit Breaker'), 'lookup_api_method': _reads('Look Up API Method'), 'lookup_api_interface': _reads('Look Up API Interface'), 'get_api_enum': _reads('Get API Enum'), 'find_related_api_members': _reads('Find Related API Members'), 'create_drawing_view': _adds('Create Drawing View'), 'add_dimension': _adds('Add Drawing Dimension'), 'add_note': _adds('Add Drawing Note'), 'create_section_view': _adds('Create Section View'), 'create_detail_view': _adds('Create Detail View'), 'update_sheet_format': _sets('Update Sheet Format'), 'auto_dimension_view': _adds('Auto-Dimension Drawing View'), 'check_drawing': _reads('Check Drawing Completeness'), 'create_technical_drawing': _adds('Create Technical Drawing'), 'add_drawing_view': _adds('Add Drawing View'), 'update_title_block': _sets('Update Title Block'), 'list_drawing_views': _reads('List Drawing Views'), 'auto_center_marks': _adds('Add Centre Marks'), 'compare_drawing_versions': _reads('Compare Drawing Files'), 'insert_model_dimensions': _adds('Insert Model Dimensions'), 'arrange_dimensions': _sets('Arrange Drawing Dimensions'), 'insert_bom_table': _adds('Insert BOM Table'), 'add_gtol': _adds('Add GD&T Frame'), 'add_datum_tag': _adds('Add Datum Tag'), 'set_sheet_scale': _sets('Set Sheet Scale'), 'generate_drawing_package': _overwrites('Generate Drawing Package'), 'list_model_dimensions': _reads('List Model Dimensions'), 'measure_entities': _reads('Measure Entities'), 'get_material': _reads('Get Material'), 'set_material': _sets('Set Material'), 'list_available_materials': _reads('List Available Materials'), 'get_custom_properties': _reads('Get Custom Properties'), 'set_custom_property': _overwrites('Set Custom Property'), 'export_flat_pattern': _overwrites('Export Flat Pattern'), 'export_step': _overwrites('Export STEP'), 'export_iges': _overwrites('Export IGES'), 'export_stl': _overwrites('Export STL'), 'export_pdf': _overwrites('Export PDF'), 'export_dwg': _overwrites('Export DWG'), 'export_image': _overwrites('Export Image'), 'save_file': _overwrites('Save File'), 'save_as_template': _overwrites('Save As Template'), 'save_as': _overwrites('Save As'), 'get_file_properties': _reads('Get File Properties'), 'get_model_info': _reads('Get Model Info'), 'list_features': _reads('List Features'), 'get_selected_entities': _reads('Get Selected Entities'), 'classify_feature_tree': _reads('Classify Feature Tree'), 'list_configurations': _reads('List Configurations'), 'create_configuration': _adds('Add Configuration'), 'activate_configuration': _sets('Activate Configuration'), 'delete_configuration': _discards('Delete Configuration'), 'create_exploded_view': _adds('Create Exploded View'), 'set_exploded_view': _sets('Set Exploded View'), 'pattern_components': _adds('Pattern Components'), 'mirror_components': _adds('Mirror Components'), 'replace_component': _overwrites('Replace Component'), 'add_balloons': _adds('Add Balloons'), 'list_equations': _reads('List Equations'), 'set_equation': _sets('Set Equation'), 'delete_equation': _discards('Delete Equation'), 'load_part': _sets('Load Part'), 'load_assembly': _sets('Load Assembly'), 'save_part': _overwrites('Save Part'), 'save_assembly': _overwrites('Save Assembly'), 'pack_and_go_assembly': _overwrites('Pack and Go Assembly'), 'list_open_documents': _reads('List Open Documents'), 'activate_document': _sets('Activate Document'), 'save_body_as_part': _overwrites('Save Body as Part'), 'execute_macro': _discards('Run Macro'), 'open_model': _sets('Open Model'), 'create_part': _adds('Create Part'), 'create_assembly': _adds('Create Assembly'), 'create_drawing': _adds('Create Drawing'), 'close_model': _discards('Close Model'), 'create_extrusion': _adds('Create Extrusion'), 'create_revolve': _adds('Create Revolve'), 'get_dimension': _reads('Get Dimension'), 'set_dimension': _sets('Set Dimension'), 'set_units': _sets('Set Units'), 'create_cut_extrude': _adds('Create Extruded Cut'), 'add_fillet': _adds('Add Fillet'), 'add_chamfer': _adds('Add Chamfer'), 'create_sweep': _adds('Create Sweep'), 'create_loft': _adds('Create Loft'), 'insert_component': _adds('Insert Component'), 'add_mate': _adds('Add Mate'), 'set_component_state': _sets('Set Component State'), 'list_components': _reads('List Components'), 'delete_feature': _discards('Delete Feature'), 'suppress_feature': _sets('Suppress or Unsuppress Feature'), 'rename_feature': _sets('Rename Feature'), 'select_feature': _sets('Select Feature'), 'select_face_edges': _sets('Select Face Edges'), 'rebuild_model': _sets('Rebuild Model'), 'undo': _discards('Undo'), 'create_reference_plane': _adds('Create Reference Plane'), 'create_axis': _adds('Create Reference Axis'), 'create_reference_point': _adds('Create Reference Point'), 'mirror_feature': _adds('Mirror Feature'), 'pattern_circular': _adds('Circular Pattern'), 'pattern_linear': _adds('Linear Pattern'), 'create_shell': _adds('Shell'), 'add_draft': _adds('Draft Faces'), 'create_rib': _adds('Rib'), 'create_base_flange': _adds('Base Flange'), 'add_edge_flange': _adds('Edge Flange'), 'create_sketched_bend': _adds('Sketched Bend'), 'set_flat_pattern': _sets('Flat Pattern'), 'create_hole': _adds('Hole Wizard Hole'), 'list_hole_sizes': _reads('List Hole Wizard Sizes'), 'add_cosmetic_thread': _adds('Cosmetic Thread'), 'create_sketch': _adds('Create Sketch'), 'add_line': _adds('Add Sketch Line'), 'add_circle': _adds('Add Sketch Circle'), 'add_rectangle': _adds('Add Sketch Rectangle'), 'exit_sketch': _sets('Exit Sketch'), 'check_sketch_fully_defined': _reads('Check Sketch Fully Defined'), 'add_arc': _adds('Add Sketch Arc'), 'add_spline': _adds('Add Sketch Spline'), 'add_centerline': _adds('Add Sketch Centerline'), 'add_polygon': _adds('Add Sketch Polygon'), 'add_ellipse': _adds('Add Sketch Ellipse'), 'add_sketch_text': _adds('Add Sketch Text'), 'set_sketch_text': _sets('Set Sketch Text'), 'add_sketch_fillet': _adds('Add Sketch Fillet'), 'add_sketch_chamfer': _adds('Add Sketch Chamfer'), 'add_slot': _adds('Add Slot'), 'sketch_trim': _discards('Trim Sketch Entity'), 'sketch_extend': _adds('Extend Sketch Entity'), 'set_construction_geometry': _sets('Set Construction Geometry'), 'add_sketch_constraint': _adds('Add Sketch Relation'), 'add_sketch_dimension': _adds('Add Sketch Dimension'), 'sketch_linear_pattern': _adds('Sketch Linear Pattern'), 'sketch_circular_pattern': _adds('Sketch Circular Pattern'), 'sketch_mirror': _adds('Mirror Sketch Entities'), 'sketch_offset': _adds('Offset Sketch Entities'), 'sketch_convert_entities': _adds('Convert Entities'), 'sketch_tutorial_simple_hole': _adds('Tutorial: Hole Sketch'), 'compare_templates': _reads('Compare Templates'), 'generate_vba_extrusion': _reads('Generate VBA: Extrusion'), 'generate_vba_revolve': _reads('Generate VBA: Revolve'), 'generate_vba_assembly_insert': _reads('Generate VBA: Insert Component'), 'generate_vba_drawing_views': _reads('Generate VBA: Drawing Views'), 'generate_vba_batch_export': _reads('Generate VBA: Batch Export'), 'generate_vba_part_modeling': _reads('Generate VBA: Part Modeling'), 'generate_vba_assembly_mates': _reads('Generate VBA: Assembly Mates'), 'generate_vba_drawing_dimensions': _reads('Generate VBA: Drawing Dimensions'), 'generate_vba_file_operations': _reads('Generate VBA: File Operations'), 'generate_vba_macro_recorder': _reads('Generate VBA: Macro Recorder')}
_INVALID_INPUT_HINT
module-attribute
¶
_INVALID_INPUT_HINT = "Fix the named field(s) and call the tool again; see the tool's input schema for the expected types and units."
Classes¶
AdapterResult
dataclass
¶
AdapterResult(status: AdapterResultStatus, data: T | None = None, error: str | None = None, execution_time: float | None = None, metadata: dict[str, Any] | None = None)
Result wrapper for adapter operations.
Attributes:
| Name | Type | Description |
|---|---|---|
data |
T | None
|
The data value. |
error |
str | None
|
The error value. |
execution_time |
float | None
|
The execution time value. |
metadata |
dict[str, Any] | None
|
The metadata value. |
status |
AdapterResultStatus
|
The status value. |
Classification
dataclass
¶
The category of a failure and the next step to suggest.
ErrorClassifier ¶
Map a failure to a :class:Classification using ordered rules.
Source code in src/solidworks_mcp/tools/error_classifier.py
Methods:¶
classify ¶
classify(message: str, exc: BaseException | None = None, *, fallback: str = OPERATION_FAILED) -> Classification
Classify message (and exc when there is one).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
The error text the caller will see. |
required |
exc
|
BaseException | None
|
The exception, when the failure was raised rather than returned. |
None
|
fallback
|
str
|
Category for an unrecognised failure: |
OPERATION_FAILED
|
Returns:
| Name | Type | Description |
|---|---|---|
Classification |
Classification
|
The first matching rule, else the fallback. |
Source code in src/solidworks_mcp/tools/error_classifier.py
InvalidInputError ¶
Bases: ValueError
The tool's input failed validation; the adapter was not called.
Requirement ¶
Bases: StrEnum
What a tool needs from SolidWorks, least first.
Support
dataclass
¶
One tool's support level and why it isn't higher.
Attributes:
| Name | Type | Description |
|---|---|---|
level |
SupportLevel
|
The tool's support level. |
reason |
str
|
One line on the gap; empty only for a stable tool. A
deprecated tool's reason is |
since |
str
|
The version a deprecated tool was deprecated in; empty for every other level. |
Methods:¶
__post_init__ ¶
Require a reason below stable, and a version for a deprecated tool.
Raises:
| Type | Description |
|---|---|
ValueError
|
If a level below stable has no reason, a stable tool
has one, or |
Source code in src/solidworks_mcp/tools/support_levels.py
replacement ¶
The tool a deprecated tool's reason names.
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The name in backticks in |
str | None
|
|
Source code in src/solidworks_mcp/tools/support_levels.py
warning ¶
The sentence a successful beta, experimental or deprecated result carries.
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: |
str | None
|
|
str | None
|
planned tool never succeeds). |
Source code in src/solidworks_mcp/tools/support_levels.py
ToolHints
dataclass
¶
One tool's title and behaviour hints.
Attributes:
| Name | Type | Description |
|---|---|---|
title |
str
|
A short human-readable name for the tool. |
read_only |
bool
|
The tool changes nothing. |
destructive |
bool
|
The tool may delete, overwrite or discard work. |
idempotent |
bool
|
Repeating a call with the same input has no further effect. |
Methods:¶
__post_init__ ¶
Reject combinations that contradict each other.
Raises:
| Type | Description |
|---|---|
ValueError
|
If a read-only tool is marked destructive or not idempotent. |
Source code in src/solidworks_mcp/tools/tool_hints.py
annotations ¶
The hints as MCP tool annotations.
Returns:
| Name | Type | Description |
|---|---|---|
ToolAnnotations |
ToolAnnotations
|
|
Source code in src/solidworks_mcp/tools/tool_hints.py
ToolOperationError ¶
Bases: Exception
An adapter operation reported failure.
Attributes:
| Name | Type | Description |
|---|---|---|
execution_time |
The adapter's timing for the failed call, if any. |
|
data |
Diagnostic data that explains the failure (e.g. rebuild errors),
returned to the caller under |
Source code in src/solidworks_mcp/tools/tool_boundary.py
ToolRegistrar ¶
ToolRegistrar(mcp: Any, classifier: ErrorClassifier = _CLASSIFIER, hints: Mapping[str, ToolHints] = TOOL_HINTS, levels: Mapping[str, Support] = SUPPORT_LEVELS, requirements: Mapping[str, Requirement] = REQUIREMENTS)
A FastMCP stand-in whose tool() applies :func:tool_boundary first.
It also gives each tool its title and behaviour hints from the hints
table, its family tag (see :func:tool_family), and its support level
from the levels table: a level:<level> tag and, below stable, a
warning on success. A needs:<requirement> tag says what it needs
from SolidWorks (tools/requirements.py). Everything else is
forwarded to the wrapped server unchanged.
Source code in src/solidworks_mcp/tools/tool_boundary.py
Methods:¶
of
classmethod
¶
Wrap mcp unless it already is a registrar (idempotent).
Every register_<area>_tools starts with mcp = ToolRegistrar.of(mcp)
so its tools get the boundary however the module is registered.
Source code in src/solidworks_mcp/tools/tool_boundary.py
tool ¶
Same contract as FastMCP.tool, with the boundary and hints applied.
Source code in src/solidworks_mcp/tools/tool_boundary.py
UnsupportedOperationError ¶
Bases: Exception
The active adapter has no capability for the requested operation.
Functions:¶
describe_validation_error ¶
Render a pydantic error as field: problem; field: problem.
Source code in src/solidworks_mcp/tools/tool_boundary.py
error_payload ¶
error_payload(message: str, classification: Classification, execution_time: float | None = None, data: Any = None) -> dict[str, Any]
Build the spec's error payload.
Source code in src/solidworks_mcp/tools/tool_boundary.py
has_tool_boundary ¶
model_parameters ¶
The parameters of fn annotated with a pydantic model.
A parameter counts when its annotation is a model, or a model | None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Callable[..., Any]
|
The tool function. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, type[BaseModel]]
|
dict[str, type[BaseModel]]: Parameter name to its model; empty when |
dict[str, type[BaseModel]]
|
the annotations can't be resolved (a model defined inside a function). |
Source code in src/solidworks_mcp/tools/tool_boundary.py
normalize_input ¶
Validate input_data as model_type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
Any
|
A |
required |
model_type
|
type[TModel]
|
The tool's pydantic input model. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
TModel |
TModel
|
The validated model. |
Raises:
| Type | Description |
|---|---|
InvalidInputError
|
Naming the offending field(s). |
Source code in src/solidworks_mcp/tools/tool_boundary.py
removed_inputs ¶
The removed inputs model was given, each with what to use instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
BaseModel
|
A validated tool input. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: One sentence per removed field present, e.g. |
list[str]
|
" |
list[str]
|
part". Empty when none was sent. |
Source code in src/solidworks_mcp/tools/input_compat.py
require_capability ¶
Raise :class:UnsupportedOperationError unless adapter has method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter
|
Any
|
The active SolidWorks adapter. |
required |
method
|
str
|
The adapter method the tool needs. |
required |
message
|
str
|
What was not done, and what to do instead. |
required |
Source code in src/solidworks_mcp/tools/tool_boundary.py
require_success ¶
require_success(result: AdapterResult[TResult], failure_message: str = 'Operation failed', *, context: str | None = None, with_data: bool = False) -> AdapterResult[TResult]
Return result when it succeeded; raise otherwise.
Mirrors the if result.is_success: ... else: error the tools used before
the boundary, so anything that is not a success - including a warning - is
reported as a failure. Tools that treat a warning as success check
result.status themselves before calling this.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
AdapterResult[TResult]
|
The adapter result to check. |
required |
failure_message
|
str
|
Message used when the adapter gave none. |
'Operation failed'
|
context
|
str | None
|
Prefix naming what failed, e.g. |
None
|
with_data
|
bool
|
Return the adapter's |
False
|
Raises:
| Type | Description |
|---|---|
ToolOperationError
|
Carrying the adapter's message and timing. |
Source code in src/solidworks_mcp/tools/tool_boundary.py
requirement_of ¶
The requirement of the tool called name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The tool's registered name. |
required |
table
|
Mapping[str, Requirement]
|
The requirements table; the module's own by default. |
REQUIREMENTS
|
Returns:
| Name | Type | Description |
|---|---|---|
Requirement |
Requirement
|
The listed requirement, or |
Requirement
|
isn't listed. |
Source code in src/solidworks_mcp/tools/requirements.py
tool_boundary ¶
tool_boundary(fn: Callable[..., Awaitable[dict[str, Any]]], classifier: ErrorClassifier = _CLASSIFIER, warning: str | None = None) -> Callable[..., Awaitable[dict[str, Any]]]
Wrap an async tool so every failure becomes an error payload.
functools.wraps keeps the signature, so FastMCP builds the same input
schema for the wrapped tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Callable[..., Awaitable[dict[str, Any]]]
|
The tool function. |
required |
classifier
|
ErrorClassifier
|
Names the failure in an error payload. |
_CLASSIFIER
|
warning
|
str | None
|
Added as |
None
|
A dict passed where the tool expects its input model is validated as
that model first, so a script can call any tool function with a dict, as
an MCP client effectively does. An input the tool no longer takes
(input_compat.REMOVED_INPUTS) is refused as invalid input before the
tool runs.
Returns:
| Type | Description |
|---|---|
Callable[..., Awaitable[dict[str, Any]]]
|
The wrapped tool. |
Source code in src/solidworks_mcp/tools/tool_boundary.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
tool_family ¶
The family tag of a tool: the name of the module that defines it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Callable[..., Any]
|
The tool function. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The module's last dotted part, e.g. |
Source code in src/solidworks_mcp/tools/tool_boundary.py
with_tool_boundary ¶
Return mcp wrapped in a :class:ToolRegistrar (typed as mcp).
The registrar duck-types the FastMCP surface the tool modules use
(tool() plus attribute forwarding), so modules keep their annotations.