Skip to content

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

Access module-attribute

Access = Literal['read', 'write', 'read_write']

ApiMember module-attribute

ApiMember = Annotated[ApiMethod | ApiProperty, Field(discriminator='kind')]

INDEX_FORMAT module-attribute

INDEX_FORMAT = '2.0'

IndexStatus module-attribute

IndexStatus = Literal['ready', 'rebuilt', 'unavailable']

MemberType module-attribute

MemberType = Literal['method', 'property']

_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

_LookupResultT = TypeVar('_LookupResultT', MemberLookup, InterfaceLookup, RelatedLookup)

_MEMBER module-attribute

_MEMBER: TypeAdapter[ApiMethod | ApiProperty] = TypeAdapter(ApiMember)

_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 method.

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 property.

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

method or property.

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

method or property.

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 VBA Library.

member str

The member or library name.

member_type str

method, property or reference.

score int

Relevance; higher is better.

status str | None

A VBA library's status.

SolidWorksAdapter

SolidWorksAdapter(config: object | None = None)

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
def __init__(self, config: object | None = None):
    """Initialize adapter with configuration.

    Args:
        config (object | None): Configuration values for the operation. Defaults to None.
    """
    if config is None:
        normalized_config: dict[str, Any] = {}
    elif isinstance(config, Mapping):
        normalized_config = dict(config)
    elif hasattr(config, "model_dump"):
        normalized_config = dict(config.model_dump())
    else:
        normalized_config = {}

    # Preserve original config object for compatibility with tests and
    # call sites that compare object identity/equality.
    self.config = config
    # Keep a normalized mapping for adapter internals.
    self.config_dict = normalized_config
    self._metrics = {
        "operations_count": 0,
        "errors_count": 0,
        "average_response_time": 0.0,
    }
    # SolidWorks-as-Code session logging. Set soc_session_id to enable
    # automatic ToolCallRecord writes for every adapter operation.
    self.soc_session_id: str | None = None
    self.soc_db_path: Path | None = None
Methods:
activate_document async
activate_document(title_or_path: str) -> AdapterResult[dict[str, Any]]

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
async def activate_document(
    self, title_or_path: str
) -> AdapterResult[dict[str, Any]]:
    """Make an already-open document the active one.

    Args:
        title_or_path (str): Title, full path, or file name of an open
            document.

    Returns:
        AdapterResult[dict[str, Any]]: What was activated, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="activate_document is not implemented by this adapter",
    )
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
async def add_arc(
    self,
    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.

    Args:
        center_x (float): The center x value.
        center_y (float): The center y value.
        start_x (float): The start x value.
        start_y (float): The start y value.
        end_x (float): The end x value.
        end_y (float): The end y value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_arc is not implemented by this adapter",
    )
add_centerline async
add_centerline(x1: float, y1: float, x2: float, y2: float) -> AdapterResult[str]

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
async def add_centerline(
    self, x1: float, y1: float, x2: float, y2: float
) -> AdapterResult[str]:
    """Add a centerline to the current sketch.

    Args:
        x1 (float): The x1 value.
        y1 (float): The y1 value.
        x2 (float): The x2 value.
        y2 (float): The y2 value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_centerline is not implemented by this adapter",
    )
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 distance along the other face.

False

Returns:

Name Type Description
AdapterResult AdapterResult[Any]

Feature result or error.

Source code in src/solidworks_mcp/adapters/base.py
async def add_chamfer(
    self,
    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``.

    Args:
        distance (float): Chamfer distance in millimeters, along one face.
        edge_names (list[str]): List of edge names to chamfer.
        angle (float): Chamfer angle in degrees. Defaults to 45.
        flip (bool): Measure ``distance`` along the other face.

    Returns:
        AdapterResult: Feature result or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_chamfer is not implemented by this adapter",
    )
add_circle abstractmethod async
add_circle(center_x: float, center_y: float, radius: float) -> AdapterResult[str]

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
@abstractmethod
async def add_circle(
    self, center_x: float, center_y: float, radius: float
) -> AdapterResult[str]:
    """Add a circle to the current sketch.

    Args:
        center_x (float): The center x value.
        center_y (float): The center y value.
        radius (float): The radius value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    pass
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
async def add_datum_tag(
    self,
    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:
        AdapterResult[dict[str, Any]]: Error unless the adapter implements it.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_datum_tag is not implemented by this adapter",
    )
add_drawing_view async
add_drawing_view(payload: Any = None) -> AdapterResult[dict[str, Any]]

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
async def add_drawing_view(
    self, payload: Any = None
) -> AdapterResult[dict[str, Any]]:
    """Add a view of a model to the active drawing sheet.

    Args:
        payload (Any): Tool payload carrying the model path, orientation,
            position in millimetres and optional view scale.

    Returns:
        AdapterResult[dict[str, Any]]: The new view's details, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_drawing_view is not implemented by this adapter",
    )
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
async def add_ellipse(
    self,
    center_x: float,
    center_y: float,
    major_axis: float,
    minor_axis: float,
) -> AdapterResult[str]:
    """Add an ellipse to the current sketch.

    Args:
        center_x (float): The center x value.
        center_y (float): The center y value.
        major_axis (float): The major axis value.
        minor_axis (float): The minor axis value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_ellipse is not implemented by this adapter",
    )
add_fillet async
add_fillet(radius: float, edge_names: list[str]) -> AdapterResult[Any]

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
async def add_fillet(
    self, radius: float, edge_names: list[str]
) -> AdapterResult[Any]:
    """Add a fillet feature to selected edges.

    Rounds the selected edges of the current solid body with the given radius.

    Args:
        radius (float): Fillet radius in millimeters.
        edge_names (list[str]): List of edge names to fillet.

    Returns:
        AdapterResult: Feature result or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_fillet is not implemented by this adapter",
    )
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
async def add_gtol(
    self,
    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:
        AdapterResult[dict[str, Any]]: Error unless the adapter implements it.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_gtol is not implemented by this adapter",
    )
add_line abstractmethod async
add_line(x1: float, y1: float, x2: float, y2: float) -> AdapterResult[str]

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
@abstractmethod
async def add_line(
    self, x1: float, y1: float, x2: float, y2: float
) -> AdapterResult[str]:
    """Add a line to the current sketch.

    Args:
        x1 (float): The x1 value.
        y1 (float): The y1 value.
        x2 (float): The x2 value.
        y2 (float): The y2 value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    pass
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. Defaults to "coincident".

'coincident'
alignment str

aligned, anti_aligned or closest. 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
face_a list[float] | None

A point on a face of the first component, in its part coordinates (mm), used instead of entity_a.

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
async def add_mate(
    self,
    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.

    Args:
        component_a (str): First component instance name.
        component_b (str): Second component instance name.
        entity_a (str): Named feature on the first component. Defaults to
            "Front Plane".
        entity_b (str): Named feature on the second component. Defaults to
            "Front Plane".
        mate_type (str): Mate type, e.g. ``coincident``. Defaults to
            "coincident".
        alignment (str): ``aligned``, ``anti_aligned`` or ``closest``.
            Defaults to "aligned".
        distance (float): Distance in millimetres, for a distance mate.
            Defaults to 0.0.
        angle (float): Angle in degrees, for an angle mate. Defaults to 0.0.
        face_a (list[float] | None): A point on a face of the first
            component, in its part coordinates (mm), used instead of
            ``entity_a``.
        face_b (list[float] | None): The same for the second component.

    Returns:
        AdapterResult[dict[str, Any]]: Mate details, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_mate is not implemented by this adapter",
    )
add_note async
add_note(payload: Any = None) -> AdapterResult[dict[str, Any]]

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
async def add_note(self, payload: Any = None) -> AdapterResult[dict[str, Any]]:
    """Place a text note on the active drawing sheet.

    Args:
        payload (Any): Tool payload carrying the note text, its position in
            millimetres and an optional font size in points.

    Returns:
        AdapterResult[dict[str, Any]]: The note's details, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_note is not implemented by this adapter",
    )
add_polygon async
add_polygon(center_x: float, center_y: float, radius: float, sides: int) -> AdapterResult[str]

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
async def add_polygon(
    self, center_x: float, center_y: float, radius: float, sides: int
) -> AdapterResult[str]:
    """Add a regular polygon to the current sketch.

    Args:
        center_x (float): The center x value.
        center_y (float): The center y value.
        radius (float): The radius value.
        sides (int): The sides value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_polygon is not implemented by this adapter",
    )
add_rectangle abstractmethod async
add_rectangle(x1: float, y1: float, x2: float, y2: float) -> AdapterResult[str]

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
@abstractmethod
async def add_rectangle(
    self, x1: float, y1: float, x2: float, y2: float
) -> AdapterResult[str]:
    """Add a rectangle to the current sketch.

    Args:
        x1 (float): The x1 value.
        y1 (float): The y1 value.
        x2 (float): The x2 value.
        y2 (float): The y2 value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    pass
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
async def add_sketch_circle(
    self,
    center_x: float,
    center_y: float,
    radius: float,
    construction: bool = False,
) -> AdapterResult[str]:
    """Alias for add_circle used by some tool flows.

    Args:
        center_x (float): The center x value.
        center_y (float): The center y value.
        radius (float): The radius value.
        construction (bool): The construction value. Defaults to False.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return await self.add_circle(center_x, center_y, radius)
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 symmetric relation (the centerline of symmetry). All other relation types reject a non-null entity3.

None

Returns:

Type Description
AdapterResult[str]

AdapterResult[str]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
async def add_sketch_constraint(
    self,
    entity1: str,
    entity2: str | None,
    relation_type: str,
    entity3: str | None = None,
) -> AdapterResult[str]:
    """Apply a geometric constraint between sketch entities.

    Args:
        entity1 (str): The entity1 value.
        entity2 (str | None): The entity2 value.
        relation_type (str): The relation type value.
        entity3 (str | None): Third entity ID — only used by the
            ``symmetric`` relation (the centerline of symmetry). All
            other relation types reject a non-null ``entity3``.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_sketch_constraint is not implemented by this adapter",
    )
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
async def add_sketch_dimension(
    self,
    entity1: str,
    entity2: str | None,
    dimension_type: str,
    value: float,
) -> AdapterResult[str]:
    """Add a sketch dimension.

    Args:
        entity1 (str): The entity1 value.
        entity2 (str | None): The entity2 value.
        dimension_type (str): The dimension type value.
        value (float): The value value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_sketch_dimension is not implemented by this adapter",
    )
add_spline async
add_spline(points: list[dict[str, float]]) -> AdapterResult[str]

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
async def add_spline(self, points: list[dict[str, float]]) -> AdapterResult[str]:
    """Add a spline through the provided points.

    Args:
        points (list[dict[str, float]]): The points value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="add_spline is not implemented by this adapter",
    )
