solidworks_mcp.selftest.areas¶
solidworks_mcp.selftest.areas ¶
The selftest's four areas: part, assembly, drawing and export.
Each area calls tools through Context.call exactly as an MCP client
would, and appends a Check per value it reads back. The values it
expects are in expected.py. An area saves what later areas need into
Context.files; an area whose needs aren't there is skipped.
Attributes¶
Classes¶
AssemblyArea ¶
The pin seated in the block's hole by two face mates.
Methods:¶
run
async
¶
Insert both parts, mate them, and check counts and clearance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The selftest context. |
required |
checks
|
list[Check]
|
The area's checks, appended to. |
required |
Source code in src/solidworks_mcp/selftest/areas.py
Check
dataclass
¶
Check(name: str, expected: Any, measured: Any, tolerance: Any = None, unit: str = '', passed: bool | None = None)
One value read back from SolidWorks against the hand calculation.
passed is None when the value could not be measured, which
counts as a failure.
Context
dataclass
¶
What the areas share: the tool caller, the folder, and saved files.
DrawingArea ¶
A new drawing with one isometric view of the block.
Methods:¶
run
async
¶
Make the drawing and count its views.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The selftest context. |
required |
checks
|
list[Check]
|
The area's checks, appended to. |
required |
Source code in src/solidworks_mcp/selftest/areas.py
ExportArea ¶
The block exported as STEP.
Methods:¶
run
async
¶
Export the block and check the file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The selftest context. |
required |
checks
|
list[Check]
|
The area's checks, appended to. |
required |
Source code in src/solidworks_mcp/selftest/areas.py
PartArea ¶
A block with a hole and a fillet, and a pin; both saved for later areas.
Methods:¶
run
async
¶
Build, check and save the block, then the pin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The selftest context. |
required |
checks
|
list[Check]
|
The area's checks, appended to. |
required |
Source code in src/solidworks_mcp/selftest/areas.py
ToolCaller ¶
Call MCP tools by name with dict input, as a client does; log each call.
Wrap a connected fastmcp.Client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
Any
|
The client, already entered. |
required |
Source code in src/solidworks_mcp/selftest/results.py
Methods:¶
__call__
async
¶
Call name and return its reply; raise when it reports an error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The tool's name. |
required |
args
|
dict[str, Any] | None
|
Its input, sent as |
None
|
record
|
bool
|
Whether the call is listed in the report. |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: The tool's reply. |
Raises:
| Type | Description |
|---|---|
ToolFailed
|
The tool replied with |
Source code in src/solidworks_mcp/selftest/results.py
ToolFailed ¶
Bases: Exception
A tool call returned status: error.
Remember which tool failed and its message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool
|
str
|
The tool's name. |
required |
message
|
str
|
The tool's error message. |
required |
Source code in src/solidworks_mcp/selftest/results.py
Methods:¶
Functions:¶
_component ¶
The component made from part.
Raises:
| Type | Description |
|---|---|
ToolFailed
|
|
Source code in src/solidworks_mcp/selftest/areas.py
_save
async
¶
Save the active document into the selftest's folder; return its path.
_sketch_and_extrude
async
¶
Sketch one shape on the Top Plane and extrude it depth mm.
Source code in src/solidworks_mcp/selftest/areas.py
verify
async
¶
Run verify_model on the active document; append one check per value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The selftest context. |
required |
label
|
str
|
Prefix for the check names, e.g. |
required |
checks
|
list[Check]
|
The area's checks, appended to. |
required |
**expectations
|
Any
|
|
{}
|