solidworks_mcp.adapters.factory¶
solidworks_mcp.adapters.factory ¶
Adapter factory for creating SolidWorks adapters.
Provides centralized adapter creation with configuration-based selection and automatic fallback strategies.
Classes¶
AdapterFactory ¶
Factory-pattern adapter creator with singleton and fallback strategies.
Manages adapter registration and creation with configuration-based selection. Automatically wraps adapters with decorators (circuit breaker, connection pool) based on configuration. Implements singleton pattern for consistency.
Attributes:
| Name | Type | Description |
|---|---|---|
_adapter_registry |
dict[AdapterType, type[SolidWorksAdapter]]
|
The adapter registry value. |
_adapters |
dict[AdapterType, type[SolidWorksAdapter]]
|
The adapters value. |
_instance |
AdapterFactory | None
|
The instance value. |
Example
factory = AdapterFactory() config = SolidWorksMCPConfig(adapter_type=AdapterType.PYWIN32) adapter = factory.create_adapter(config) await adapter.connect()
Methods:¶
__new__ ¶
Initialize or return singleton AdapterFactory instance.
Enforces singleton pattern to ensure single adapter registry and consistent factory behavior across application lifetime.
Returns:
| Name | Type | Description |
|---|---|---|
AdapterFactory |
AdapterFactory
|
The result produced by the operation. |
Example
factory1 = AdapterFactory() factory2 = AdapterFactory() factory1 is factory2 True
Source code in src/solidworks_mcp/adapters/factory.py
create_adapter
classmethod
¶
Create and configure a SolidWorks adapter instance.
Determines the best adapter type based on configuration and environment. Selects implementation, applies wrappers (circuit breaker, connection pool), and returns a fully-initialized adapter ready for connection.
The adapter is automatically downgraded to Mock on non-Windows platforms or when testing is enabled, with fallback to configured type otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
SolidWorksMCPConfig
|
Configuration values for the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolidWorksAdapter |
SolidWorksAdapter
|
The result produced by the operation. |
Example
config = SolidWorksMCPConfig(mock_solidworks=True) adapter = AdapterFactory.create_adapter(config) isinstance(adapter, MockSolidWorksAdapter) True
Source code in src/solidworks_mcp/adapters/factory.py
register_adapter
classmethod
¶
Register an adapter class for a given adapter type.
Updates the adapter registry to map a specific AdapterType enum value to a SolidWorksAdapter implementation class. Called during initialization to register built- in adapters (PyWin32, Mock, etc.).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adapter_type
|
AdapterType
|
The adapter type value. |
required |
adapter_class
|
type[SolidWorksAdapter]
|
The adapter class value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
None. |
Example
from adapters.pywin32_adapter import PyWin32Adapter AdapterFactory.register_adapter( ... AdapterType.PYWIN32, PyWin32Adapter ... )
Source code in src/solidworks_mcp/adapters/factory.py
AdapterType ¶
Bases: StrEnum
SolidWorks adapter implementation options.
Attributes:
| Name | Type | Description |
|---|---|---|
EDGE_DOTNET |
Any
|
The edge dotnet value. |
MOCK |
Any
|
The mock value. |
POWERSHELL |
Any
|
The powershell value. |
PYWIN32 |
Any
|
The pywin32 value. |
VBA |
Any
|
The vba value. |
MockSolidWorksAdapter ¶
Bases: SolidWorksAdapter
Mock adapter that simulates SolidWorks operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
object | None
|
Configuration values for the operation. Defaults to None. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
_connected |
Any
|
The connected value. |
_delays |
Any
|
The delays value. |
_is_connected_proxy |
Any
|
The is connected proxy value. |
_operation_count |
Any
|
The operation count value. |
_simulate_errors |
Any
|
The simulate errors value. |
Initialize the mock solid works adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
object | None
|
Configuration values for the operation. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
None. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
Methods:¶
__getattribute__ ¶
Build internal getattribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.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]
Mock adding a circular arc to sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_x
|
float
|
Arc centre X. |
required |
center_y
|
float
|
Arc centre Y. |
required |
start_x
|
float
|
Arc start point X. |
required |
start_y
|
float
|
Arc start point Y. |
required |
end_x
|
float
|
Arc end point X. |
required |
end_y
|
float
|
Arc end point Y. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
add_centerline
async
¶
Mock adding a construction centerline to 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/mock_adapter.py
add_circle
async
¶
Mock adding a circle to 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/mock_adapter.py
add_ellipse
async
¶
add_ellipse(center_x: float, center_y: float, major_axis: float, minor_axis: float) -> AdapterResult[str]
Mock adding an axis-aligned ellipse to sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_x
|
float
|
Ellipse centre X in millimetres. |
required |
center_y
|
float
|
Ellipse centre Y in millimetres. |
required |
major_axis
|
float
|
Full major-axis length in millimetres. |
required |
minor_axis
|
float
|
Full minor-axis length in millimetres. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
add_line
async
¶
Mock adding a line to 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/mock_adapter.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) -> AdapterResult[dict[str, Any]]
Mock mating two components 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. Defaults to "coincident". |
'coincident'
|
alignment
|
str
|
Mate alignment. Defaults to "aligned". |
'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
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 | |
add_polygon
async
¶
Mock adding a regular polygon to sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_x
|
float
|
Polygon centre X in millimetres. |
required |
center_y
|
float
|
Polygon centre Y in millimetres. |
required |
radius
|
float
|
Circumradius in millimetres (distance from centre
to each vertex; matches the real adapter's
|
required |
sides
|
int
|
Number of polygon sides. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
add_rectangle
async
¶
Mock adding a rectangle to 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/mock_adapter.py
add_sketch_constraint
async
¶
add_sketch_constraint(entity1: str, entity2: str | None, relation_type: str, entity3: str | None = None) -> AdapterResult[str]
Mock adding a geometric constraint between sketch entities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity1
|
str
|
Primary sketch-entity ID. |
required |
entity2
|
str | None
|
Secondary sketch-entity ID, or None for single-entity relations (horizontal, vertical, fix). |
required |
relation_type
|
str
|
Constraint name (see RELATION_NAME_MAP). |
required |
entity3
|
str | None
|
Third entity ID — only used by the
|
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: SUCCESS with a placeholder constraint ID, or ERROR if no active sketch, the relation_type is unsupported, arity is wrong, or an entity ID is unknown. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 | |
add_sketch_line
async
¶
add_sketch_line(x1: float, y1: float, x2: float, y2: float, construction: bool = False) -> AdapterResult[dict[str, Any]]
Legacy compatibility wrapper around add_line.
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 |
construction
|
bool
|
The construction value. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
add_spline
async
¶
Mock adding a NURBS spline through the supplied points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
list[dict[str, float]]
|
Ordered control points with
|
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
check_sketch_fully_defined
async
¶
Mock check for sketch definition status.
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/mock_adapter.py
close_model
async
¶
Mock closing 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/mock_adapter.py
connect
async
¶
Mock connection to SolidWorks.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
None. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
create_assembly
async
¶
Mock creating a new assembly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The name value. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksModel]
|
AdapterResult[SolidWorksModel]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
create_drawing
async
¶
Mock creating a new drawing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The name value. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksModel]
|
AdapterResult[SolidWorksModel]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
create_extrusion
async
¶
create_extrusion(params: ExtrusionParameters | str, depth: float | None = None, direction: str | None = None) -> AdapterResult[SolidWorksFeature]
Mock creating an extrusion feature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
ExtrusionParameters | str
|
The params value. |
required |
depth
|
float | None
|
The depth value. Defaults to None. |
None
|
direction
|
str | None
|
The direction value. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksFeature]
|
AdapterResult[SolidWorksFeature]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
create_loft
async
¶
Mock creating 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/mock_adapter.py
create_part
async
¶
Mock creating a new part.
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
|
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksModel]
|
AdapterResult[SolidWorksModel]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
create_revolve
async
¶
Mock creating 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/mock_adapter.py
create_sketch
async
¶
Mock creating a sketch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plane
|
str
|
The plane value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
create_sweep
async
¶
Mock creating 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/mock_adapter.py
disconnect
async
¶
Mock disconnection from SolidWorks.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
None. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
exit_sketch
async
¶
Mock exiting sketch mode.
Returns:
| Type | Description |
|---|---|
AdapterResult[None]
|
AdapterResult[None]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
export_file
async
¶
Mock exporting 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/mock_adapter.py
1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 | |
export_image
async
¶
Mock export of a PNG/JPG viewport screenshot.
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/mock_adapter.py
get_dimension
async
¶
Mock getting a dimension value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[float]
|
AdapterResult[float]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
get_mass_properties
async
¶
Mock getting mass properties.
Returns:
| Type | Description |
|---|---|
AdapterResult[MassProperties]
|
AdapterResult[MassProperties]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
get_model_info
async
¶
Mock metadata for the currently active model.
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
health_check
async
¶
Get mock health status.
Returns:
| Name | Type | Description |
|---|---|---|
AdapterHealth |
AdapterHealth
|
The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.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]]
Mock inserting a component into the active assembly.
Records the component in self._components so repeated inserts
accumulate and list_components reflects them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to the part or sub-assembly to insert. |
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]]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
is_connected ¶
Check if mock connection is active.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if connected, otherwise False. |
list_components
async
¶
Mock listing the top-level components of the active assembly.
Returns:
| Type | Description |
|---|---|
AdapterResult[list[str]]
|
AdapterResult[list[str]]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
list_configurations
async
¶
Mock configuration listing for the active model.
Returns:
| Type | Description |
|---|---|
AdapterResult[list[str]]
|
AdapterResult[list[str]]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
list_features
async
¶
list_features(include_suppressed: bool = False, max_assembly_depth: int = 2) -> AdapterResult[list[dict[str, Any]]]
Mock feature tree listing for the active model.
For an Assembly model, flattens in every configured component's
features (see _assembly_components) alongside the document's own
features, tagged with component/component_path the same way
the real adapter does. Falls back to a small canned two-component
fixture (plus one nested sub-assembly) when no components have been
configured, mirroring the existing "seed realistic feature names"
behavior for an empty Part.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_suppressed
|
bool
|
The include suppressed value. Defaults to False. |
False
|
max_assembly_depth
|
int
|
Sub-assembly recursion budget. Ignored for non-Assembly models. Defaults to 2. |
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/mock_adapter.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | |
open_model
async
¶
Mock opening a SolidWorks model.
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. |
Raises:
| Type | Description |
|---|---|
SolidWorksOperationError
|
Simulated adapter failure. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
pack_and_go_assembly
async
¶
Mock Pack-and-Go: simulate copying an assembly to a target directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_path
|
str
|
Path to the source .sldasm file. |
required |
target_dir
|
str
|
Directory to copy files into. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict]
|
AdapterResult[dict]: Simulated pack-and-go result. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
save_file
async
¶
Legacy compatibility save operation for tests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str | None
|
Path to the target file. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
select_feature
async
¶
Mock feature selection/highlight — succeeds without COM side-effects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
feature_name
|
str
|
The feature name value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[dict[str, Any]]
|
AdapterResult[dict[str, Any]]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
set_dimension
async
¶
Mock setting a dimension value.
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/mock_adapter.py
sketch_circular_pattern
async
¶
Mock creating a circular sketch pattern around the sketch origin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entities
|
list[str]
|
Seed entity IDs. |
required |
angle
|
float
|
Total swept angle in degrees. |
required |
count
|
int
|
Total number of instances (including the seed). |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
sketch_linear_pattern
async
¶
sketch_linear_pattern(entities: list[str], direction_x: float, direction_y: float, spacing: float, count: int) -> AdapterResult[str]
Mock creating a linear sketch pattern.
Mirrors the real adapter's validation rules — empty entities, count < 2, non-positive spacing, and a zero direction vector each produce a clear error without "creating" a pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entities
|
list[str]
|
Seed entity IDs. |
required |
direction_x
|
float
|
Pattern direction X component. |
required |
direction_y
|
float
|
Pattern direction Y component. |
required |
spacing
|
float
|
Distance between instances in millimetres. |
required |
count
|
int
|
Total number of instances (including the seed). |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
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 | |
sketch_mirror
async
¶
Mock mirroring sketch entities about a centerline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entities
|
list[str]
|
IDs of segments to mirror. |
required |
mirror_line
|
str
|
ID of the centerline to mirror across. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
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 | |
sketch_offset
async
¶
sketch_offset(entities: list[str], offset_distance: float, reverse_direction: bool) -> AdapterResult[str]
Mock offsetting sketch entities by a fixed distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entities
|
list[str]
|
IDs of segments to offset. |
required |
offset_distance
|
float
|
Distance in millimetres. Must be > 0. |
required |
reverse_direction
|
bool
|
Flip the offset direction. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[str]
|
AdapterResult[str]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/mock_adapter.py
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:¶
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_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_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_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) -> 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
|
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_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
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 a new assembly document.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The name value. 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_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 a new drawing document.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The name value. 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_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 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
|
Returns:
| Type | Description |
|---|---|
AdapterResult[SolidWorksModel]
|
AdapterResult[SolidWorksModel]: The result produced by the operation. |
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_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
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_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_dimension
abstractmethod
async
¶
Get the value of a dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[float]
|
AdapterResult[float]: The result produced by the operation. |
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_metrics ¶
Get adapter metrics.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: A dictionary containing the resulting values. |
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. |
health_check
abstractmethod
async
¶
Get adapter health status.
Returns:
| Name | Type | Description |
|---|---|---|
AdapterHealth |
AdapterHealth
|
The result produced by the operation. |
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
is_connected
abstractmethod
¶
Check if connected to SolidWorks.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if connected, otherwise False. |
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_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
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
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
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
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
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
SolidWorksMCPConfig ¶
Bases: BaseModel
Main configuration for SolidWorks MCP Server.
Attributes:
| Name | Type | Description |
|---|---|---|
adapter_type |
AdapterType
|
The adapter type value. |
allowed_hosts |
list[str]
|
The allowed hosts value. |
allowed_origins |
list[str]
|
The allowed origins value. |
api_key |
SecretStr | None
|
The api key value. |
api_key_required |
bool
|
The api key required value. |
api_keys |
list[str]
|
The api keys value. |
cache_dir |
Path | None
|
The cache dir value. |
circuit_breaker_enabled |
bool
|
The circuit breaker enabled value. |
circuit_breaker_threshold |
int
|
The circuit breaker threshold value. |
circuit_breaker_timeout |
int
|
The circuit breaker timeout value. |
complexity_parameter_threshold |
int
|
The complexity parameter threshold value. |
complexity_score_threshold |
float
|
The complexity score threshold value. |
connection_pool_size |
int
|
The connection pool size value. |
connection_pooling |
bool
|
The connection pooling value. |
cors_origins |
list[str]
|
The cors origins value. |
data_dir |
Path
|
The data dir value. |
database_url |
str
|
The database url value. |
debug |
bool
|
The debug value. |
deployment_mode |
DeploymentMode
|
The deployment mode value. |
enable_analysis_tools |
bool
|
The enable analysis tools value. |
enable_audit_logging |
bool
|
The enable audit logging value. |
enable_circuit_breaker |
bool
|
The enable circuit breaker value. |
enable_connection_pooling |
bool
|
The enable connection pooling value. |
enable_cors |
bool
|
The enable cors value. |
enable_design_tables |
bool
|
The enable design tables value. |
enable_intelligent_routing |
bool
|
The enable intelligent routing value. |
enable_macro_recording |
bool
|
The enable macro recording value. |
enable_pdm |
bool
|
The enable pdm value. |
enable_rate_limiting |
bool
|
The enable rate limiting value. |
enable_response_cache |
bool
|
The enable response cache value. |
enable_sql_integration |
bool
|
The enable sql integration value. |
enable_windows_validation |
bool
|
The enable windows validation value. |
host |
str
|
The host value. |
log_file |
Path | None
|
The log file value. |
log_level |
str
|
The log level value. |
max_connections |
int
|
The max connections value. |
max_retries |
int
|
The max retries value. |
mock_solidworks |
bool
|
The mock solidworks value. |
model_config |
Any
|
The model config value. |
pdm_server |
str | None
|
The pdm server value. |
pdm_vault |
str | None
|
The pdm vault value. |
port |
int
|
The port value. |
rate_limit_enabled |
bool
|
The rate limit enabled value. |
rate_limit_per_minute |
int
|
The rate limit per minute value. |
response_cache_max_entries |
int
|
The response cache max entries value. |
response_cache_ttl_seconds |
int
|
The response cache ttl seconds value. |
security_level |
SecurityLevel
|
The security level value. |
solidworks_path |
str | None
|
The solidworks path value. |
solidworks_year |
int | None
|
The solidworks year value. |
sql_connection |
str | None
|
The sql connection value. |
state_file |
str | None
|
The state file value. |
testing |
bool
|
The testing value. |
timeout_seconds |
float
|
The timeout seconds value. |
worker_processes |
int
|
The worker processes value. |
Attributes¶
can_use_solidworks
property
¶
Check if SolidWorks integration is possible.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if use solidworks, otherwise False. |
is_windows
property
¶
Check if running on Windows.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if windows, otherwise False. |
Methods:¶
from_env
classmethod
¶
Build configuration from environment variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env_file
|
str | None
|
The env file value. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
SolidWorksMCPConfig |
SolidWorksMCPConfig
|
The result produced by the operation. |
Source code in src/solidworks_mcp/config.py
get_database_config ¶
Get database configuration.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: A dictionary containing the resulting values. |
get_security_config ¶
Get security configuration.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: A dictionary containing the resulting values. |
Source code in src/solidworks_mcp/config.py
model_post_init ¶
Post-initialization setup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
__context
|
Any
|
The context value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
None. |
Source code in src/solidworks_mcp/config.py
set_cache_dir
classmethod
¶
Set default cache directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
Path | None
|
The v value. |
required |
info
|
ValidationInfo
|
The info value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
The result produced by the operation. |
Source code in src/solidworks_mcp/config.py
set_log_file
classmethod
¶
Set default log file path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
Path | None
|
The v value. |
required |
info
|
ValidationInfo
|
The info value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
The result produced by the operation. |
Source code in src/solidworks_mcp/config.py
sync_legacy_alias_fields ¶
Sync test/developer alias fields into canonical runtime fields.
Several fixtures and scripts still populate compatibility fields such as
rate_limit_enabled and connection_pooling. Runtime code reads the canonical
fields, so normalize them here after validation.
Returns:
| Name | Type | Description |
|---|---|---|
SolidWorksMCPConfig |
SolidWorksMCPConfig
|
The result produced by the operation. |
Source code in src/solidworks_mcp/config.py
validate_adapter_type
classmethod
¶
Validate adapter type based on platform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
AdapterType
|
The v value. |
required |
info
|
ValidationInfo
|
The info value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AdapterType |
AdapterType
|
The result produced by the operation. |
Source code in src/solidworks_mcp/config.py
validate_complexity_parameter_threshold
classmethod
¶
Validate the complexity parameter threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
int
|
The v value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The computed numeric result. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Complexity_parameter_threshold must be >= 1. |
Source code in src/solidworks_mcp/config.py
validate_complexity_score_threshold
classmethod
¶
Validate the complexity score threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
float
|
The v value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The computed numeric result. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Complexity_score_threshold must be in (0, 1]. |
Source code in src/solidworks_mcp/config.py
validate_port
classmethod
¶
Validate the port.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
int
|
The v value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The computed numeric result. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Port must be between 1 and 65535. |
Source code in src/solidworks_mcp/config.py
validate_response_cache_max_entries
classmethod
¶
Validate response cache size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
int
|
The v value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The computed numeric result. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Response_cache_max_entries must be >= 1. |
Source code in src/solidworks_mcp/config.py
validate_response_cache_ttl_seconds
classmethod
¶
Validate default response cache TTL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
int
|
The v value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The computed numeric result. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Response_cache_ttl_seconds must be >= 1. |
Source code in src/solidworks_mcp/config.py
validate_timeout
classmethod
¶
Validate the timeout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
float
|
The v value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The computed numeric result. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Timeout_seconds must be > 0. |
Source code in src/solidworks_mcp/config.py
VbaGeneratorAdapter ¶
Adapter that executes complex operations through VBA-oriented flow.
This adapter currently uses the wrapped COM adapter for final execution, but annotates responses as VBA-routed and can be extended to execute generated macros directly in future iterations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backing_adapter
|
Any
|
The backing adapter value. |
required |
macro_executor
|
VbaMacroExecutor | None
|
The macro executor value. Defaults to None. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
_backing_adapter |
Any
|
The backing adapter value. |
_macro_executor |
Any
|
The macro executor value. |
config |
Any
|
The config value. |
Initialize the vba generator adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backing_adapter
|
Any
|
The backing adapter value. |
required |
macro_executor
|
VbaMacroExecutor | None
|
The macro executor value. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
None. |
Source code in src/solidworks_mcp/adapters/vba_adapter.py
Methods:¶
__getattr__ ¶
Delegate unknown members to backing adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
str
|
The item value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/vba_adapter.py
connect
async
¶
Connect to SolidWorks using wrapped adapter.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
None. |
create_extrusion
async
¶
Create the extrusion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
ExtrusionParameters
|
The params value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[Any]
|
AdapterResult[Any]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/vba_adapter.py
create_loft
async
¶
Create the loft.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
LoftParameters
|
The params value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[Any]
|
AdapterResult[Any]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/vba_adapter.py
create_revolve
async
¶
Create the revolve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
RevolveParameters
|
The params value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[Any]
|
AdapterResult[Any]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/vba_adapter.py
create_sweep
async
¶
Create the sweep.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
SweepParameters
|
The params value. |
required |
Returns:
| Type | Description |
|---|---|
AdapterResult[Any]
|
AdapterResult[Any]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/vba_adapter.py
disconnect
async
¶
execute_macro
async
¶
execute_macro(macro_code: str, macro_name: str = 'GeneratedMacro', subroutine: str = 'Main') -> AdapterResult[Any]
Provide execute macro support for the vba generator adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
macro_code
|
str
|
The macro code value. |
required |
macro_name
|
str
|
The macro name value. Defaults to "GeneratedMacro". |
'GeneratedMacro'
|
subroutine
|
str
|
The subroutine value. Defaults to "Main". |
'Main'
|
Returns:
| Type | Description |
|---|---|
AdapterResult[Any]
|
AdapterResult[Any]: The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/vba_adapter.py
get_macro_execution_history ¶
Retrieve VBA macro execution history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
macro_name
|
str | None
|
The macro name value. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[ str, Any, |
dict[str, Any]
|
]: A dictionary containing the resulting values. |
Source code in src/solidworks_mcp/adapters/vba_adapter.py
health_check
async
¶
Return wrapped adapter health with VBA route marker.
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/vba_adapter.py
is_connected ¶
Return wrapped adapter connection state.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if connected, otherwise False. |
Functions:¶
_register_default_adapters ¶
Register default adapter implementations.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
None. |
Source code in src/solidworks_mcp/adapters/factory.py
create_adapter
async
¶
Async factory function for creating SolidWorks adapters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
SolidWorksMCPConfig
|
Configuration values for the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SolidWorksAdapter |
SolidWorksAdapter
|
The result produced by the operation. |