arrange_dimensions async
arrange_dimensions(view_name: str | None = None) -> AdapterResult[dict[str, Any]]

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
async def arrange_dimensions(
    self,
    view_name: str | None = None,
) -> AdapterResult[dict[str, Any]]:
    """Move drawing dimensions so none overlaps, then verify.

    Returns:
        AdapterResult[dict[str, Any]]: Error unless the adapter implements it.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="arrange_dimensions is not implemented by this adapter",
    )
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
async def auto_center_marks(
    self,
    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.

    Args:
        view_name (str): Name of a view on the active drawing.
        mark_holes (bool): Mark holes / bores.
        mark_fillets (bool): Mark fillets.
        mark_slots (bool): Mark slots.

    Returns:
        AdapterResult[dict[str, Any]]: The view and before/after centre-mark
        counts, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="auto_center_marks is not implemented by this adapter",
    )
check_interference async
check_interference(params: Any = None) -> AdapterResult[dict[str, Any]]

Check the active assembly for interfering components.

Parameters:

Name Type Description Default
params Any

Optional settings; coincident, components.

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
async def check_interference(
    self, params: Any = None
) -> AdapterResult[dict[str, Any]]:
    """Check the active assembly for interfering components.

    Args:
        params (Any): Optional settings; ``coincident``, ``components``.

    Returns:
        AdapterResult[dict[str, Any]]: Interference details, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="check_interference is not implemented by this adapter",
    )
check_sketch_fully_defined async
check_sketch_fully_defined(sketch_name: str | None = None) -> AdapterResult[dict[str, Any]]

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
async def check_sketch_fully_defined(
    self, sketch_name: str | None = None
) -> AdapterResult[dict[str, Any]]:
    """Check whether a sketch is fully defined.

    Args:
        sketch_name (str | None): Optional sketch name to inspect. Defaults to None.

    Returns:
        AdapterResult[dict[str, Any]]: Definition status payload.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="check_sketch_fully_defined is not implemented by this adapter",
    )
close_model abstractmethod async
close_model(save: bool = False) -> AdapterResult[None]

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
@abstractmethod
async def close_model(self, save: bool = False) -> AdapterResult[None]:
    """Close the current model.

    Args:
        save (bool): The save value. Defaults to False.

    Returns:
        AdapterResult[None]: The result produced by the operation.
    """
    pass
connect abstractmethod async
connect() -> None

Connect to SolidWorks application.

Returns:

Name Type Description
None None

None.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def connect(self) -> None:
    """Connect to SolidWorks application.

    Returns:
        None: None.
    """
    pass
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
@abstractmethod
async def create_assembly(
    self, name: str | None = None, template: str | None = None
) -> AdapterResult[SolidWorksModel]:
    """Create a new assembly document.

    Args:
        name (str | None): The name value. Defaults to None.
        template (str | None): Template file path. Defaults to None.

    Returns:
        AdapterResult[SolidWorksModel]: The result produced by the operation.
    """
    pass
create_axis async
create_axis(reference: str) -> AdapterResult[dict[str, Any]]

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
async def create_axis(self, reference: str) -> AdapterResult[dict[str, Any]]:
    """Create a reference axis along a principal direction.

    Args:
        reference (str): "x", "y" or "z" (case-insensitive, leading +/- stripped).

    Returns:
        AdapterResult[dict[str, Any]]: The plane pair used and feature counts, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="create_axis is not implemented by this adapter",
    )
create_cut async
create_cut(sketch_name: str, depth: float) -> AdapterResult[str]

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
async def create_cut(self, sketch_name: str, depth: float) -> AdapterResult[str]:
    """Create a cut feature from an existing sketch.

    Args:
        sketch_name (str): The sketch name value.
        depth (float): The depth value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="create_cut is not implemented by this adapter",
    )
create_cut_extrude async
create_cut_extrude(params: ExtrusionParameters) -> AdapterResult[Any]

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
async def create_cut_extrude(
    self, params: ExtrusionParameters
) -> AdapterResult[Any]:
    """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.

    Args:
        params (ExtrusionParameters): Depth and direction parameters.

    Returns:
        AdapterResult: Feature result or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="create_cut_extrude is not implemented by this adapter",
    )
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
@abstractmethod
async def create_drawing(
    self, name: str | None = None, template: str | None = None
) -> AdapterResult[SolidWorksModel]:
    """Create a new drawing document.

    Args:
        name (str | None): The name value. Defaults to None.
        template (str | None): Template file path. Defaults to None.

    Returns:
        AdapterResult[SolidWorksModel]: The result produced by the operation.
    """
    pass
create_drawing_view async
create_drawing_view(payload: Any = None) -> AdapterResult[dict[str, Any]]

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
async def create_drawing_view(
    self, payload: Any = None
) -> AdapterResult[dict[str, Any]]:
    """Place a view of a model on the active drawing sheet.

    Args:
        payload (Any): Tool payload carrying the model path, orientation,
            position in millimetres and optional view scale.

    Returns:
        AdapterResult[dict[str, Any]]: The new view's details, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="create_drawing_view is not implemented by this adapter",
    )
create_extrusion abstractmethod async
create_extrusion(params: ExtrusionParameters) -> AdapterResult[SolidWorksFeature]

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
@abstractmethod
async def create_extrusion(
    self, params: ExtrusionParameters
) -> AdapterResult[SolidWorksFeature]:
    """Create an extrusion feature.

    Args:
        params (ExtrusionParameters): The params value.

    Returns:
        AdapterResult[SolidWorksFeature]: The result produced by the operation.
    """
    pass
create_loft abstractmethod async
create_loft(params: LoftParameters) -> AdapterResult[SolidWorksFeature]

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
@abstractmethod
async def create_loft(
    self, params: LoftParameters
) -> AdapterResult[SolidWorksFeature]:
    """Create a loft feature.

    Args:
        params (LoftParameters): The params value.

    Returns:
        AdapterResult[SolidWorksFeature]: The result produced by the operation.
    """
    pass
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
@abstractmethod
async def create_part(
    self,
    name: str | None = None,
    units: str | None = None,
    template: str | None = None,
) -> AdapterResult[SolidWorksModel]:
    """Create a new part document.

    Args:
        name (str | None): The name value. Defaults to None.
        units (str | None): The units value. Defaults to None.
        template (str | None): Template file path. Defaults to None.

    Returns:
        AdapterResult[SolidWorksModel]: The result produced by the operation.
    """
    pass
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 axis. Defaults to 0.0.

0.0
flip bool

Reverse the offset or angle direction. Defaults to False.

False
axis str | None

Named axis to rotate about; needed with angle.

None
face_point list[float] | None

[x, y, z] mm on a flat face to use as the reference instead of reference.

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
async def create_reference_plane(
    self,
    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.

    Args:
        reference (str): Name of the reference plane.
        offset (float): Offset distance in millimetres. Defaults to 0.0.
        angle (float): Angle in degrees about ``axis``. Defaults to 0.0.
        flip (bool): Reverse the offset or angle direction. Defaults to False.
        axis (str | None): Named axis to rotate about; needed with ``angle``.
        face_point (list[float] | None): ``[x, y, z]`` mm on a flat face to
            use as the reference instead of ``reference``.

    Returns:
        AdapterResult[dict[str, Any]]: The new plane's name and parameters, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="create_reference_plane is not implemented by this adapter",
    )
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
async def create_reference_point(
    self,
    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.

    Args:
        mode (str): "along_curve" or "face_center".
        x (float): X of a point on the target edge/face, in millimetres.
        y (float): Y of a point on the target edge/face, in millimetres.
        z (float): Z of a point on the target edge/face, in millimetres.
        distance (float | None): For "along_curve", offset from the edge
            start in millimetres.
        percent (float | None): For "along_curve", position as 0-100 of
            the edge length.

    Returns:
        AdapterResult[dict[str, Any]]: The mode and feature counts, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="create_reference_point is not implemented by this adapter",
    )
create_revolve abstractmethod async
create_revolve(params: RevolveParameters) -> AdapterResult[SolidWorksFeature]

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
@abstractmethod
async def create_revolve(
    self, params: RevolveParameters
) -> AdapterResult[SolidWorksFeature]:
    """Create a revolve feature.

    Args:
        params (RevolveParameters): The params value.

    Returns:
        AdapterResult[SolidWorksFeature]: The result produced by the operation.
    """
    pass
create_sketch abstractmethod async
create_sketch(plane: str) -> AdapterResult[str]

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
@abstractmethod
async def create_sketch(self, plane: str) -> AdapterResult[str]:
    """Create a new sketch on the specified plane.

    Args:
        plane (str): The plane value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    pass
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
async def create_standard_drawing(
    self,
    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:
        AdapterResult[dict[str, Any]]: Error unless the adapter implements it.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="create_standard_drawing is not implemented by this adapter",
    )
create_sweep abstractmethod async
create_sweep(params: SweepParameters) -> AdapterResult[SolidWorksFeature]

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
@abstractmethod
async def create_sweep(
    self, params: SweepParameters
) -> AdapterResult[SolidWorksFeature]:
    """Create a sweep feature.

    Args:
        params (SweepParameters): The params value.

    Returns:
        AdapterResult[SolidWorksFeature]: The result produced by the operation.
    """
    pass
create_technical_drawing async
create_technical_drawing(payload: Any = None) -> AdapterResult[dict[str, Any]]

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
async def create_technical_drawing(
    self, payload: Any = None
) -> AdapterResult[dict[str, Any]]:
    """Lay out the standard views of a model on the active sheet.

    Args:
        payload (Any): Tool payload carrying the model path and the
            projection angle.

    Returns:
        AdapterResult[dict[str, Any]]: The view names created, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="create_technical_drawing is not implemented by this adapter",
    )
delete_feature async
delete_feature(name: str) -> AdapterResult[dict[str, Any]]

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
async def delete_feature(self, name: str) -> AdapterResult[dict[str, Any]]:
    """Delete a named feature or sketch from the active model.

    Args:
        name (str): Feature or sketch name.

    Returns:
        AdapterResult[dict[str, Any]]: What was deleted, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="delete_feature is not implemented by this adapter",
    )
disconnect abstractmethod async
disconnect() -> None

Disconnect from SolidWorks application.

Returns:

Name Type Description
None None

None.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def disconnect(self) -> None:
    """Disconnect from SolidWorks application.

    Returns:
        None: None.
    """
    pass
exit_sketch abstractmethod async
exit_sketch() -> AdapterResult[None]

Exit sketch editing mode.

Returns:

Type Description
AdapterResult[None]

AdapterResult[None]: The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def exit_sketch(self) -> AdapterResult[None]:
    """Exit sketch editing mode.

    Returns:
        AdapterResult[None]: The result produced by the operation.
    """
    pass
