solidworks_mcp.selftest.documents¶
solidworks_mcp.selftest.documents ¶
Keep the selftest away from the user's documents.
The guard notes which documents are open before the selftest starts and gives it a fresh temporary folder to save into. On the way out, also after an error, it closes, unsaved, only the documents the selftest made, then deletes the folder. A document that was open before is never activated, saved or closed.
Attributes¶
Classes¶
DocumentGuard ¶
An async context manager owning the selftest's folder and documents.
Use call to list, activate and close documents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
call
|
ToolCaller
|
The selftest's tool caller. |
required |
Source code in src/solidworks_mcp/selftest/documents.py
Attributes¶
folder
property
¶
The selftest's temporary folder; only inside async with.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
The guard has not been entered. |
Methods:¶
__aenter__
async
¶
Note the open documents and make the folder.
Returns:
| Name | Type | Description |
|---|---|---|
DocumentGuard |
DocumentGuard
|
This guard, with |
Source code in src/solidworks_mcp/selftest/documents.py
__aexit__
async
¶
__aexit__(exc_type: type[BaseException] | None, exc: BaseException | None, traceback: TracebackType | None) -> None
Close the selftest's documents and delete its folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exc_type
|
type[BaseException] | None
|
The exception's type, if one is propagating. |
required |
exc
|
BaseException | None
|
The exception, if one is propagating. |
required |
traceback
|
TracebackType | None
|
Its traceback. |
required |
Source code in src/solidworks_mcp/selftest/documents.py
cleanup
async
¶
Close the selftest's documents, unsaved, then delete its folder.
A failure is recorded in problems, never raised, so it can't hide
the results it follows.
Source code in src/solidworks_mcp/selftest/documents.py
is_ours ¶
Whether the selftest made document.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
document
|
dict[str, Any]
|
An entry from |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True when it is new since the start and was never saved, |
bool
|
or was saved inside the selftest's folder. |
Source code in src/solidworks_mcp/selftest/documents.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 |