solidworks_mcp.tools.docs_discovery¶
solidworks_mcp.tools.docs_discovery ¶
Docs discovery tool for SolidWorks COM and VBA command indexing.
Builds an index of every SolidWorks COM interface, with each member's signature and description, from the registered SolidWorks type library, plus the VBA library references in the registry. The API lookup tools answer from that index and build it themselves the first time, so an agent never has to prepare anything: SolidWorks only has to be installed.
Index records (:mod:.type_library) and lookup results (below) are Pydantic
models; the tools return them as plain dicts with model_dump(), like
every other tool in the package.
Attributes¶
ApiMember
module-attribute
¶
_INDEX_DIRS
module-attribute
¶
_INDEX_DIRS = (Path('.generated/docs-index'), Path('tests/.generated/solidworks_integration/docs-index'), Path('tests/.generated/docs-index'))
_LookupResultT
module-attribute
¶
_MEMBER_LISTS
module-attribute
¶
_MEMBER_LISTS: tuple[tuple[MemberType, str], ...] = (('method', 'methods'), ('property', 'properties'))
Classes¶
ApiIndexInput ¶
Bases: CompatInput
Fields every API lookup takes to choose the index it answers from.
Attributes:
| Name | Type | Description |
|---|---|---|
year |
int | None
|
The SolidWorks year whose API to answer for. |
index_file |
str | None
|
A saved index to answer from instead. |
ApiMethod ¶
Bases: BaseModel
A SolidWorks API method and its signature.
Attributes:
| Name | Type | Description |
|---|---|---|
kind |
Literal['method']
|
Always |
description |
str
|
The library's one-line help string. |
parameters |
list[ApiParameter]
|
The parameters, in call order. |
return_type |
str | None
|
What it returns; None for nothing. |
ApiParameter ¶
Bases: BaseModel
One parameter of a SolidWorks API method.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The parameter name as the type library spells it. |
type |
str
|
Its VBA type or interface name. |
direction |
Direction
|
Whether the caller passes it, SolidWorks fills it, or both. |
ApiProperty ¶
Bases: BaseModel
A SolidWorks API property.
Attributes:
| Name | Type | Description |
|---|---|---|
kind |
Literal['property']
|
Always |
description |
str
|
The library's one-line help string. |
type |
str | None
|
The value's type. |
access |
Access
|
Whether it can be read, written or both. |
CompatInput ¶
Bases: BaseModel
Base schema allowing legacy/extra fields used by existing tests.
Attributes:
| Name | Type | Description |
|---|---|---|
model_config |
Any
|
The model config value. |
DiscoverDocsInput ¶
Bases: CompatInput
Input schema for discover_solidworks_docs.
Attributes:
| Name | Type | Description |
|---|---|---|
output_dir |
str | None
|
Folder to save the index in. |
include_vba |
bool
|
Whether to scan for VBA library references. |
year |
int | None
|
The SolidWorks year whose type library to read. |
FindRelatedApiInput ¶
Bases: ApiIndexInput
Input schema for find_related_api_members.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
An interface or member name to find relatives of. |
max_results |
int
|
How many related members to return at most. |
InterfaceLookup ¶
Bases: BaseModel
lookup_api_interface's result.
Attributes:
| Name | Type | Description |
|---|---|---|
found |
bool
|
Whether the interface is indexed. |
interface |
str
|
Its name, as SolidWorks spells it when found. |
methods |
list[str] | None
|
Its method names. |
properties |
list[str] | None
|
Its property names. |
method_count |
int | None
|
How many methods. |
property_count |
int | None
|
How many properties. |
note |
str | None
|
Why no index could be built. |
LookupApiInterfaceInput ¶
Bases: ApiIndexInput
Input schema for lookup_api_interface.
Attributes:
| Name | Type | Description |
|---|---|---|
interface |
str
|
The COM interface whose members to list. |
LookupApiMethodInput ¶
Bases: ApiIndexInput
Input schema for lookup_api_method.
Attributes:
| Name | Type | Description |
|---|---|---|
interface |
str
|
The COM interface the member is on. |
method |
str
|
The method or property name. |
MemberLookup ¶
Bases: BaseModel
lookup_api_method's result: one member's signature, or no match.
Attributes:
| Name | Type | Description |
|---|---|---|
found |
bool
|
Whether the member is on the interface. |
interface |
str
|
The interface, as SolidWorks spells it when found. |
method |
str | None
|
The name asked for, on a no-match. |
member |
str | None
|
The member's real name. |
member_type |
MemberType | None
|
|
signature_indexed |
bool | None
|
Always true on a match. |
description |
str | None
|
The help string. |
parameters |
list[ApiParameter] | None
|
The parameters. |
return_type |
str | None
|
The return type (a property's value type). |
access |
Access | None
|
A property's access. |
note |
str | None
|
Why there's no match, or a casing difference. |
RelatedLookup ¶
Bases: BaseModel
find_related_api_members's result.
Attributes:
| Name | Type | Description |
|---|---|---|
found |
bool
|
Whether anything related was found. |
query |
str
|
The name asked for. |
resolved_as |
str
|
How the name was read. |
related |
list[RelatedMember]
|
The related members. |
note |
str | None
|
Why no index could be built. |
RelatedMember ¶
Bases: BaseModel
One member find_related_api_members returns.
Attributes:
| Name | Type | Description |
|---|---|---|
object |
str
|
The interface it is on. |
member |
str
|
Its name. |
member_type |
MemberType
|
|
reason |
str
|
Why it is related. |
SearchApiHelpInput ¶
Bases: ApiIndexInput
Input schema for search_solidworks_api_help.
Attributes:
| Name | Type | Description |
|---|---|---|
query |
str
|
Words to search member and interface names for. |
max_results |
int
|
How many matches to return at most. |
auto_discover_if_missing |
bool
|
Accepted for old callers; unused. |
SearchMatch ¶
Bases: BaseModel
One search_solidworks_api_help match.
Attributes:
| Name | Type | Description |
|---|---|---|
object |
str
|
The interface, or |
member |
str
|
The member or library name. |
member_type |
str
|
|
score |
int
|
Relevance; higher is better. |
status |
str | None
|
A VBA library's status. |
SolidWorksAdapter ¶
Bases: ABC
Base adapter interface for SolidWorks integration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
object | None
|
Configuration values for the operation. Defaults to None. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
_metrics |
Any
|
The metrics value. |
config |
Any
|
The config value. |
config_dict |
Any
|
The config dict value. |
Initialize adapter with configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
object | None
|
Configuration values for the operation. Defaults to None. |
None
|
Source code in src/solidworks_mcp/adapters/base.py
Methods:¶
activate_document
async
¶
Make an already-open document the active one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title_or_path
|
str
|
Title, full path, or file name of an open document. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: What was activated, or error. |
Source code in src/solidworks_mcp/adapters/base.py
add_arc
async
¶
add_arc(center_x: float, center_y: float, start_x: float, start_y: float, end_x: float, end_y: float) -> AdapterResult[str]
Add an arc to the current sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_x
|
float
|
The center x value. |
required |
center_y
|
float
|
The center y value. |
required |
start_x
|
float
|
The start x value. |
required |
start_y
|
float
|
The start y value. |
required |
end_x
|
float
|
The end x value. |
required |
end_y
|
float
|
The end y value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_centerline
async
¶
Add a centerline to the current sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x1
|
float
|
The x1 value. |
required |
y1
|
float
|
The y1 value. |
required |
x2
|
float
|
The x2 value. |
required |
y2
|
float
|
The y2 value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_chamfer
async
¶
add_chamfer(distance: float, edge_names: list[str], angle: float = 45.0, flip: bool = False) -> AdapterResult[Any]
Add an angle-distance chamfer to the named or selected edges.
At the default 45 degrees both legs equal distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
distance
|
float
|
Chamfer distance in millimeters, along one face. |
required |
edge_names
|
list[str]
|
List of edge names to chamfer. |
required |
angle
|
float
|
Chamfer angle in degrees. Defaults to 45. |
45.0
|
flip
|
bool
|
Measure |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
AdapterResult |
AdapterResult[Any]
|
Feature result or error. |
Source code in src/solidworks_mcp/adapters/base.py
add_circle
abstractmethod
async
¶
Add a circle to the current sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_x
|
float
|
The center x value. |
required |
center_y
|
float
|
The center y value. |
required |
radius
|
float
|
The radius value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_datum_tag
async
¶
add_datum_tag(label: str, attach_at_mm: tuple[float, float], x_mm: float, y_mm: float) -> AdapterResult[dict[str, Any]]
Add a datum feature symbol on a drawing edge.
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Error unless the adapter implements it. |
Source code in src/solidworks_mcp/adapters/base.py
add_drawing_view
async
¶
Add a view of a model to the active drawing sheet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Any
|
Tool payload carrying the model path, orientation, position in millimetres and optional view scale. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The new view's details, or error. |
Source code in src/solidworks_mcp/adapters/base.py
add_ellipse
async
¶
add_ellipse(center_x: float, center_y: float, major_axis: float, minor_axis: float) -> AdapterResult[str]
Add an ellipse to the current sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_x
|
float
|
The center x value. |
required |
center_y
|
float
|
The center y value. |
required |
major_axis
|
float
|
The major axis value. |
required |
minor_axis
|
float
|
The minor axis value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_fillet
async
¶
Add a fillet feature to selected edges.
Rounds the selected edges of the current solid body with the given radius.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Fillet radius in millimeters. |
required |
edge_names
|
list[str]
|
List of edge names to fillet. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AdapterResult |
AdapterResult[Any]
|
Feature result or error. |
Source code in src/solidworks_mcp/adapters/base.py
add_gtol
async
¶
add_gtol(characteristic: str, tolerance: float, x_mm: float, y_mm: float, diameter_zone: bool = False, material_condition: str = 'none', datums: list[str] | None = None, attach_at_mm: tuple[float, float] | None = None, dimension: tuple[str, str] | None = None) -> AdapterResult[dict[str, Any]]
Add a GD&T feature control frame to the active drawing.
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Error unless the adapter implements it. |
Source code in src/solidworks_mcp/adapters/base.py
add_line
abstractmethod
async
¶
Add a line to the current sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x1
|
float
|
The x1 value. |
required |
y1
|
float
|
The y1 value. |
required |
x2
|
float
|
The x2 value. |
required |
y2
|
float
|
The y2 value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_mate
async
¶
add_mate(component_a: str, component_b: str, entity_a: str = 'Front Plane', entity_b: str = 'Front Plane', mate_type: str = 'coincident', alignment: str = 'aligned', distance: float = 0.0, angle: float = 0.0, face_a: list[float] | None = None, face_b: list[float] | None = None) -> AdapterResult[dict[str, Any]]
Mate two components together in the active assembly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_a
|
str
|
First component instance name. |
required |
component_b
|
str
|
Second component instance name. |
required |
entity_a
|
str
|
Named feature on the first component. Defaults to "Front Plane". |
'Front Plane'
|
entity_b
|
str
|
Named feature on the second component. Defaults to "Front Plane". |
'Front Plane'
|
mate_type
|
str
|
Mate type, e.g. |
'coincident'
|
alignment
|
str
|
|
'aligned'
|
distance
|
float
|
Distance in millimetres, for a distance mate. Defaults to 0.0. |
0.0
|
angle
|
float
|
Angle in degrees, for an angle mate. Defaults to 0.0. |
0.0
|
face_a
|
list[float] | None
|
A point on a face of the first
component, in its part coordinates (mm), used instead of
|
None
|
face_b
|
list[float] | None
|
The same for the second component. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Mate details, or error. |
Source code in src/solidworks_mcp/adapters/base.py
add_note
async
¶
Place a text note on the active drawing sheet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Any
|
Tool payload carrying the note text, its position in millimetres and an optional font size in points. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The note's details, or error. |
Source code in src/solidworks_mcp/adapters/base.py
add_polygon
async
¶
Add a regular polygon to the current sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_x
|
float
|
The center x value. |
required |
center_y
|
float
|
The center y value. |
required |
radius
|
float
|
The radius value. |
required |
sides
|
int
|
The sides value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_rectangle
abstractmethod
async
¶
Add a rectangle to the current sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x1
|
float
|
The x1 value. |
required |
y1
|
float
|
The y1 value. |
required |
x2
|
float
|
The x2 value. |
required |
y2
|
float
|
The y2 value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_sketch_circle
async
¶
add_sketch_circle(center_x: float, center_y: float, radius: float, construction: bool = False) -> AdapterResult[str]
Alias for add_circle used by some tool flows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_x
|
float
|
The center x value. |
required |
center_y
|
float
|
The center y value. |
required |
radius
|
float
|
The radius value. |
required |
construction
|
bool
|
The construction value. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_sketch_constraint
async
¶
add_sketch_constraint(entity1: str, entity2: str | None, relation_type: str, entity3: str | None = None) -> AdapterResult[str]
Apply a geometric constraint between sketch entities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity1
|
str
|
The entity1 value. |
required |
entity2
|
str | None
|
The entity2 value. |
required |
relation_type
|
str
|
The relation type value. |
required |
entity3
|
str | None
|
Third entity ID — only used by the
|
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_sketch_dimension
async
¶
add_sketch_dimension(entity1: str, entity2: str | None, dimension_type: str, value: float) -> AdapterResult[str]
Add a sketch dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity1
|
str
|
The entity1 value. |
required |
entity2
|
str | None
|
The entity2 value. |
required |
dimension_type
|
str
|
The dimension type value. |
required |
value
|
float
|
The value value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
add_spline
async
¶
Add a spline through the provided points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
list[dict[str, float]]
|
The points value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
arrange_dimensions
async
¶
Move drawing dimensions so none overlaps, then verify.
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Error unless the adapter implements it. |
Source code in src/solidworks_mcp/adapters/base.py
auto_center_marks
async
¶
auto_center_marks(view_name: str, mark_holes: bool = True, mark_fillets: bool = False, mark_slots: bool = True) -> AdapterResult[dict[str, Any]]
Auto-insert centre marks on circular features in a drawing view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_name
|
str
|
Name of a view on the active drawing. |
required |
mark_holes
|
bool
|
Mark holes / bores. |
True
|
mark_fillets
|
bool
|
Mark fillets. |
False
|
mark_slots
|
bool
|
Mark slots. |
True
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The view and before/after centre-mark |
AdapterResult[dict[str, Any]]
|
counts, or error. |
Source code in src/solidworks_mcp/adapters/base.py
check_interference
async
¶
Check the active assembly for interfering components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
Any
|
Optional settings; |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Interference details, or error. |
Source code in src/solidworks_mcp/adapters/base.py
check_sketch_fully_defined
async
¶
Check whether a sketch is fully defined.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sketch_name
|
str | None
|
Optional sketch name to inspect. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Definition status payload. |
Source code in src/solidworks_mcp/adapters/base.py
close_model
abstractmethod
async
¶
Close the current model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
save
|
bool
|
The save value. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
AdapterResult[None]
|
AdapterResult[None]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
connect
abstractmethod
async
¶
create_assembly
abstractmethod
async
¶
create_assembly(name: str | None = None, template: str | None = None) -> AdapterResult[SolidWorksModel]
Create a new assembly document.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The name value. Defaults to None. |
None
|
template
|
str | None
|
Template file path. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksModel]
|
AdapterResult[SolidWorksModel]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
create_axis
async
¶
Create a reference axis along a principal direction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference
|
str
|
"x", "y" or "z" (case-insensitive, leading ± stripped). |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The plane pair used and feature counts, or error. |
Source code in src/solidworks_mcp/adapters/base.py
create_cut
async
¶
Create a cut feature from an existing sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sketch_name
|
str
|
The sketch name value. |
required |
depth
|
float
|
The depth value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
create_cut_extrude
async
¶
Create a cut-extrude feature from the active sketch.
Cuts material from the current solid body using the active sketch profile. Equivalent to SolidWorks Insert > Cut > Extrude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
ExtrusionParameters
|
Depth and direction parameters. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AdapterResult |
AdapterResult[Any]
|
Feature result or error. |
Source code in src/solidworks_mcp/adapters/base.py
create_drawing
abstractmethod
async
¶
create_drawing(name: str | None = None, template: str | None = None) -> AdapterResult[SolidWorksModel]
Create a new drawing document.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The name value. Defaults to None. |
None
|
template
|
str | None
|
Template file path. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksModel]
|
AdapterResult[SolidWorksModel]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
create_drawing_view
async
¶
Place a view of a model on the active drawing sheet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Any
|
Tool payload carrying the model path, orientation, position in millimetres and optional view scale. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The new view's details, or error. |
Source code in src/solidworks_mcp/adapters/base.py
create_extrusion
abstractmethod
async
¶
Create an extrusion feature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
ExtrusionParameters
|
The params value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksFeature]
|
AdapterResult[SolidWorksFeature]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
create_loft
abstractmethod
async
¶
Create a loft feature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
LoftParameters
|
The params value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksFeature]
|
AdapterResult[SolidWorksFeature]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
create_part
abstractmethod
async
¶
create_part(name: str | None = None, units: str | None = None, template: str | None = None) -> AdapterResult[SolidWorksModel]
Create a new part document.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The name value. Defaults to None. |
None
|
units
|
str | None
|
The units value. Defaults to None. |
None
|
template
|
str | None
|
Template file path. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksModel]
|
AdapterResult[SolidWorksModel]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
create_reference_plane
async
¶
create_reference_plane(reference: str, offset: float = 0.0, angle: float = 0.0, flip: bool = False, axis: str | None = None, face_point: list[float] | None = None) -> AdapterResult[dict[str, Any]]
Create a reference plane offset from, angled to, or on a plane or face.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference
|
str
|
Name of the reference plane. |
required |
offset
|
float
|
Offset distance in millimetres. Defaults to 0.0. |
0.0
|
angle
|
float
|
Angle in degrees about |
0.0
|
flip
|
bool
|
Reverse the offset or angle direction. Defaults to False. |
False
|
axis
|
str | None
|
Named axis to rotate about; needed with |
None
|
face_point
|
list[float] | None
|
|
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The new plane's name and parameters, or error. |
Source code in src/solidworks_mcp/adapters/base.py
create_reference_point
async
¶
create_reference_point(mode: str, x: float, y: float, z: float, distance: float | None = None, percent: float | None = None) -> AdapterResult[dict[str, Any]]
Create a reference point on the active part.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
"along_curve" or "face_center". |
required |
x
|
float
|
X of a point on the target edge/face, in millimetres. |
required |
y
|
float
|
Y of a point on the target edge/face, in millimetres. |
required |
z
|
float
|
Z of a point on the target edge/face, in millimetres. |
required |
distance
|
float | None
|
For "along_curve", offset from the edge start in millimetres. |
None
|
percent
|
float | None
|
For "along_curve", position as 0-100 of the edge length. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The mode and feature counts, or error. |
Source code in src/solidworks_mcp/adapters/base.py
create_revolve
abstractmethod
async
¶
Create a revolve feature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
RevolveParameters
|
The params value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksFeature]
|
AdapterResult[SolidWorksFeature]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
create_sketch
abstractmethod
async
¶
Create a new sketch on the specified plane.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plane
|
str
|
The plane value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
create_standard_drawing
async
¶
create_standard_drawing(model_path: str, output_dir: str | None = None, title: str | None = None, subtitle: str | None = None, drawing_number: str | None = None, author: str = '', revision: str = 'A', company: str = '', drawn_date: str | None = None, notes: list[str] | None = None, include_isometric: bool = True, write_model_properties: bool = True, title_block_text_height_mm: float | None = None, include_bom: bool = False) -> AdapterResult[dict[str, Any]]
Create a complete standard A3 drawing.
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Error unless the adapter implements it. |
Source code in src/solidworks_mcp/adapters/base.py
create_sweep
abstractmethod
async
¶
Create a sweep feature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
SweepParameters
|
The params value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksFeature]
|
AdapterResult[SolidWorksFeature]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
create_technical_drawing
async
¶
Lay out the standard views of a model on the active sheet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Any
|
Tool payload carrying the model path and the projection angle. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The view names created, or error. |
Source code in src/solidworks_mcp/adapters/base.py
delete_feature
async
¶
Delete a named feature or sketch from the active model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Feature or sketch name. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: What was deleted, or error. |
Source code in src/solidworks_mcp/adapters/base.py
disconnect
abstractmethod
async
¶
exit_sketch
abstractmethod
async
¶
Exit sketch editing mode.
Returns:
| Type | Description |
|---|---|
AdapterResult[None]
|
AdapterResult[None]: The result produced by the operation. |
export_file
abstractmethod
async
¶
Export the current model to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to the target file. |
required |
format_type
|
str
|
The format type value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[None]
|
AdapterResult[None]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
export_flat_pattern
async
¶
Export the active sheet-metal part's flat pattern.
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Error unless the adapter implements it. |
Source code in src/solidworks_mcp/adapters/base.py
export_image
abstractmethod
async
¶
Export a viewport screenshot (PNG/JPG) of the current model.
Payload keys: file_path (str): Absolute output path. width (int): Image width in pixels. height (int): Image height in pixels. view_orientation (str): One of "isometric", "front", "top", "right", "back", "bottom", "current".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict
|
The payload value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict]
|
AdapterResult[dict]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
get_application_info
async
¶
Describe the connected SolidWorks without changing anything.
Only file names leave the adapter, never full paths, so the result
can be pasted into a public report. A value that cannot be read is
None, never guessed.
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: |
AdapterResult[dict[str, Any]]
|
|
AdapterResult[dict[str, Any]]
|
|
AdapterResult[dict[str, Any]]
|
|
Source code in src/solidworks_mcp/adapters/base.py
get_custom_properties
async
¶
Read the custom properties of the active document.
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Error unless the adapter implements it. |
Source code in src/solidworks_mcp/adapters/base.py
get_dimension
abstractmethod
async
¶
Get the value of a dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: |
Source code in src/solidworks_mcp/adapters/base.py
get_mass_properties
abstractmethod
async
¶
Get mass properties of the current model.
Returns:
| Type | Description |
|---|---|
AdapterResult[MassProperties]
|
AdapterResult[MassProperties]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
get_material
async
¶
Read the material assigned to the active part.
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Error unless the adapter implements it. |
Source code in src/solidworks_mcp/adapters/base.py
get_metrics ¶
Get adapter metrics.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: A dictionary containing the resulting values. |
get_model_geometry_summary
async
¶
Summarise the active part or assembly without changing it.
Must not rebuild the model, modify it, or clear the selection, so
callers can read it around a feature call. Values the adapter cannot
determine are None, never guessed.
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: |
AdapterResult[dict[str, Any]]
|
|
AdapterResult[dict[str, Any]]
|
|
AdapterResult[dict[str, Any]]
|
|
AdapterResult[dict[str, Any]]
|
|
Source code in src/solidworks_mcp/adapters/base.py
get_model_info
abstractmethod
async
¶
Get metadata for the active model.
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The result produced by the operation. |
get_selected_entities
async
¶
Report the faces/edges/vertices currently selected in the live UI.
Lets an agent see exactly what the user has clicked on in SolidWorks (e.g. "chamfer THIS face") instead of inferring it from a screenshot.
Returns:
| Type | Description |
|---|---|
AdapterResult[list[dict[str, Any]]]
|
AdapterResult[list[dict[str, Any]]]: One descriptor per selected |
AdapterResult[list[dict[str, Any]]]
|
entity. See the PyWin32 adapter's implementation for the field |
AdapterResult[list[dict[str, Any]]]
|
set (varies by entity type). |
Source code in src/solidworks_mcp/adapters/base.py
health_check
abstractmethod
async
¶
Get adapter health status.
Returns:
| Name | Type | Description |
|---|---|---|
AdapterHealth |
AdapterHealth
|
The result produced by the operation. |
insert_bom_table
async
¶
insert_bom_table(view_name: str, template_path: str | None = None, bom_type: str = 'top_level_only', x_mm: float | None = None, y_mm: float | None = None) -> AdapterResult[dict[str, Any]]
Insert a BOM table anchored to an assembly drawing view.
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Error unless the adapter implements it. |
Source code in src/solidworks_mcp/adapters/base.py
insert_component
async
¶
insert_component(file_path: str, x: float = 0.0, y: float = 0.0, z: float = 0.0) -> AdapterResult[dict[str, Any]]
Insert a part or sub-assembly into the active assembly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Absolute path to the |
required |
x
|
float
|
X position in millimetres. Defaults to 0.0. |
0.0
|
y
|
float
|
Y position in millimetres. Defaults to 0.0. |
0.0
|
z
|
float
|
Z position in millimetres. Defaults to 0.0. |
0.0
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Component name and counts, or error. |
Source code in src/solidworks_mcp/adapters/base.py
insert_model_dimensions
async
¶
insert_model_dimensions(view_name: str | None = None, include_hole_wizard: bool = True) -> AdapterResult[dict[str, Any]]
Bring model dimensions into drawing views.
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Error unless the adapter implements it. |
Source code in src/solidworks_mcp/adapters/base.py
is_connected
abstractmethod
¶
Check if connected to SolidWorks.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if connected, otherwise False. |
list_available_materials
async
¶
List materials from the configured material libraries.
Returns:
| Type | Description |
|---|---|
AdapterResult[list[dict[str, str]]]
|
AdapterResult[list[dict[str, str]]]: Error unless the adapter implements it. |
Source code in src/solidworks_mcp/adapters/base.py
list_components
async
¶
List the top-level components of the active assembly.
Returns:
| Type | Description |
|---|---|
AdapterResult[list[str]]
|
AdapterResult[list[str]]: Component instance names, or error. |
Source code in src/solidworks_mcp/adapters/base.py
list_configurations
abstractmethod
async
¶
List configuration names for the active model.
Returns:
| Type | Description |
|---|---|
AdapterResult[list[str]]
|
AdapterResult[list[str]]: The result produced by the operation. |
list_drawing_views
async
¶
List the views on the active drawing.
Returns:
| Type | Description |
|---|---|
AdapterResult[list[str]]
|
AdapterResult[list[str]]: View names, or error. |
Source code in src/solidworks_mcp/adapters/base.py
list_features
abstractmethod
async
¶
list_features(include_suppressed: bool = False, max_assembly_depth: int = 2) -> AdapterResult[list[dict[str, Any]]]
List model features from the feature tree.
For a Part document, returns that document's own feature list,
unchanged from prior behavior. For an Assembly document, returns a
single flat list containing the assembly's own top-level features
plus every resolved component's features, recursing into
sub-assemblies up to max_assembly_depth. Every descriptor gains
component, component_path, and component_parent keys:
None for a document's own features (Part features, or an Assembly's
top-level features), or the owning component's name/path for a
component-derived feature. component_parent is the immediate parent
component name when the component is nested inside a sub-assembly,
otherwise None. A component that cannot be resolved (suppressed,
lightweight-and-unloaded, missing file) is represented by one descriptor
with type: "UnresolvedComponent" instead of being silently dropped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_suppressed
|
bool
|
The include suppressed value. Defaults to False. Applied independently to the assembly's own features and to each component's features. |
False
|
max_assembly_depth
|
int
|
How many levels of sub-assembly to recurse into. Defaults to 2. Ignored for Part documents. A component beyond the configured depth still appears in the result as a single descriptor (name + path), not expanded. |
2
|
Returns:
| Type | Description |
|---|---|
AdapterResult[list[dict[str, Any]]]
|
AdapterResult[list[dict[str, Any]]]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
list_model_dimensions
async
¶
List every dimension in the active part or assembly.
Returns:
| Type | Description |
|---|---|
AdapterResult[list[dict[str, Any]]]
|
AdapterResult[list[dict[str, Any]]]: Error unless the adapter implements it. |
Source code in src/solidworks_mcp/adapters/base.py
list_open_documents
async
¶
Enumerate every document currently open in SolidWorks.
Returns:
| Type | Description |
|---|---|
AdapterResult[list[dict[str, Any]]]
|
AdapterResult[list[dict[str, Any]]]: One entry per open document |
AdapterResult[list[dict[str, Any]]]
|
( |
Source code in src/solidworks_mcp/adapters/base.py
measure_entities
async
¶
Measure one or two selected entities.
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Error unless the adapter implements it. |
Source code in src/solidworks_mcp/adapters/base.py
mirror_feature
async
¶
mirror_feature(features: list[str], mirror_plane: str, merge: bool = True, mirror_bodies: bool = True) -> AdapterResult[dict[str, Any]]
Mirror solid bodies or features about a plane.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
list[str]
|
Body or feature names to mirror. |
required |
mirror_plane
|
str
|
Plane name to mirror about. |
required |
merge
|
bool
|
Merge the mirrored result with the original. Defaults to True. |
True
|
mirror_bodies
|
bool
|
Mirror whole bodies rather than features. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The mirror feature's name, inputs and volume |
AdapterResult[dict[str, Any]]
|
before/after, or error. |
Source code in src/solidworks_mcp/adapters/base.py
open_model
abstractmethod
async
¶
Open a SolidWorks model (part, assembly, or drawing).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to the target file. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksModel]
|
AdapterResult[SolidWorksModel]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
pattern_circular
async
¶
pattern_circular(features: list[str], axis: str, count: int, angle: float = 360.0, equal_spacing: bool = True) -> AdapterResult[dict[str, Any]]
Pattern features around an axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
list[str]
|
Names of the features to pattern. |
required |
axis
|
str
|
Name of the axis to rotate about. |
required |
count
|
int
|
Total number of instances including the original. |
required |
angle
|
float
|
Total angle in degrees to spread them over. Defaults to 360.0. |
360.0
|
equal_spacing
|
bool
|
Space instances evenly across |
True
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: What was patterned and the volume |
AdapterResult[dict[str, Any]]
|
before/after, or error. |
Source code in src/solidworks_mcp/adapters/base.py
rebuild_model
async
¶
Force a rebuild and report per-feature rebuild errors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
top_level_only
|
bool
|
Rebuild only the top level of an assembly. Defaults to False (full rebuild). |
False
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: |
AdapterResult[dict[str, Any]]
|
|
AdapterResult[dict[str, Any]]
|
|
AdapterResult[dict[str, Any]]
|
|
AdapterResult[dict[str, Any]]
|
ERROR (still carrying |
AdapterResult[dict[str, Any]]
|
remains. |
Source code in src/solidworks_mcp/adapters/base.py
rename_feature
async
¶
Rename an existing feature on the feature tree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
old_name
|
str
|
Current feature name. |
required |
new_name
|
str
|
New feature name. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The old and new names, or error. |
Source code in src/solidworks_mcp/adapters/base.py
reset_circuit_breakers
async
¶
Re-open operations a circuit breaker paused.
An adapter without a circuit breaker has nothing paused; the breaker and the connection pool override this.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
str | None
|
The operation to reset; |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, list[str]]]
|
AdapterResult[dict[str, list[str]]]: |
Source code in src/solidworks_mcp/adapters/base.py
save_body_as_part
async
¶
Extract one solid body from the active multibody part to a new file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body_name
|
str
|
Name of a solid body in the active part. |
required |
file_path
|
str
|
Absolute path for the new |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The body, the written path, and the |
AdapterResult[dict[str, Any]]
|
solid-body names found, or error. |
Source code in src/solidworks_mcp/adapters/base.py
save_file
async
¶
Save the active model to the existing path or the provided path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str | None
|
Path to the target file. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[Any]
|
AdapterResult[Any]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
select_face_edges
async
¶
select_face_edges(point: list[float] | None = None, side: str | None = None, plane: str | None = None, edge_type: str = 'all', append: bool = False) -> AdapterResult[dict[str, Any]]
Multi-select every edge bounding one face of the active part.
Exactly one of point/side/plane identifies the face.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
list[float] | None
|
|
None
|
side
|
str | None
|
|
None
|
plane
|
str | None
|
Reference plane name; the body face(s) lying on it. |
None
|
edge_type
|
str
|
|
'all'
|
append
|
bool
|
Add to the current selection. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: |
AdapterResult[dict[str, Any]]
|
(one descriptor per selected edge) and |
Source code in src/solidworks_mcp/adapters/base.py
select_feature
async
¶
Select a named feature, sketch, plane or component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
feature_name
|
str
|
The feature name, optionally |
required |
append
|
bool
|
Add to the current selection instead of replacing it. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: On success |
AdapterResult[dict[str, Any]]
|
|
AdapterResult[dict[str, Any]]
|
|
AdapterResult[dict[str, Any]]
|
SUCCESS with |
Source code in src/solidworks_mcp/adapters/base.py
set_component_state
async
¶
set_component_state(component: str, fixed: bool | None = None, flexible: bool | None = None) -> AdapterResult[dict[str, Any]]
Fix or float a component, and make a sub-assembly rigid or flexible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component
|
str
|
Instance name, as |
required |
fixed
|
bool | None
|
True fixes it, False floats it. |
None
|
flexible
|
bool | None
|
True flexible, False rigid. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The state before and after, or error. |
Source code in src/solidworks_mcp/adapters/base.py
set_custom_property
async
¶
set_custom_property(name: str, value: str, configuration: str | None = None) -> AdapterResult[dict[str, Any]]
Create or overwrite one custom property.
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Error unless the adapter implements it. |
Source code in src/solidworks_mcp/adapters/base.py
set_dimension
abstractmethod
async
¶
Set the value of a dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name value. |
required |
value
|
float
|
The value value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[None]
|
AdapterResult[None]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
set_material
async
¶
set_material(material_name: str, database: str | None = None, configuration: str | None = None) -> AdapterResult[dict[str, Any]]
Assign a material to the active part.
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Error unless the adapter implements it. |
Source code in src/solidworks_mcp/adapters/base.py
set_sheet_scale
async
¶
Set the active drawing sheet's scale.
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Error unless the adapter implements it. |
Source code in src/solidworks_mcp/adapters/base.py
set_units
async
¶
Set the active document's linear unit system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unit_system
|
str
|
One of |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: What was applied, or error. |
Source code in src/solidworks_mcp/adapters/base.py
sketch_circular_pattern
async
¶
Create a circular pattern of sketch entities around the sketch origin.
The rotation axis is always the sketch origin — SW's
CreateCircularSketchStepAndRepeat has no pattern-centre
parameter and derives the axis from the seed's geometry. Place
the seed entity at the desired radius from the origin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entities
|
list[str]
|
The entities value. |
required |
angle
|
float
|
The angle value. |
required |
count
|
int
|
The count value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
sketch_linear_pattern
async
¶
sketch_linear_pattern(entities: list[str], direction_x: float, direction_y: float, spacing: float, count: int) -> AdapterResult[str]
Create a linear pattern of sketch entities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entities
|
list[str]
|
The entities value. |
required |
direction_x
|
float
|
The direction x value. |
required |
direction_y
|
float
|
The direction y value. |
required |
spacing
|
float
|
The spacing value. |
required |
count
|
int
|
The count value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
sketch_mirror
async
¶
Mirror sketch entities about a mirror line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entities
|
list[str]
|
The entities value. |
required |
mirror_line
|
str
|
The mirror line value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
sketch_offset
async
¶
sketch_offset(entities: list[str], offset_distance: float, reverse_direction: bool) -> AdapterResult[str]
Offset sketch entities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entities
|
list[str]
|
The entities value. |
required |
offset_distance
|
float
|
The offset distance value. |
required |
reverse_direction
|
bool
|
The reverse direction value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/base.py
suppress_feature
async
¶
Suppress or unsuppress a named feature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Feature name. |
required |
suppress
|
bool
|
True to suppress, False to unsuppress. |
True
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The resulting state, or error. |
Source code in src/solidworks_mcp/adapters/base.py
undo
async
¶
Undo the last operations in the active model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
count
|
int
|
Number of steps to undo. |
1
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: Whether the tree changed, or error. |
Source code in src/solidworks_mcp/adapters/base.py
update_metrics ¶
Update adapter metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation_time
|
float
|
The operation time value. |
required |
success
|
bool
|
The success value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
None. |
Source code in src/solidworks_mcp/adapters/base.py
SolidWorksDocsDiscovery ¶
SolidWorksDocsDiscovery(output_dir: Path | None = None, year: int | None = None, strict_year: bool = False)
Discover and index SolidWorks COM and VBA documentation.
The COM part is read from the registered SolidWorks type library, so it needs SolidWorks installed but never starts, attaches to or calls it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
Path | None
|
Where the index is saved. Defaults to
|
None
|
year
|
int | None
|
The SolidWorks year whose type library to read; None for the newest installed. |
None
|
strict_year
|
bool
|
True when the caller asked for |
False
|
Attributes:
| Name | Type | Description |
|---|---|---|
output_dir |
Path
|
Where the index is saved. |
index |
dict[str, Any]
|
The index built so far, as saved. |
Initialize docs discovery.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
Path | None
|
Where the index is saved. |
None
|
year
|
int | None
|
The SolidWorks year to read, if any. |
None
|
strict_year
|
bool
|
True to fail when that year isn't installed. |
False
|
Source code in src/solidworks_mcp/tools/docs_discovery.py
Methods:¶
create_search_summary ¶
Summarize the index for a response.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Interface, method and property totals, the type |
dict[str, Any]
|
library version and the VBA libraries found. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
discover_all ¶
Run full discovery of COM and, optionally, VBA documentation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_vba
|
bool
|
Also scan the registry for VBA references. |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: The complete index. |
Raises:
| Type | Description |
|---|---|
TypeLibraryUnavailable
|
No matching type library is registered. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
discover_com_objects ¶
Index every COM interface in the SolidWorks type library.
Also records which type library was read and the member totals.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Interface name -> its methods, properties and |
dict[str, Any]
|
member signatures, as saved. |
Raises:
| Type | Description |
|---|---|
TypeLibraryUnavailable
|
No matching type library is registered. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
discover_vba_references ¶
Discover VBA/TypeLib references via the Windows Registry.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: The SolidWorks and Office/VBA type libraries |
dict[str, Any]
|
found; empty off Windows. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
save_index ¶
Save the index as compact JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The file name inside |
'solidworks_docs_index.json'
|
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
The saved file. |
Raises:
| Type | Description |
|---|---|
ToolOperationError
|
The file could not be written. Lookups would otherwise rebuild the index on every call. |
Source code in src/solidworks_mcp/tools/docs_discovery.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
TypeLibraryUnavailable ¶
Bases: ToolOperationError
No SolidWorks type library could be loaded; the message says why.
Source code in src/solidworks_mcp/tools/tool_boundary.py
_IndexForLookup
dataclass
¶
_IndexForLookup(index: dict[str, Any], index_file: Path | None, status: IndexStatus, note: str | None = None, year: int | None = None)
The index a lookup answers from, and how it was obtained.
Attributes:
| Name | Type | Description |
|---|---|---|
index |
dict[str, Any]
|
The index; empty when |
index_file |
Path | None
|
The file it was read from or saved to. |
status |
IndexStatus
|
|
note |
str | None
|
Why the index is unavailable. |
year |
int | None
|
The year asked for, reported when the index doesn't name its type library (none could be built, or a caller's file lacks it). |
Methods:¶
annotate ¶
Add why no index could be built to a lookup result, when it couldn't.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
_LookupResultT
|
A lookup result. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
_LookupResultT |
_LookupResultT
|
The same result. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
payload ¶
The fields every lookup response carries about its index.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: |
dict[str, Any]
|
library that answered, |
Source code in src/solidworks_mcp/tools/docs_discovery.py
Functions:¶
_build_index ¶
_build_index(year: int | None, strict: bool, output_dir: Path | None = None, include_vba: bool = True) -> tuple[SolidWorksDocsDiscovery, Path]
Build the docs index from the type library and save it under its year.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int | None
|
The SolidWorks year to read; None for the newest. |
required |
strict
|
bool
|
True when the caller asked for |
required |
output_dir
|
Path | None
|
Where to save; the default index folder if None. |
None
|
include_vba
|
bool
|
Also scan for VBA references. |
True
|
Returns:
| Type | Description |
|---|---|
SolidWorksDocsDiscovery
|
tuple[SolidWorksDocsDiscovery, Path]: The discovery holding the |
Path
|
index, and the saved file. |
Raises:
| Type | Description |
|---|---|
TypeLibraryUnavailable
|
No matching type library is registered. |
ToolOperationError
|
The index could not be saved. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
_discover_vba_references_via_registry ¶
Enumerate VBA/TypeLib references via the Windows Registry.
Scans HKEY_CLASSES_ROOT\TypeLib for entries whose name matches SolidWorks or common Office/VBA libraries.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: |
dict[str, Any]
|
GUID, version and status; empty off Windows. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
_extract_year ¶
Extract a 4-digit year (20xx) from a string such as an install path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str | None
|
The text to search. |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
int | None: The year, or None when there isn't one. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
_fallback_help_for_query ¶
Suggest MCP tools for a query, alongside or instead of API matches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The search words. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: |
Source code in src/solidworks_mcp/tools/docs_discovery.py
_find_index_file ¶
Find the saved index for a SolidWorks year.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
The type library's year. |
required |
Returns:
| Type | Description |
|---|---|
Path | None
|
Path | None: The first |
Path | None
|
index folders, or None. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
_find_related_api_members ¶
Given an indexed interface or member name, return related members.
- An interface name -> its own members.
- A member name -> the other members of every interface that also exposes it (siblings commonly used together), plus name-substring matches elsewhere in the index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
dict[str, Any]
|
The index. |
required |
name
|
str
|
The interface or member name. |
required |
max_results
|
int
|
How many related members to keep. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RelatedLookup |
RelatedLookup
|
The related members and how |
Source code in src/solidworks_mcp/tools/docs_discovery.py
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 | |
_index_for_lookup ¶
_index_for_lookup(requested_year: int | None, explicit_index_file: str | None, config: Any) -> _IndexForLookup
Find the saved index for the type library a lookup reads, or build it.
The index is found by the type library version the registry says would
be read, so it is built once and reused, whatever year was guessed. An
index in an older format, or from another type library version, is
rebuilt, never answered from. A usable explicit_index_file is
answered from directly, with no registry read.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requested_year
|
int | None
|
The year the caller asked for, if any. |
required |
explicit_index_file
|
str | None
|
An index file the caller named. |
required |
config
|
Any
|
Server configuration. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
_IndexForLookup |
_IndexForLookup
|
The index and how it was obtained. |
Raises:
| Type | Description |
|---|---|
ToolOperationError
|
A built index could not be saved. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
_index_is_stale ¶
Whether an index file is older than max_age_days.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index_file
|
Path | None
|
The file, if any. |
required |
max_age_days
|
int
|
The age limit in days. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True when the file exists and is older than the limit. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
_load_index_file ¶
Read a saved index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index_file
|
Path
|
The JSON file. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
dict[str, Any] | None: The index, or None when the file is missing |
dict[str, Any] | None
|
or isn't a JSON object. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
_lookup_interface ¶
List an interface's methods and properties, or say it isn't indexed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
dict[str, Any]
|
The index. |
required |
interface
|
str
|
The interface name asked for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
InterfaceLookup |
InterfaceLookup
|
Its member names and counts, or a no-match. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
_lookup_method ¶
Look up a method or property's signature on an interface.
Matching ignores case, as COM late binding does; member is the name
as the type library spells it. Only the matched record is validated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
dict[str, Any]
|
The index. |
required |
interface
|
str
|
The interface name asked for. |
required |
method
|
str
|
The member name asked for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
MemberLookup |
MemberLookup
|
The signature, or a no-match with a note. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
_maybe_refresh_index ¶
_maybe_refresh_index(index: dict[str, Any], index_file: Path, year: int, config: Any) -> tuple[dict[str, Any], Path]
Rebuild a current index that is old, when the config allows.
A SolidWorks service pack can replace the type library in place, so an
index older than docs_index_max_age_days is rebuilt when
config.docs_index_auto_refresh is on. Any failure keeps the existing
index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
dict[str, Any]
|
The saved index. |
required |
index_file
|
Path
|
Its file. |
required |
year
|
int
|
The type library's year. |
required |
config
|
Any
|
Server configuration. |
required |
Returns:
| Type | Description |
|---|---|
tuple[dict[str, Any], Path]
|
tuple[dict[str, Any], Path]: The (possibly rebuilt) index and file. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
_rebuild_rag_index ¶
Rebuild the FAISS solidworks-api-docs namespace from a saved index.
Optional: it needs the faiss-cpu extra, and a failure here never
fails the discovery that triggered it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index_file
|
Path
|
The saved docs index. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True when the RAG index was rebuilt and saved. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
_resolve_interface ¶
Find an interface by name, ignoring case.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
dict[str, Any]
|
The index. |
required |
name
|
str
|
The interface name asked for. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, dict[str, Any]] | None
|
tuple[str, dict[str, Any]] | None: Its real name and record, or None. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
_resolve_solidworks_year ¶
The year a call asked for, else the year the server was started with.
Never guessed from folder names: those can be missing, or left behind by an uninstalled version. None means "the newest installed".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requested_year
|
int | None
|
The year the call asked for. |
required |
config
|
Any
|
Server configuration ( |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
int | None: The year, or None. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
_search_index ¶
Search the index's interface, member and VBA library names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
dict[str, Any]
|
The index. |
required |
query
|
str
|
Words to look for; each word scores separately. |
required |
max_results
|
int
|
How many matches to keep. |
required |
Returns:
| Type | Description |
|---|---|
list[SearchMatch]
|
list[SearchMatch]: The best matches, highest score first. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
index_type_library ¶
Index every dispatch interface in a type library.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lib
|
TypeLibLike
|
An ITypeLib (or a fake with the same methods). |
required |
Returns:
| Type | Description |
|---|---|
dict[str, ApiInterface]
|
dict[str, ApiInterface]: Interface name -> its record. |
Source code in src/solidworks_mcp/tools/type_library.py
load_type_library ¶
load_type_library(year: int | None = None, strict: bool = False, com: Any = None, registry: Any = None) -> tuple[Any, TypeLibraryInfo]
Load the registered SolidWorks type library for a year.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int | None
|
The wanted SolidWorks year; None for the newest. |
None
|
strict
|
bool
|
True to fail when that year isn't installed. |
False
|
com
|
Any
|
The |
None
|
registry
|
Any
|
The |
None
|
Returns:
| Type | Description |
|---|---|
tuple[Any, TypeLibraryInfo]
|
tuple[Any, TypeLibraryInfo]: The ITypeLib and where it came from. |
Raises:
| Type | Description |
|---|---|
TypeLibraryUnavailable
|
Not on Windows with pywin32, no matching type library is registered, or the registered one won't load. |
Source code in src/solidworks_mcp/tools/type_library.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
register_docs_discovery_tools
async
¶
register_docs_discovery_tools(mcp: FastMCP, adapter: SolidWorksAdapter, config: dict[str, Any]) -> int
Register the docs discovery and API lookup tools with FastMCP.
None of them use the adapter or SolidWorks itself: they read the installed type library.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mcp
|
FastMCP
|
The server to register on. |
required |
adapter
|
SolidWorksAdapter
|
Unused; kept for the registrar's uniform signature. |
required |
config
|
dict[str, Any]
|
Server configuration ( |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The number of tools registered. |
Source code in src/solidworks_mcp/tools/docs_discovery.py
1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 | |
target_version ¶
target_version(year: int | None = None, strict: bool = False, registry: Any = None) -> tuple[int, int]
The type library version a load for year would read, without loading it.
Lookups use this to find the saved index for that version before deciding whether to build one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int | None
|
The wanted SolidWorks year; None for the newest. |
None
|
strict
|
bool
|
True to fail when that year isn't installed. |
False
|
registry
|
Any
|
The |
None
|
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
tuple[int, int]: The |
Raises:
| Type | Description |
|---|---|
TypeLibraryUnavailable
|
Not on Windows, or no matching type library is registered. |
Source code in src/solidworks_mcp/tools/type_library.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.
Source code in src/solidworks_mcp/tools/tool_boundary.py
year_of ¶
The SolidWorks year a type library major version belongs to.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
major
|
int
|
The type library major version, e.g. 34. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The release year, e.g. 2026. |