export_file abstractmethod async
export_file(file_path: str, format_type: str) -> AdapterResult[None]

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
@abstractmethod
async def export_file(
    self, file_path: str, format_type: str
) -> AdapterResult[None]:
    """Export the current model to a file.

    Args:
        file_path (str): Path to the target file.
        format_type (str): The format type value.

    Returns:
        AdapterResult[None]: The result produced by the operation.
    """
    pass
export_flat_pattern async
export_flat_pattern(file_path: str) -> AdapterResult[dict[str, Any]]

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
async def export_flat_pattern(
    self,
    file_path: str,
) -> AdapterResult[dict[str, Any]]:
    """Export the active sheet-metal part's flat pattern.

    Returns:
        AdapterResult[dict[str, Any]]: Error unless the adapter implements it.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="export_flat_pattern is not implemented by this adapter",
    )
export_image abstractmethod async
export_image(payload: dict) -> AdapterResult[dict]

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
@abstractmethod
async def export_image(self, payload: dict) -> AdapterResult[dict]:
    """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".

    Args:
        payload (dict): The payload value.

    Returns:
        AdapterResult[dict]: The result produced by the operation.
    """
    pass
get_application_info async
get_application_info() -> AdapterResult[dict[str, Any]]

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]]: revision (e.g. "34.4.0"),

AdapterResult[dict[str, Any]]

language (e.g. "english") and templates: for each of

AdapterResult[dict[str, Any]]

part, assembly and drawing, the default template's

AdapterResult[dict[str, Any]]

file_name and whether the file exists.

Source code in src/solidworks_mcp/adapters/base.py
async def get_application_info(self) -> AdapterResult[dict[str, Any]]:
    """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:
        AdapterResult[dict[str, Any]]: ``revision`` (e.g. ``"34.4.0"``),
        ``language`` (e.g. ``"english"``) and ``templates``: for each of
        ``part``, ``assembly`` and ``drawing``, the default template's
        ``file_name`` and whether the file ``exists``.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="get_application_info is not implemented by this adapter",
    )
get_custom_properties async
get_custom_properties(configuration: str | None = None) -> AdapterResult[dict[str, Any]]

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
async def get_custom_properties(
    self,
    configuration: str | None = None,
) -> AdapterResult[dict[str, Any]]:
    """Read the custom properties of the active document.

    Returns:
        AdapterResult[dict[str, Any]]: Error unless the adapter implements it.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="get_custom_properties is not implemented by this adapter",
    )
get_dimension abstractmethod async
get_dimension(name: str) -> AdapterResult[dict[str, Any]]

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]]: value and units (mm, deg or None).

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def get_dimension(self, name: str) -> AdapterResult[dict[str, Any]]:
    """Get the value of a dimension.

    Args:
        name (str): The name value.

    Returns:
        AdapterResult[dict[str, Any]]: ``value`` and ``units`` (mm, deg or None).
    """
    pass
get_mass_properties abstractmethod async
get_mass_properties() -> AdapterResult[MassProperties]

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
@abstractmethod
async def get_mass_properties(self) -> AdapterResult[MassProperties]:
    """Get mass properties of the current model.

    Returns:
        AdapterResult[MassProperties]: The result produced by the operation.
    """
    pass
get_material async
get_material(configuration: str | None = None) -> AdapterResult[dict[str, Any]]

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
async def get_material(
    self,
    configuration: str | None = None,
) -> AdapterResult[dict[str, Any]]:
    """Read the material assigned to the active part.

    Returns:
        AdapterResult[dict[str, Any]]: Error unless the adapter implements it.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="get_material is not implemented by this adapter",
    )
get_metrics
get_metrics() -> dict[str, Any]

Get adapter metrics.

Returns:

Type Description
dict[str, Any]

dict[str, Any]: A dictionary containing the resulting values.

Source code in src/solidworks_mcp/adapters/base.py
def get_metrics(self) -> dict[str, Any]:
    """Get adapter metrics.

    Returns:
        dict[str, Any]: A dictionary containing the resulting values.
    """
    return self._metrics.copy()
get_model_geometry_summary async
get_model_geometry_summary() -> AdapterResult[dict[str, Any]]

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]]: document_type ("part" or

AdapterResult[dict[str, Any]]

"assembly"), volume_mm3, bounding_box_mm (min,

AdapterResult[dict[str, Any]]

max and size as [x, y, z]), bounding_box_method,

AdapterResult[dict[str, Any]]

solid_body_count, and for assemblies component_count and

AdapterResult[dict[str, Any]]

mate_count. Error when there is no active part or assembly.

Source code in src/solidworks_mcp/adapters/base.py
async def get_model_geometry_summary(self) -> AdapterResult[dict[str, Any]]:
    """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:
        AdapterResult[dict[str, Any]]: ``document_type`` (``"part"`` or
        ``"assembly"``), ``volume_mm3``, ``bounding_box_mm`` (``min``,
        ``max`` and ``size`` as ``[x, y, z]``), ``bounding_box_method``,
        ``solid_body_count``, and for assemblies ``component_count`` and
        ``mate_count``. Error when there is no active part or assembly.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="get_model_geometry_summary is not implemented by this adapter",
    )
get_model_info abstractmethod async
get_model_info() -> AdapterResult[dict[str, Any]]

Get metadata for the 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/base.py
@abstractmethod
async def get_model_info(self) -> AdapterResult[dict[str, Any]]:
    """Get metadata for the active model.

    Returns:
        AdapterResult[dict[str, Any]]: The result produced by the operation.
    """
    pass
get_selected_entities async
get_selected_entities() -> AdapterResult[list[dict[str, Any]]]

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
async def get_selected_entities(self) -> AdapterResult[list[dict[str, Any]]]:
    """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:
        AdapterResult[list[dict[str, Any]]]: One descriptor per selected
        entity. See the PyWin32 adapter's implementation for the field
        set (varies by entity type).
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="get_selected_entities is not implemented by this adapter",
    )
health_check abstractmethod async
health_check() -> AdapterHealth

Get adapter health status.

Returns:

Name Type Description
AdapterHealth AdapterHealth

The result produced by the operation.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
async def health_check(self) -> AdapterHealth:
    """Get adapter health status.

    Returns:
        AdapterHealth: The result produced by the operation.
    """
    pass
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
async def insert_bom_table(
    self,
    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:
        AdapterResult[dict[str, Any]]: Error unless the adapter implements it.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="insert_bom_table is not implemented by this adapter",
    )
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 .sldprt or .sldasm.

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
async def insert_component(
    self, 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.

    Args:
        file_path (str): Absolute path to the ``.sldprt`` or ``.sldasm``.
        x (float): X position in millimetres. Defaults to 0.0.
        y (float): Y position in millimetres. Defaults to 0.0.
        z (float): Z position in millimetres. Defaults to 0.0.

    Returns:
        AdapterResult[dict[str, Any]]: Component name and counts, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="insert_component is not implemented by this adapter",
    )
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
async def insert_model_dimensions(
    self,
    view_name: str | None = None,
    include_hole_wizard: bool = True,
) -> AdapterResult[dict[str, Any]]:
    """Bring model dimensions into drawing views.

    Returns:
        AdapterResult[dict[str, Any]]: Error unless the adapter implements it.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="insert_model_dimensions is not implemented by this adapter",
    )
is_connected abstractmethod
is_connected() -> bool

Check if connected to SolidWorks.

Returns:

Name Type Description
bool bool

True if connected, otherwise False.

Source code in src/solidworks_mcp/adapters/base.py
@abstractmethod
def is_connected(self) -> bool:
    """Check if connected to SolidWorks.

    Returns:
        bool: True if connected, otherwise False.
    """
    pass
list_available_materials async
list_available_materials(search: str | None = None) -> AdapterResult[list[dict[str, str]]]

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
async def list_available_materials(
    self,
    search: str | None = None,
) -> AdapterResult[list[dict[str, str]]]:
    """List materials from the configured material libraries.

    Returns:
        AdapterResult[list[dict[str, str]]]: Error unless the adapter implements it.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="list_available_materials is not implemented by this adapter",
    )
list_components async
list_components() -> AdapterResult[list[str]]

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
async def list_components(self) -> AdapterResult[list[str]]:
    """List the top-level components of the active assembly.

    Returns:
        AdapterResult[list[str]]: Component instance names, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="list_components is not implemented by this adapter",
    )
list_configurations abstractmethod async
list_configurations() -> AdapterResult[list[str]]

List configuration names 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/base.py
@abstractmethod
async def list_configurations(self) -> AdapterResult[list[str]]:
    """List configuration names for the active model.

    Returns:
        AdapterResult[list[str]]: The result produced by the operation.
    """
    pass
list_drawing_views async
list_drawing_views() -> AdapterResult[list[str]]

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
async def list_drawing_views(self) -> AdapterResult[list[str]]:
    """List the views on the active drawing.

    Returns:
        AdapterResult[list[str]]: View names, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="list_drawing_views is not implemented by this adapter",
    )
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
@abstractmethod
async def list_features(
    self, 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.

    Args:
        include_suppressed (bool): The include suppressed value. Defaults to False.
            Applied independently to the assembly's own features and to
            each component's features.
        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.

    Returns:
        AdapterResult[list[dict[str, Any]]]: The result produced by the operation.
    """
    pass
list_model_dimensions async
list_model_dimensions(feature_name: str | None = None) -> AdapterResult[list[dict[str, Any]]]

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
async def list_model_dimensions(
    self,
    feature_name: str | None = None,
) -> AdapterResult[list[dict[str, Any]]]:
    """List every dimension in the active part or assembly.

    Returns:
        AdapterResult[list[dict[str, Any]]]: Error unless the adapter implements it.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="list_model_dimensions is not implemented by this adapter",
    )
list_open_documents async
list_open_documents() -> AdapterResult[list[dict[str, Any]]]

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]]]

(title, path, type, is_active), or error.

Source code in src/solidworks_mcp/adapters/base.py
async def list_open_documents(self) -> AdapterResult[list[dict[str, Any]]]:
    """Enumerate every document currently open in SolidWorks.

    Returns:
        AdapterResult[list[dict[str, Any]]]: One entry per open document
        (``title``, ``path``, ``type``, ``is_active``), or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="list_open_documents is not implemented by this adapter",
    )
measure_entities async
measure_entities(entities: list[str]) -> AdapterResult[dict[str, Any]]

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
async def measure_entities(
    self,
    entities: list[str],
) -> AdapterResult[dict[str, Any]]:
    """Measure one or two selected entities.

    Returns:
        AdapterResult[dict[str, Any]]: Error unless the adapter implements it.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="measure_entities is not implemented by this adapter",
    )
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
async def mirror_feature(
    self,
    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.

    Args:
        features (list[str]): Body or feature names to mirror.
        mirror_plane (str): Plane name to mirror about.
        merge (bool): Merge the mirrored result with the original. Defaults to True.
        mirror_bodies (bool): Mirror whole bodies rather than features. Defaults to True.

    Returns:
        AdapterResult[dict[str, Any]]: The mirror feature's name, inputs and volume
        before/after, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="mirror_feature is not implemented by this adapter",
    )
open_model abstractmethod async
open_model(file_path: str) -> AdapterResult[SolidWorksModel]

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
@abstractmethod
async def open_model(self, file_path: str) -> AdapterResult[SolidWorksModel]:
    """Open a SolidWorks model (part, assembly, or drawing).

    Args:
        file_path (str): Path to the target file.

    Returns:
        AdapterResult[SolidWorksModel]: The result produced by the operation.
    """
    pass
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 angle. Defaults to True.

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
async def pattern_circular(
    self,
    features: list[str],
    axis: str,
    count: int,
    angle: float = 360.0,
    equal_spacing: bool = True,
) -> AdapterResult[dict[str, Any]]:
    """Pattern features around an axis.

    Args:
        features (list[str]): Names of the features to pattern.
        axis (str): Name of the axis to rotate about.
        count (int): Total number of instances including the original.
        angle (float): Total angle in degrees to spread them over. Defaults to 360.0.
        equal_spacing (bool): Space instances evenly across ``angle``. Defaults to True.

    Returns:
        AdapterResult[dict[str, Any]]: What was patterned and the volume
        before/after, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="pattern_circular is not implemented by this adapter",
    )
rebuild_model async
rebuild_model(top_level_only: bool = False) -> AdapterResult[dict[str, Any]]

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]]: rebuilt, top_level_only,

AdapterResult[dict[str, Any]]

errors (one entry per failing feature with feature,

AdapterResult[dict[str, Any]]

type, code, code_name, severity, description,

AdapterResult[dict[str, Any]]

parents, hint), error_count and warning_count.

AdapterResult[dict[str, Any]]

ERROR (still carrying data) when any error-severity entry

AdapterResult[dict[str, Any]]

remains.

Source code in src/solidworks_mcp/adapters/base.py
async def rebuild_model(
    self, top_level_only: bool = False
) -> AdapterResult[dict[str, Any]]:
    """Force a rebuild and report per-feature rebuild errors.

    Args:
        top_level_only (bool): Rebuild only the top level of an assembly.
            Defaults to False (full rebuild).

    Returns:
        AdapterResult[dict[str, Any]]: ``rebuilt``, ``top_level_only``,
        ``errors`` (one entry per failing feature with ``feature``,
        ``type``, ``code``, ``code_name``, ``severity``, ``description``,
        ``parents``, ``hint``), ``error_count`` and ``warning_count``.
        ERROR (still carrying ``data``) when any error-severity entry
        remains.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="rebuild_model is not implemented by this adapter",
    )
rename_feature async
rename_feature(old_name: str, new_name: str) -> AdapterResult[dict[str, Any]]

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
async def rename_feature(
    self, old_name: str, new_name: str
) -> AdapterResult[dict[str, Any]]:
    """Rename an existing feature on the feature tree.

    Args:
        old_name (str): Current feature name.
        new_name (str): New feature name.

    Returns:
        AdapterResult[dict[str, Any]]: The old and new names, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="rename_feature is not implemented by this adapter",
    )
reset_circuit_breakers async
reset_circuit_breakers(operation: str | None = None) -> AdapterResult[dict[str, list[str]]]

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 resets every one.

None

Returns:

Type Description
AdapterResult[dict[str, list[str]]]

AdapterResult[dict[str, list[str]]]: reset, the operations that were paused.

Source code in src/solidworks_mcp/adapters/base.py
async def reset_circuit_breakers(
    self, operation: str | None = None
) -> AdapterResult[dict[str, list[str]]]:
    """Re-open operations a circuit breaker paused.

    An adapter without a circuit breaker has nothing paused; the breaker
    and the connection pool override this.

    Args:
        operation: The operation to reset; ``None`` resets every one.

    Returns:
        AdapterResult[dict[str, list[str]]]: ``reset``, the operations that were paused.
    """
    return AdapterResult(status=AdapterResultStatus.SUCCESS, data={"reset": []})
save_body_as_part async
save_body_as_part(body_name: str, file_path: str) -> AdapterResult[dict[str, Any]]

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 .sldprt.

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
async def save_body_as_part(
    self, body_name: str, file_path: str
) -> AdapterResult[dict[str, Any]]:
    """Extract one solid body from the active multibody part to a new file.

    Args:
        body_name (str): Name of a solid body in the active part.
        file_path (str): Absolute path for the new ``.sldprt``.

    Returns:
        AdapterResult[dict[str, Any]]: The body, the written path, and the
        solid-body names found, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="save_body_as_part is not implemented by this adapter",
    )
save_file async
save_file(file_path: str | None = None) -> AdapterResult[Any]

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
async def save_file(self, file_path: str | None = None) -> AdapterResult[Any]:
    """Save the active model to the existing path or the provided path.

    Args:
        file_path (str | None): Path to the target file. Defaults to None.

    Returns:
        AdapterResult[Any]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="save_file is not implemented by this adapter",
    )
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

[x, y, z] in mm on the face.

None
side str | None

+X..-Z or top/bottom/front/back/ right/left; the furthest planar face facing that way.

None
plane str | None

Reference plane name; the body face(s) lying on it.

None
edge_type str

all, linear or circular.

'all'
append bool

Add to the current selection. Defaults to False.

False

Returns:

Type Description
AdapterResult[dict[str, Any]]

AdapterResult[dict[str, Any]]: face (or faces), edges

AdapterResult[dict[str, Any]]

(one descriptor per selected edge) and selection_count.

Source code in src/solidworks_mcp/adapters/base.py
async def select_face_edges(
    self,
    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.

    Args:
        point (list[float] | None): ``[x, y, z]`` in mm on the face.
        side (str | None): ``+X``..``-Z`` or ``top/bottom/front/back/
            right/left``; the furthest planar face facing that way.
        plane (str | None): Reference plane name; the body face(s) lying
            on it.
        edge_type (str): ``all``, ``linear`` or ``circular``.
        append (bool): Add to the current selection. Defaults to False.

    Returns:
        AdapterResult[dict[str, Any]]: ``face`` (or ``faces``), ``edges``
        (one descriptor per selected edge) and ``selection_count``.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="select_face_edges is not implemented by this adapter",
    )
select_feature async
select_feature(feature_name: str, append: bool = False) -> AdapterResult[dict[str, Any]]

Select a named feature, sketch, plane or component.

Parameters:

Name Type Description Default
feature_name str

The feature name, optionally @document qualified.

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 selected (True),

AdapterResult[dict[str, Any]]

feature_name, selected_name, entity_type and

AdapterResult[dict[str, Any]]

selection_count. ERROR when nothing could be selected - never

AdapterResult[dict[str, Any]]

SUCCESS with selected: False.

Source code in src/solidworks_mcp/adapters/base.py
async def select_feature(
    self, feature_name: str, append: bool = False
) -> AdapterResult[dict[str, Any]]:
    """Select a named feature, sketch, plane or component.

    Args:
        feature_name (str): The feature name, optionally ``@document``
            qualified.
        append (bool): Add to the current selection instead of replacing
            it. Defaults to False.

    Returns:
        AdapterResult[dict[str, Any]]: On success ``selected`` (True),
        ``feature_name``, ``selected_name``, ``entity_type`` and
        ``selection_count``. ERROR when nothing could be selected - never
        SUCCESS with ``selected: False``.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="select_feature is not implemented by this adapter",
    )
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 list_components reports it.

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
async def set_component_state(
    self,
    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.

    Args:
        component (str): Instance name, as ``list_components`` reports it.
        fixed (bool | None): True fixes it, False floats it.
        flexible (bool | None): True flexible, False rigid.

    Returns:
        AdapterResult[dict[str, Any]]: The state before and after, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="set_component_state is not implemented by this adapter",
    )
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
async def set_custom_property(
    self,
    name: str,
    value: str,
    configuration: str | None = None,
) -> AdapterResult[dict[str, Any]]:
    """Create or overwrite one custom property.

    Returns:
        AdapterResult[dict[str, Any]]: Error unless the adapter implements it.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="set_custom_property is not implemented by this adapter",
    )
set_dimension abstractmethod async
set_dimension(name: str, value: float) -> AdapterResult[None]

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
@abstractmethod
async def set_dimension(self, name: str, value: float) -> AdapterResult[None]:
    """Set the value of a dimension.

    Args:
        name (str): The name value.
        value (float): The value value.

    Returns:
        AdapterResult[None]: The result produced by the operation.
    """
    pass
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
async def set_material(
    self,
    material_name: str,
    database: str | None = None,
    configuration: str | None = None,
) -> AdapterResult[dict[str, Any]]:
    """Assign a material to the active part.

    Returns:
        AdapterResult[dict[str, Any]]: Error unless the adapter implements it.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="set_material is not implemented by this adapter",
    )
set_sheet_scale async
set_sheet_scale(numerator: float, denominator: float) -> AdapterResult[dict[str, Any]]

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
async def set_sheet_scale(
    self,
    numerator: float,
    denominator: float,
) -> AdapterResult[dict[str, Any]]:
    """Set the active drawing sheet's scale.

    Returns:
        AdapterResult[dict[str, Any]]: Error unless the adapter implements it.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="set_sheet_scale is not implemented by this adapter",
    )
set_units async
set_units(unit_system: str) -> AdapterResult[dict[str, Any]]

Set the active document's linear unit system.

Parameters:

Name Type Description Default
unit_system str

One of mm, cm, m, in, ft.

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
async def set_units(self, unit_system: str) -> AdapterResult[dict[str, Any]]:
    """Set the active document's linear unit system.

    Args:
        unit_system (str): One of ``mm``, ``cm``, ``m``, ``in``, ``ft``.

    Returns:
        AdapterResult[dict[str, Any]]: What was applied, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="set_units is not implemented by this adapter",
    )
sketch_circular_pattern async
sketch_circular_pattern(entities: list[str], angle: float, count: int) -> AdapterResult[str]

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
async def sketch_circular_pattern(
    self,
    entities: list[str],
    angle: float,
    count: int,
) -> AdapterResult[str]:
    """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.

    Args:
        entities (list[str]): The entities value.
        angle (float): The angle value.
        count (int): The count value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="sketch_circular_pattern is not implemented by this adapter",
    )
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
async def sketch_linear_pattern(
    self,
    entities: list[str],
    direction_x: float,
    direction_y: float,
    spacing: float,
    count: int,
) -> AdapterResult[str]:
    """Create a linear pattern of sketch entities.

    Args:
        entities (list[str]): The entities value.
        direction_x (float): The direction x value.
        direction_y (float): The direction y value.
        spacing (float): The spacing value.
        count (int): The count value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="sketch_linear_pattern is not implemented by this adapter",
    )
sketch_mirror async
sketch_mirror(entities: list[str], mirror_line: str) -> AdapterResult[str]

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
async def sketch_mirror(
    self, entities: list[str], mirror_line: str
) -> AdapterResult[str]:
    """Mirror sketch entities about a mirror line.

    Args:
        entities (list[str]): The entities value.
        mirror_line (str): The mirror line value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="sketch_mirror is not implemented by this adapter",
    )
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
async def sketch_offset(
    self,
    entities: list[str],
    offset_distance: float,
    reverse_direction: bool,
) -> AdapterResult[str]:
    """Offset sketch entities.

    Args:
        entities (list[str]): The entities value.
        offset_distance (float): The offset distance value.
        reverse_direction (bool): The reverse direction value.

    Returns:
        AdapterResult[str]: The result produced by the operation.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="sketch_offset is not implemented by this adapter",
    )
suppress_feature async
suppress_feature(name: str, suppress: bool = True) -> AdapterResult[dict[str, Any]]

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
async def suppress_feature(
    self, name: str, suppress: bool = True
) -> AdapterResult[dict[str, Any]]:
    """Suppress or unsuppress a named feature.

    Args:
        name (str): Feature name.
        suppress (bool): True to suppress, False to unsuppress.

    Returns:
        AdapterResult[dict[str, Any]]: The resulting state, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="suppress_feature is not implemented by this adapter",
    )
undo async
undo(count: int = 1) -> AdapterResult[dict[str, Any]]

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
async def undo(self, count: int = 1) -> AdapterResult[dict[str, Any]]:
    """Undo the last operations in the active model.

    Args:
        count (int): Number of steps to undo.

    Returns:
        AdapterResult[dict[str, Any]]: Whether the tree changed, or error.
    """
    return AdapterResult(
        status=AdapterResultStatus.ERROR,
        error="undo is not implemented by this adapter",
    )
update_metrics
update_metrics(operation_time: float, success: bool) -> None

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
def update_metrics(self, operation_time: float, success: bool) -> None:
    """Update adapter metrics.

    Args:
        operation_time (float): The operation time value.
        success (bool): The success value.

    Returns:
        None: None.
    """
    self._metrics["operations_count"] += 1
    if not success:
        self._metrics["errors_count"] += 1

    # Update average response time
    current_avg = self._metrics["average_response_time"]
    count = self._metrics["operations_count"]
    self._metrics["average_response_time"] = (
        current_avg * (count - 1) + operation_time
    ) / count

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 .generated/docs-index.

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 year, so a missing year is an error instead of falling back to the newest.

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
def __init__(
    self,
    output_dir: Path | None = None,
    year: int | None = None,
    strict_year: bool = False,
):
    """Initialize docs discovery.

    Args:
        output_dir (Path | None): Where the index is saved.
        year (int | None): The SolidWorks year to read, if any.
        strict_year (bool): True to fail when that year isn't installed.
    """
    self.output_dir = output_dir or _INDEX_DIRS[0]
    self.output_dir.mkdir(parents=True, exist_ok=True)
    self.year = year
    self.strict_year = strict_year
    self.index: dict[str, Any] = {
        "version": INDEX_FORMAT,
        "type_library": None,
        "solidworks_version": None,
        "com_objects": {},
        "vba_references": {},
        "total_methods": 0,
        "total_properties": 0,
    }
Methods:
create_search_summary
create_search_summary() -> dict[str, Any]

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
def create_search_summary(self) -> dict[str, Any]:
    """Summarize the index for a response.

    Returns:
        dict[str, Any]: Interface, method and property totals, the type
        library version and the VBA libraries found.
    """
    return {
        "total_com_objects": len(self.index["com_objects"]),
        "total_methods": self.index["total_methods"],
        "total_properties": self.index["total_properties"],
        "solidworks_version": self.index["solidworks_version"],
        "available_vba_libs": [
            lib
            for lib, info in self.index["vba_references"].items()
            if info.get("status") == "available"
        ],
    }
discover_all
discover_all(include_vba: bool = True) -> dict[str, Any]

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
def discover_all(self, include_vba: bool = True) -> dict[str, Any]:
    """Run full discovery of COM and, optionally, VBA documentation.

    Args:
        include_vba (bool): Also scan the registry for VBA references.

    Returns:
        dict[str, Any]: The complete index.

    Raises:
        TypeLibraryUnavailable: No matching type library is registered.
    """
    logger.info("Discovering COM objects...")
    self.index["com_objects"] = self.discover_com_objects()

    if include_vba:
        logger.info("Discovering VBA references...")
        self.index["vba_references"] = self.discover_vba_references()

    return self.index
discover_com_objects
discover_com_objects() -> dict[str, Any]

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
def discover_com_objects(self) -> dict[str, Any]:
    """Index every COM interface in the SolidWorks type library.

    Also records which type library was read and the member totals.

    Returns:
        dict[str, Any]: Interface name -> its methods, properties and
        member signatures, as saved.

    Raises:
        TypeLibraryUnavailable: No matching type library is registered.
    """
    lib, info = load_type_library(self.year, self.strict_year)
    interfaces = index_type_library(lib)
    self.index["type_library"] = info.model_dump()
    self.index["solidworks_version"] = info.version
    self.index["total_methods"] = sum(i.method_count for i in interfaces.values())
    self.index["total_properties"] = sum(
        i.property_count for i in interfaces.values()
    )
    logger.info(
        "[docs_discovery] Type library {} ({}): {} interfaces",
        info.version,
        info.path,
        len(interfaces),
    )
    return {name: record.model_dump() for name, record in interfaces.items()}
discover_vba_references
discover_vba_references() -> dict[str, Any]

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
def discover_vba_references(self) -> dict[str, Any]:
    """Discover VBA/TypeLib references via the Windows Registry.

    Returns:
        dict[str, Any]: The SolidWorks and Office/VBA type libraries
        found; empty off Windows.
    """
    refs = _discover_vba_references_via_registry()
    if refs:
        logger.info(
            "[docs_discovery] Registry TypeLib scan found {} entries", len(refs)
        )
    else:
        logger.debug(
            "[docs_discovery] Registry TypeLib scan found no matching entries"
        )
    return refs
save_index
save_index(filename: str = 'solidworks_docs_index.json') -> Path

Save the index as compact JSON.

Parameters:

Name Type Description Default
filename str

The file name inside output_dir.

'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
def save_index(self, filename: str = "solidworks_docs_index.json") -> Path:
    """Save the index as compact JSON.

    Args:
        filename (str): The file name inside ``output_dir``.

    Returns:
        Path: The saved file.

    Raises:
        ToolOperationError: The file could not be written. Lookups would
            otherwise rebuild the index on every call.
    """
    output_path = self.output_dir / filename
    try:
        with open(output_path, "w", encoding="utf-8") as f:
            # Compact: every lookup reads this file, and nobody edits it.
            json.dump(self.index, f, separators=(",", ":"))
    except OSError as exc:
        raise ToolOperationError(
            f"Couldn't save the API index to {output_path}: {exc}"
        ) from exc
    logger.info("Docs index saved to {}", output_path)
    return output_path

ToolOperationError

ToolOperationError(message: str, execution_time: float | None = None, data: Any = None)

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 data.

Source code in src/solidworks_mcp/tools/tool_boundary.py
def __init__(
    self,
    message: str,
    execution_time: float | None = None,
    data: Any = None,
) -> None:
    super().__init__(message)
    self.execution_time = execution_time
    self.data = data

TypeLibraryUnavailable

TypeLibraryUnavailable(message: str, execution_time: float | None = None, data: Any = None)

Bases: ToolOperationError

No SolidWorks type library could be loaded; the message says why.

Source code in src/solidworks_mcp/tools/tool_boundary.py
def __init__(
    self,
    message: str,
    execution_time: float | None = None,
    data: Any = None,
) -> None:
    super().__init__(message)
    self.execution_time = execution_time
    self.data = data

_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 status is unavailable.

index_file Path | None

The file it was read from or saved to.

status IndexStatus

ready (read from disk), rebuilt (built for this call) or unavailable.

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
annotate(result: _LookupResultT) -> _LookupResultT

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
def annotate(self, result: _LookupResultT) -> _LookupResultT:
    """Add why no index could be built to a lookup result, when it couldn't.

    Args:
        result (_LookupResultT): A lookup result.

    Returns:
        _LookupResultT: The same result.
    """
    if self.note:
        result.note = self.note
    return result
payload
payload() -> dict[str, Any]

The fields every lookup response carries about its index.

Returns:

Type Description
dict[str, Any]

dict[str, Any]: year and type_library_version of the

dict[str, Any]

library that answered, index_status and source_index_file.

Source code in src/solidworks_mcp/tools/docs_discovery.py
def payload(self) -> dict[str, Any]:
    """The fields every lookup response carries about its index.

    Returns:
        dict[str, Any]: ``year`` and ``type_library_version`` of the
        library that answered, ``index_status`` and ``source_index_file``.
    """
    library = self.index.get("type_library") or {}
    return {
        "year": library.get("year", self.year),
        "type_library_version": library.get("version"),
        "index_status": self.status,
        "source_index_file": str(self.index_file) if self.index_file else None,
    }

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 year.

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
def _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.

    Args:
        year (int | None): The SolidWorks year to read; None for the newest.
        strict (bool): True when the caller asked for ``year``.
        output_dir (Path | None): Where to save; the default index folder if None.
        include_vba (bool): Also scan for VBA references.

    Returns:
        tuple[SolidWorksDocsDiscovery, Path]: The discovery holding the
        index, and the saved file.

    Raises:
        TypeLibraryUnavailable: No matching type library is registered.
        ToolOperationError: The index could not be saved.
    """
    discovery = SolidWorksDocsDiscovery(
        output_dir=output_dir, year=year, strict_year=strict
    )
    index = discovery.discover_all(include_vba=include_vba)
    filename = f"solidworks_docs_index_{index['type_library']['year']}.json"
    return discovery, discovery.save_index(filename=filename)

_discover_vba_references_via_registry

_discover_vba_references_via_registry() -> dict[str, Any]

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]: "<name> (<guid> v<version>)" -> its description,

dict[str, Any]

GUID, version and status; empty off Windows.

Source code in src/solidworks_mcp/tools/docs_discovery.py
def _discover_vba_references_via_registry() -> dict[str, Any]:
    """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:
        dict[str, Any]: ``"<name> (<guid> v<version>)"`` -> its description,
        GUID, version and status; empty off Windows.
    """
    vba_refs: dict[str, Any] = {}

    # Keywords to look for in type lib names
    interesting_keywords = [
        "solidworks",
        "sldworks",
        "vba",
        "visual basic",
        "stdole",
        "office",
        "microsoft office",
    ]

    if platform.system() != "Windows":
        return vba_refs

    try:
        import winreg

        typelib_key = winreg.OpenKey(
            winreg.HKEY_CLASSES_ROOT, "TypeLib", access=winreg.KEY_READ
        )
        idx = 0
        while True:
            try:
                guid = winreg.EnumKey(typelib_key, idx)
                idx += 1
            except OSError:
                break
            try:
                guid_key = winreg.OpenKey(typelib_key, guid, access=winreg.KEY_READ)
                ver_idx = 0
                while True:
                    try:
                        version = winreg.EnumKey(guid_key, ver_idx)
                        ver_idx += 1
                    except OSError:
                        break
                    try:
                        ver_key = winreg.OpenKey(
                            guid_key, version, access=winreg.KEY_READ
                        )
                        try:
                            name, _ = winreg.QueryValueEx(ver_key, "")
                        except OSError:
                            name = ""
                        winreg.CloseKey(ver_key)
                        if name and any(
                            kw in name.lower() for kw in interesting_keywords
                        ):
                            key = f"{name} ({guid} v{version})"
                            if key not in vba_refs:
                                vba_refs[key] = {
                                    "description": name,
                                    "guid": guid,
                                    "version": version,
                                    "status": "available",
                                }
                    except Exception:
                        continue
                winreg.CloseKey(guid_key)
            except Exception:
                continue
        winreg.CloseKey(typelib_key)
    except Exception as exc:
        logger.debug("[docs_discovery] Registry TypeLib scan failed: {}", exc)

    return vba_refs

_extract_year

_extract_year(value: str | None) -> int | None

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
def _extract_year(value: str | None) -> int | None:
    """Extract a 4-digit year (20xx) from a string such as an install path.

    Args:
        value (str | None): The text to search.

    Returns:
        int | None: The year, or None when there isn't one.
    """
    if not value:
        return None
    match = re.search(r"\b(20\d{2})\b", value)
    return int(match.group(1)) if match else None

_fallback_help_for_query

_fallback_help_for_query(query: str) -> dict[str, Any]

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]: suggested_tools and next_steps.

Source code in src/solidworks_mcp/tools/docs_discovery.py
def _fallback_help_for_query(query: str) -> dict[str, Any]:
    """Suggest MCP tools for a query, alongside or instead of API matches.

    Args:
        query (str): The search words.

    Returns:
        dict[str, Any]: ``suggested_tools`` and ``next_steps``.
    """
    q = query.lower()

    if any(word in q for word in ("revolve", "lathe", "turned")):
        return {
            "suggested_tools": [
                "create_part",
                "create_sketch",
                "add_centerline",
                "add_line",
                "add_arc",
                "exit_sketch",
                "create_revolve",
            ],
            "next_steps": [
                "Create a profile sketch and a centerline in the same sketch.",
                "Exit sketch mode before create_revolve.",
                "If real COM returns parameter mismatch, use generate_vba_revolve as fallback guidance.",
            ],
        }

    if any(word in q for word in ("extrude", "boss", "cut")):
        return {
            "suggested_tools": [
                "create_part",
                "create_sketch",
                "add_rectangle",
                "add_circle",
                "exit_sketch",
                "create_extrusion",
            ],
            "next_steps": [
                "Ensure sketch profile is closed before create_extrusion.",
                "Use direction='cut' for removal operations.",
            ],
        }

    return {
        "suggested_tools": [
            "lookup_api_interface",
            "lookup_api_method",
            "find_related_api_members",
        ],
        "next_steps": [
            "Search again with a narrower term, such as part of a method name.",
            "Use lookup_api_interface on an interface (e.g. IModelDoc2) to see "
            "every member it has.",
        ],
    }

_find_index_file

_find_index_file(year: int) -> Path | None

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 solidworks_docs_index_<year>.json in the

Path | None

index folders, or None.

Source code in src/solidworks_mcp/tools/docs_discovery.py
def _find_index_file(year: int) -> Path | None:
    """Find the saved index for a SolidWorks year.

    Args:
        year (int): The type library's year.

    Returns:
        Path | None: The first ``solidworks_docs_index_<year>.json`` in the
        index folders, or None.
    """
    for directory in _INDEX_DIRS:
        candidate = directory / f"solidworks_docs_index_{year}.json"
        if candidate.is_file():
            return candidate
    return None
_find_related_api_members(index: dict[str, Any], name: str, max_results: int) -> RelatedLookup

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 name was read.

Source code in src/solidworks_mcp/tools/docs_discovery.py
def _find_related_api_members(
    index: dict[str, Any], name: str, max_results: int
) -> RelatedLookup:
    """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.

    Args:
        index (dict[str, Any]): The index.
        name (str): The interface or member name.
        max_results (int): How many related members to keep.

    Returns:
        RelatedLookup: The related members and how ``name`` was read.
    """
    com_objects = index.get("com_objects", {})
    related: list[RelatedMember] = []
    seen: set[tuple[str, str]] = set()

    def _add(obj_name: str, member: str, member_type: MemberType, reason: str) -> None:
        """Record one related member, once, never the name asked about.

        Args:
            obj_name (str): Its interface.
            member (str): Its name.
            member_type (MemberType): ``method`` or ``property``.
            reason (str): Why it is related.
        """
        key = (obj_name, str(member))
        if key in seen or str(member).lower() == name.lower():
            return
        seen.add(key)
        related.append(
            RelatedMember(
                object=obj_name,
                member=str(member),
                member_type=member_type,
                reason=reason,
            )
        )

    resolved = _resolve_interface(index, name)
    if resolved is not None:
        obj_name, obj_data = resolved
        for m in obj_data.get("methods", []):
            _add(obj_name, m, "method", "same interface")
        for p in obj_data.get("properties", []):
            _add(obj_name, p, "property", "same interface")
        return RelatedLookup(
            found=True,
            query=name,
            resolved_as="interface",
            related=related[:max_results],
        )

    lowered = name.lower()
    matched_member = False
    for obj_name, obj_data in com_objects.items():
        members: list[tuple[str, MemberType]] = [
            (str(member), member_type)
            for member_type, key in _MEMBER_LISTS
            for member in obj_data.get(key, [])
        ]
        names_lower = {str(m).lower() for m, _ in members}
        if lowered in names_lower:
            matched_member = True
            for member, member_type in members:
                _add(obj_name, member, member_type, f"sibling on {obj_name}")
        else:
            for member, member_type in members:
                if lowered in str(member).lower():
                    _add(obj_name, member, member_type, "name match")

    return RelatedLookup(
        found=matched_member or bool(related),
        query=name,
        resolved_as="member" if matched_member else "name-match",
        related=related[:max_results],
    )

_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
def _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.

    Args:
        requested_year (int | None): The year the caller asked for, if any.
        explicit_index_file (str | None): An index file the caller named.
        config (Any): Server configuration.

    Returns:
        _IndexForLookup: The index and how it was obtained.

    Raises:
        ToolOperationError: A built index could not be saved.
    """
    year = _resolve_solidworks_year(requested_year, config)
    if explicit_index_file:
        explicit = Path(explicit_index_file)
        index = _load_index_file(explicit)
        if index is not None and index.get("version") == INDEX_FORMAT:
            return _IndexForLookup(index, explicit, "ready", year=year)
    strict = requested_year is not None
    try:
        major, minor = target_version(year, strict)
    except TypeLibraryUnavailable as exc:
        return _IndexForLookup({}, None, "unavailable", str(exc), year)
    library_year = year_of(major)
    index_file = _find_index_file(library_year)
    index = _load_index_file(index_file) if index_file else None
    if (
        index_file is not None
        and index is not None
        and index.get("version") == INDEX_FORMAT
        and (index.get("type_library") or {}).get("version") == f"{major}.{minor}"
    ):
        index, index_file = _maybe_refresh_index(
            index, index_file, library_year, config
        )
        return _IndexForLookup(index, index_file, "ready")
    try:
        discovery, fresh_file = _build_index(library_year, strict=True)
    except TypeLibraryUnavailable as exc:
        return _IndexForLookup({}, None, "unavailable", str(exc), year)
    return _IndexForLookup(discovery.index, fresh_file, "rebuilt")

_index_is_stale

_index_is_stale(index_file: Path | None, max_age_days: int) -> bool

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
def _index_is_stale(index_file: Path | None, max_age_days: int) -> bool:
    """Whether an index file is older than ``max_age_days``.

    Args:
        index_file (Path | None): The file, if any.
        max_age_days (int): The age limit in days.

    Returns:
        bool: True when the file exists and is older than the limit.
    """
    if index_file is None:
        return False
    try:
        age_days = (time.time() - index_file.stat().st_mtime) / 86400.0
    except OSError:
        return False
    return age_days > max_age_days

_load_index_file

_load_index_file(index_file: Path) -> dict[str, Any] | None

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
def _load_index_file(index_file: Path) -> dict[str, Any] | None:
    """Read a saved index.

    Args:
        index_file (Path): The JSON file.

    Returns:
        dict[str, Any] | None: The index, or None when the file is missing
        or isn't a JSON object.
    """
    try:
        with index_file.open("r", encoding="utf-8") as handle:
            data = json.load(handle)
    except (OSError, ValueError):
        return None
    return data if isinstance(data, dict) else None

_lookup_interface

_lookup_interface(index: dict[str, Any], interface: str) -> InterfaceLookup

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
def _lookup_interface(index: dict[str, Any], interface: str) -> InterfaceLookup:
    """List an interface's methods and properties, or say it isn't indexed.

    Args:
        index (dict[str, Any]): The index.
        interface (str): The interface name asked for.

    Returns:
        InterfaceLookup: Its member names and counts, or a no-match.
    """
    resolved = _resolve_interface(index, interface)
    if resolved is None:
        return InterfaceLookup(found=False, interface=interface)
    obj_name, obj_data = resolved
    methods = [str(m) for m in obj_data.get("methods", [])]
    properties = [str(p) for p in obj_data.get("properties", [])]
    return InterfaceLookup(
        found=True,
        interface=obj_name,
        methods=methods,
        properties=properties,
        method_count=len(methods),
        property_count=len(properties),
    )

_lookup_method

_lookup_method(index: dict[str, Any], interface: str, method: str) -> MemberLookup

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
def _lookup_method(index: dict[str, Any], interface: str, method: str) -> MemberLookup:
    """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.

    Args:
        index (dict[str, Any]): The index.
        interface (str): The interface name asked for.
        method (str): The member name asked for.

    Returns:
        MemberLookup: The signature, or a no-match with a note.
    """
    resolved = _resolve_interface(index, interface)
    if resolved is None:
        return MemberLookup(found=False, interface=interface, method=method)
    obj_name, obj_data = resolved
    lowered = method.lower()
    for name, raw in obj_data.get("members", {}).items():
        if name.lower() != lowered:
            continue
        record = _MEMBER.validate_python(raw)
        result = MemberLookup(
            found=True,
            interface=obj_name,
            member=name,
            member_type=record.kind,
            signature_indexed=True,
            description=record.description,
        )
        if isinstance(record, ApiProperty):
            # A property's "return type" is the value type it reads back.
            result.parameters = []
            result.return_type = record.type
            result.access = record.access
        else:
            result.parameters = record.parameters
            result.return_type = record.return_type
        if name != method:
            result.note = (
                f"SolidWorks spells it {name!r}. COM matches names "
                f"regardless of case, so {method!r} also works."
            )
        return result
    return MemberLookup(
        found=False,
        interface=obj_name,
        method=method,
        note=f"{method!r} is not an indexed member of {obj_name}.",
    )

_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
def _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.

    Args:
        index (dict[str, Any]): The saved index.
        index_file (Path): Its file.
        year (int): The type library's year.
        config (Any): Server configuration.

    Returns:
        tuple[dict[str, Any], Path]: The (possibly rebuilt) index and file.
    """
    if not getattr(config, "docs_index_auto_refresh", False):
        return index, index_file
    max_age = int(getattr(config, "docs_index_max_age_days", 21) or 21)
    if not _index_is_stale(index_file, max_age):
        return index, index_file
    logger.info("Docs index older than {} days; rebuilding it", max_age)
    try:
        discovery, fresh_file = _build_index(year, strict=False)
    except TypeLibraryUnavailable as exc:
        logger.warning("Docs index refresh failed, using existing index: {}", exc)
        return index, index_file
    return discovery.index, fresh_file

_rebuild_rag_index

_rebuild_rag_index(index_file: Path) -> bool

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
def _rebuild_rag_index(index_file: Path) -> bool:
    """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.

    Args:
        index_file (Path): The saved docs index.

    Returns:
        bool: True when the RAG index was rebuilt and saved.
    """
    try:
        from solidworks_mcp.agents.vector_rag import build_solidworks_api_docs_index

        rag_idx = build_solidworks_api_docs_index(index_file)
        rag_idx.save()
    except ImportError:
        logger.debug("faiss-cpu not installed; skipping RAG index rebuild")
        return False
    except Exception as exc:
        logger.warning("RAG rebuild failed: {}", exc)
        return False
    logger.info(
        "FAISS 'solidworks-api-docs' namespace rebuilt: {} chunks",
        rag_idx.chunk_count,
    )
    return True

_resolve_interface

_resolve_interface(index: dict[str, Any], name: str) -> tuple[str, dict[str, Any]] | None

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
def _resolve_interface(
    index: dict[str, Any], name: str
) -> tuple[str, dict[str, Any]] | None:
    """Find an interface by name, ignoring case.

    Args:
        index (dict[str, Any]): The index.
        name (str): The interface name asked for.

    Returns:
        tuple[str, dict[str, Any]] | None: Its real name and record, or None.
    """
    com_objects = index.get("com_objects", {})
    if name in com_objects:
        return name, com_objects[name]
    lowered = name.lower()
    for obj_name, obj_data in com_objects.items():
        if obj_name.lower() == lowered:
            return obj_name, obj_data
    return None

_resolve_solidworks_year

_resolve_solidworks_year(requested_year: int | None, config: Any) -> int | None

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 (solidworks_year is set by --year; solidworks_path may name a year).

required

Returns:

Type Description
int | None

int | None: The year, or None.

Source code in src/solidworks_mcp/tools/docs_discovery.py
def _resolve_solidworks_year(requested_year: int | None, config: Any) -> int | None:
    """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".

    Args:
        requested_year (int | None): The year the call asked for.
        config (Any): Server configuration (``solidworks_year`` is set by
            ``--year``; ``solidworks_path`` may name a year).

    Returns:
        int | None: The year, or None.
    """
    if requested_year:
        return requested_year
    config_year = getattr(config, "solidworks_year", None)
    if isinstance(config_year, int):
        return config_year
    return _extract_year(getattr(config, "solidworks_path", None))

_search_index

_search_index(index: dict[str, Any], query: str, max_results: int) -> list[SearchMatch]

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
def _search_index(
    index: dict[str, Any], query: str, max_results: int
) -> list[SearchMatch]:
    """Search the index's interface, member and VBA library names.

    Args:
        index (dict[str, Any]): The index.
        query (str): Words to look for; each word scores separately.
        max_results (int): How many matches to keep.

    Returns:
        list[SearchMatch]: The best matches, highest score first.
    """
    tokens = [t for t in re.split(r"\s+", query.lower().strip()) if t]
    if not tokens:
        return []

    results: list[SearchMatch] = []

    def _score(text: str) -> int:
        """Score a name: 10 per word equal to it, 3 per word inside it.

        Args:
            text (str): The name.

        Returns:
            int: The score.
        """
        lower = text.lower()
        score = 0
        for token in tokens:
            if token == lower:
                score += 10
            elif token in lower:
                score += 3
        return score

    for obj_name, obj_data in index.get("com_objects", {}).items():
        obj_score = _score(obj_name)
        for member_type, key in _MEMBER_LISTS:
            for member in obj_data.get(key, []):
                score = obj_score + _score(str(member))
                if score > 0:
                    results.append(
                        SearchMatch(
                            object=obj_name,
                            member=str(member),
                            member_type=member_type,
                            score=score,
                        )
                    )

    for lib_name, lib_data in index.get("vba_references", {}).items():
        score = _score(f"{lib_name} {lib_data.get('description', '')}")
        if score > 0:
            results.append(
                SearchMatch(
                    object="VBA Library",
                    member=lib_name,
                    member_type="reference",
                    status=lib_data.get("status", "unknown"),
                    score=score,
                )
            )

    results.sort(key=lambda item: item.score, reverse=True)
    return results[:max_results]

index_type_library

index_type_library(lib: TypeLibLike) -> dict[str, ApiInterface]

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
def index_type_library(lib: TypeLibLike) -> dict[str, ApiInterface]:
    """Index every dispatch interface in a type library.

    Args:
        lib (TypeLibLike): An ITypeLib (or a fake with the same methods).

    Returns:
        dict[str, ApiInterface]: Interface name -> its record.
    """
    com_objects = {}
    for position in range(lib.GetTypeInfoCount()):
        if lib.GetTypeInfoType(position) != _TKIND_DISPATCH:
            continue
        name = lib.GetDocumentation(position)[0]
        com_objects[name] = _interface_record(lib.GetTypeInfo(position))
    return com_objects

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 pythoncom module; defaults to the real one.

None
registry Any

The winreg module; defaults to the real one.

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
def 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.

    Args:
        year (int | None): The wanted SolidWorks year; None for the newest.
        strict (bool): True to fail when that year isn't installed.
        com (Any): The ``pythoncom`` module; defaults to the real one.
        registry (Any): The ``winreg`` module; defaults to the real one.

    Returns:
        tuple[Any, TypeLibraryInfo]: The ITypeLib and where it came from.

    Raises:
        TypeLibraryUnavailable: Not on Windows with pywin32, no matching
            type library is registered, or the registered one won't load.
    """
    com = com if com is not None else pythoncom
    if com is None:
        raise TypeLibraryUnavailable(_NEEDS_WINDOWS)
    major, minor = target_version(year, strict, registry)
    try:
        lib = com.LoadRegTypeLib(SOLIDWORKS_TYPELIB_GUID, major, minor)
    except com.com_error as exc:
        # An uninstall can leave the registry key behind its deleted .tlb.
        raise TypeLibraryUnavailable(
            f"SolidWorks {year_of(major)}'s type library is registered but "
            f"couldn't be loaded ({exc}); repairing that SolidWorks install "
            "restores it."
        ) from exc
    info = TypeLibraryInfo(
        guid=SOLIDWORKS_TYPELIB_GUID,
        version=f"{major}.{minor}",
        year=year_of(major),
        path=str(com.QueryPathOfRegTypeLib(SOLIDWORKS_TYPELIB_GUID, major, minor)),
    )
    return lib, info

normalize_input

normalize_input(input_data: Any, model_type: type[TModel]) -> TModel

Validate input_data as model_type.

Parameters:

Name Type Description Default
input_data Any

A model_type instance, a mapping of its fields, another pydantic model (converted through model_dump), or None for a tool whose fields all have defaults.

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
def normalize_input[TModel: BaseModel](
    input_data: Any, model_type: type[TModel]
) -> TModel:
    """Validate ``input_data`` as ``model_type``.

    Args:
        input_data: A ``model_type`` instance, a mapping of its fields, another
            pydantic model (converted through ``model_dump``), or ``None`` for
            a tool whose fields all have defaults.
        model_type: The tool's pydantic input model.

    Returns:
        TModel: The validated model.

    Raises:
        InvalidInputError: Naming the offending field(s).
    """
    if isinstance(input_data, model_type):
        return input_data
    if input_data is None:
        input_data = {}
    elif not isinstance(input_data, dict) and hasattr(input_data, "model_dump"):
        input_data = input_data.model_dump()
    try:
        return model_type.model_validate(input_data)
    except ValidationError as exc:  # also wraps ValueErrors from validators
        raise InvalidInputError(describe_validation_error(exc)) from exc

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 (solidworks_year, the index refresh settings).

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
async def 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.

    Args:
        mcp (FastMCP): The server to register on.
        adapter (SolidWorksAdapter): Unused; kept for the registrar's
            uniform signature.
        config (dict[str, Any]): Server configuration (``solidworks_year``,
            the index refresh settings).

    Returns:
        int: The number of tools registered.
    """
    mcp = with_tool_boundary(mcp)

    @mcp.tool()
    async def discover_solidworks_docs(
        input_data: DiscoverDocsInput | None = None,
    ) -> dict[str, Any]:
        """Rebuild the SolidWorks API index on purpose. The lookups don't need it.

        The lookup tools (lookup_api_method, lookup_api_interface,
        find_related_api_members, search_solidworks_api_help) build the index
        themselves on first use, so call this only to rebuild it, to read a
        specific SolidWorks year, or to save a copy elsewhere. It reads every
        interface in the installed SolidWorks type library (each member's
        parameters, return type and description), plus the VBA library
        references. SolidWorks must be installed, not running; it is never
        started or called. Changes: writes the index file, replacing the
        saved one.

        Returns ``summary`` (interface, method and property counts),
        ``type_library`` (version, year and .tlb path), ``year`` and
        ``output_file``, the saved index (megabytes, so it is not returned).
        Fails with a message naming the installed years when ``year`` isn't
        installed, or saying SolidWorks isn't installed here.

        Example input: ``{"year": 2026}``

        Args:
            input_data (DiscoverDocsInput | None): The rebuild. Nothing is
                required: `year` defaults to the installed release,
                `output_dir` to the index folder, and `include_vba` to on.

        Returns:
            dict[str, Any]: ``summary``, ``type_library``, ``year``,
            ``output_file`` and ``rag_indexed``, plus
            ``status``/``message``/``execution_time``.
        """
        start_time = time.time()
        normalized = normalize_input(input_data, DiscoverDocsInput)
        output_dir = Path(normalized.output_dir) if normalized.output_dir else None
        year = _resolve_solidworks_year(normalized.year, config)

        logger.info("Starting SolidWorks documentation discovery...")
        discovery, output_file = _build_index(
            year,
            strict=normalized.year is not None,
            output_dir=output_dir,
            include_vba=normalized.include_vba,
        )
        index = discovery.index
        summary = discovery.create_search_summary()

        return {
            "status": "success",
            "message": f"Discovered {summary['total_com_objects']} COM objects, "
            f"{summary['total_methods']} methods, "
            f"{summary['total_properties']} properties",
            "type_library": index["type_library"],
            "summary": summary,
            "year": index["type_library"]["year"],
            "output_file": str(output_file),
            "rag_indexed": _rebuild_rag_index(output_file),
            "execution_time": time.time() - start_time,
        }

    @mcp.tool()
    async def search_solidworks_api_help(
        input_data: SearchApiHelpInput | None = None,
    ) -> dict[str, Any]:
        """Search SolidWorks API interface and member names by keyword.

        Use this when you don't know the exact name: "chamfer" finds
        IFeatureManager.InsertFeatureChamfer. Then call lookup_api_method on
        a match for its parameters and return type. Matches come from the
        SolidWorks type library installed on this machine.

        Setup: none. SolidWorks must be installed, not running; it is never
        contacted. Read-only. The first call builds the index (about a
        second) and later calls reuse it. ``index_status`` is ``ready``
        (saved index), ``rebuilt`` (built for this call) or ``unavailable``
        (no index could be built; ``guidance`` says why).

        Returns ``matches`` (interface, member, member_type, score),
        ``guidance``, and ``fallback_help`` suggesting MCP tools for the
        task, with ``year`` and ``type_library_version`` of the library that
        answered.

        Example input: ``{"query": "chamfer", "max_results": 5}``

        Args:
            input_data (SearchApiHelpInput | None): The search. `query`
                (one or more words) is required; `max_results` and `year`
                have defaults.

        Returns:
            dict[str, Any]: ``matches``, ``guidance``, ``fallback_help``,
            ``year``, ``type_library_version``, ``index_status`` and
            ``source_index_file``, plus ``status``/``message``/``execution_time``.
        """
        start_time = time.time()
        normalized = normalize_input(input_data, SearchApiHelpInput)
        source = _index_for_lookup(normalized.year, normalized.index_file, config)

        matches = _search_index(source.index, normalized.query, normalized.max_results)
        guidance_lines = []
        if matches:
            guidance_lines.append(
                f"Found {len(matches)} API matches for '{normalized.query}'."
            )
            guidance_lines.append(
                "Use lookup_api_method on a match for its parameters and return type."
            )
        else:
            guidance_lines.append(
                "No indexed API hits found; using workflow fallback guidance."
            )
        if source.note:
            guidance_lines.append(source.note)

        return {
            "status": "success",
            "message": "SolidWorks API help search completed",
            "query": normalized.query,
            **source.payload(),
            "matches": [match.model_dump(exclude_unset=True) for match in matches],
            "fallback_help": _fallback_help_for_query(normalized.query),
            "guidance": " ".join(guidance_lines),
            "execution_time": time.time() - start_time,
        }

    @mcp.tool()
    async def lookup_api_method(
        input_data: LookupApiMethodInput | None = None,
    ) -> dict[str, Any]:
        """Look up one SolidWorks API method or property: parameters, return type, description.

        Use this before writing or debugging a SolidWorks API call (VBA, a
        macro or COM) to check that the member exists on that interface and
        how to call it. Answers come from the SolidWorks type library
        installed on this machine, so they match the installed version.

        Setup: none. SolidWorks must be installed, not running; it is never
        contacted. Read-only. The first lookup builds the index (about a
        second). ``index_status`` is ``ready``, ``rebuilt`` or
        ``unavailable``.

        Names match regardless of case, as COM does. ``result.member`` is
        SolidWorks' own spelling, with a ``note`` when yours differs. Each
        parameter has a ``type`` and a ``direction``: ``in``, ``out``
        (SolidWorks fills it) or ``in_out`` (pass a variable by reference).
        ``return_type`` is null when the method returns nothing; a property
        has its value type there and an ``access``. ``result.found`` false
        means there is no such member, and ``result.note`` says why,
        including when no index could be built (SolidWorks isn't installed
        here, or the requested year isn't).

        Example input: ``{"interface": "ISldWorks", "method": "OpenDoc6"}``

        Args:
            input_data (LookupApiMethodInput | None): The member to look up.
                `interface` (e.g. "ISldWorks") and `method` (a method or
                property name) are required; `year` has a default.

        Returns:
            dict[str, Any]: ``result``, ``year``, ``type_library_version``,
            ``index_status`` and ``source_index_file``, plus
            ``status``/``message``/``execution_time``.
        """
        start_time = time.time()
        normalized = normalize_input(input_data, LookupApiMethodInput)
        source = _index_for_lookup(normalized.year, normalized.index_file, config)
        result = source.annotate(
            _lookup_method(source.index, normalized.interface, normalized.method)
        )
        return {
            "status": "success",
            "message": (
                "Method found"
                if result.found
                else "No indexed match for that interface/method"
            ),
            **source.payload(),
            "result": result.model_dump(exclude_unset=True),
            "execution_time": time.time() - start_time,
        }

    @mcp.tool()
    async def lookup_api_interface(
        input_data: LookupApiInterfaceInput | None = None,
    ) -> dict[str, Any]:
        """List every method and property of a SolidWorks COM interface.

        Use this to see what an interface offers, such as IFeatureManager,
        or to check which interface a member is really on before calling it.
        For one member's parameters, use lookup_api_method. Names match
        regardless of case.

        Setup: none. SolidWorks must be installed, not running; it is never
        contacted. Read-only. The first call builds the index (about a
        second) and later calls reuse it. ``index_status`` is ``ready``
        (saved index), ``rebuilt`` (built for this call) or ``unavailable``
        (no index could be built).

        Returns ``result`` with ``methods``, ``properties`` and their counts.
        ``result.found`` false means the interface isn't in the type library,
        or no index could be built, in which case ``result.note`` says why.

        Example input: ``{"interface": "IFeatureManager"}``

        Args:
            input_data (LookupApiInterfaceInput | None): The interface.
                `interface` (e.g. "IFeatureManager") is required; `year` has
                a default.

        Returns:
            dict[str, Any]: ``result``, ``year``, ``type_library_version``,
            ``index_status`` and ``source_index_file``, plus
            ``status``/``message``/``execution_time``.
        """
        start_time = time.time()
        normalized = normalize_input(input_data, LookupApiInterfaceInput)
        source = _index_for_lookup(normalized.year, normalized.index_file, config)
        result = _lookup_interface(source.index, normalized.interface)
        source.annotate(result)
        return {
            "status": "success",
            "message": (
                f"{result.method_count} methods, {result.property_count} properties"
                if result.found
                else "Interface not found in the indexed documentation"
            ),
            **source.payload(),
            "result": result.model_dump(exclude_unset=True),
            "execution_time": time.time() - start_time,
        }

    @mcp.tool()
    async def find_related_api_members(
        input_data: FindRelatedApiInput | None = None,
    ) -> dict[str, Any]:
        """Find SolidWorks API members related to an interface or member name.

        For an interface: its own members. For a member: the other members
        of every interface that also has it (often used together), plus
        members whose names contain it. Use it to explore around a call you
        know, such as what sits beside InsertSketch.

        Setup: none. SolidWorks must be installed, not running; it is never
        contacted. Read-only. The first call builds the index (about a
        second) and later calls reuse it. ``index_status`` is ``ready``
        (saved index), ``rebuilt`` (built for this call) or ``unavailable``
        (no index could be built).

        Returns ``result.related``: each member's interface, name, type and
        why it is related. ``result.found`` false means nothing matched, or
        no index could be built, in which case ``result.note`` says why.

        Example input: ``{"name": "InsertSketch", "max_results": 10}``

        Args:
            input_data (FindRelatedApiInput | None): What to explore.
                `name` (an interface or member) is required; `max_results`
                and `year` have defaults.

        Returns:
            dict[str, Any]: ``result``, ``year``, ``type_library_version``,
            ``index_status`` and ``source_index_file``, plus
            ``status``/``message``/``execution_time``.
        """
        start_time = time.time()
        normalized = normalize_input(input_data, FindRelatedApiInput)
        source = _index_for_lookup(normalized.year, normalized.index_file, config)
        result = _find_related_api_members(
            source.index, normalized.name, normalized.max_results
        )
        source.annotate(result)
        return {
            "status": "success",
            "message": (
                f"{len(result.related)} related member(s)"
                if result.found
                else "No related members found"
            ),
            **source.payload(),
            "result": result.model_dump(exclude_unset=True),
            "execution_time": time.time() - start_time,
        }

    # discover_solidworks_docs, search_solidworks_api_help, lookup_api_method,
    # lookup_api_interface, find_related_api_members
    tool_count = 5
    return tool_count

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 winreg module; defaults to the real one.

None

Returns:

Type Description
tuple[int, int]

tuple[int, int]: The (major, minor) version.

Raises:

Type Description
TypeLibraryUnavailable

Not on Windows, or no matching type library is registered.

Source code in src/solidworks_mcp/tools/type_library.py
def 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.

    Args:
        year (int | None): The wanted SolidWorks year; None for the newest.
        strict (bool): True to fail when that year isn't installed.
        registry (Any): The ``winreg`` module; defaults to the real one.

    Returns:
        tuple[int, int]: The ``(major, minor)`` version.

    Raises:
        TypeLibraryUnavailable: Not on Windows, or no matching type library
            is registered.
    """
    registry = registry if registry is not None else winreg
    if registry is None:
        raise TypeLibraryUnavailable(_NEEDS_WINDOWS)
    return choose_version(registered_versions(registry), year, strict)

with_tool_boundary

with_tool_boundary(mcp: TServer) -> TServer

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
def with_tool_boundary[TServer](mcp: TServer) -> TServer:
    """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.
    """
    return cast(TServer, ToolRegistrar.of(mcp))

year_of

year_of(major: int) -> int

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.

Source code in src/solidworks_mcp/tools/type_library.py
def year_of(major: int) -> int:
    """The SolidWorks year a type library major version belongs to.

    Args:
        major (int): The type library major version, e.g. 34.

    Returns:
        int: The release year, e.g. 2026.
    """
    return major + _YEAR_OFFSET