solidworks_mcp.adapters.intelligent_router¶
solidworks_mcp.adapters.intelligent_router ¶
Intelligent router for COM/VBA execution with optional response caching.
Attributes¶
OperationCallable
module-attribute
¶
Classes¶
AdapterResult
dataclass
¶
AdapterResult(status: AdapterResultStatus, data: T | None = None, error: str | None = None, execution_time: float | None = None, metadata: dict[str, Any] | None = None)
Bases: Generic[T]
Result wrapper for adapter operations.
Attributes:
| Name | Type | Description |
|---|---|---|
data |
T | None
|
The data value. |
error |
str | None
|
The error value. |
execution_time |
float | None
|
The execution time value. |
metadata |
dict[str, Any] | None
|
The metadata value. |
status |
AdapterResultStatus
|
The status value. |
AdapterResultStatus ¶
Bases: StrEnum
Result status for adapter operations.
Attributes:
| Name | Type | Description |
|---|---|---|
ERROR |
Any
|
The error value. |
SUCCESS |
Any
|
The success value. |
TIMEOUT |
Any
|
The timeout value. |
WARNING |
Any
|
The warning value. |
ComplexityAnalyzer ¶
Analyze operation complexity and recommend COM or VBA execution path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameter_threshold
|
int
|
The parameter threshold value. Defaults to 12. |
12
|
score_threshold
|
float
|
The score threshold value. Defaults to 0.6. |
0.6
|
Attributes:
| Name | Type | Description |
|---|---|---|
_parameter_threshold |
Any
|
The parameter threshold value. |
_score_threshold |
Any
|
The score threshold value. |
Initialize analyzer state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameter_threshold
|
int
|
The parameter threshold value. Defaults to 12. |
12
|
score_threshold
|
float
|
The score threshold value. Defaults to 0.6. |
0.6
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
None. |
Source code in src/solidworks_mcp/adapters/complexity_analyzer.py
Methods:¶
analyze ¶
Produce a routing recommendation for an operation call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
str
|
Callable object executed by the helper. |
required |
payload
|
object
|
The payload value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RoutingDecision |
RoutingDecision
|
The result produced by the operation. |
Source code in src/solidworks_mcp/adapters/complexity_analyzer.py
record_result ¶
Record operation outcome for future routing influence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
str
|
Callable object executed by the helper. |
required |
route
|
str
|
The route value. |
required |
success
|
bool
|
The success value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
None. |
Source code in src/solidworks_mcp/adapters/complexity_analyzer.py
IntelligentRouter ¶
IntelligentRouter(analyzer: ComplexityAnalyzer, cache: ResponseCache, cacheable_operations: set[str] | None = None)
Route operations between COM and VBA paths using complexity analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
analyzer
|
ComplexityAnalyzer
|
The analyzer value. |
required |
cache
|
ResponseCache
|
The cache value. |
required |
cacheable_operations
|
set[str] | None
|
The cacheable operations value. Defaults to None. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
_analyzer |
Any
|
The analyzer value. |
_cache |
Any
|
The cache value. |
_cacheable_operations |
Any
|
The cacheable operations value. |
Initialize router dependencies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
analyzer
|
ComplexityAnalyzer
|
The analyzer value. |
required |
cache
|
ResponseCache
|
The cache value. |
required |
cacheable_operations
|
set[str] | None
|
The cacheable operations value. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
None. |
Source code in src/solidworks_mcp/adapters/intelligent_router.py
Methods:¶
execute
async
¶
execute(operation: str, payload: object, call_args: tuple[Any, ...], call_kwargs: dict[str, Any], com_operation: OperationCallable, vba_operation: OperationCallable | None, cache_ttl_seconds: int | None = None) -> tuple[AdapterResult[Any], RouteResult]
Provide execute support for the intelligent router.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
str
|
Callable object executed by the helper. |
required |
payload
|
object
|
The payload value. |
required |
call_args
|
tuple[Any, ...]
|
The call args value. |
required |
call_kwargs
|
dict[str, Any]
|
The call kwargs value. |
required |
com_operation
|
OperationCallable
|
The com operation value. |
required |
vba_operation
|
OperationCallable | None
|
The vba operation value. |
required |
cache_ttl_seconds
|
int | None
|
The cache ttl seconds value. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[AdapterResult[Any], RouteResult]
|
tuple[AdapterResult[Any], RouteResult]: A tuple containing the resulting values. |
Source code in src/solidworks_mcp/adapters/intelligent_router.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
ResponseCache ¶
Thread-safe in-memory cache for adapter response objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policy
|
CachePolicy
|
The policy value. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
_lock |
Any
|
The lock value. |
_policy |
Any
|
The policy value. |
Initialize this cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policy
|
CachePolicy
|
The policy value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
None. |
Source code in src/solidworks_mcp/cache/response_cache.py
Attributes¶
enabled
property
¶
Return whether caching is enabled.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if enabled, otherwise False. |
Methods:¶
get ¶
Fetch a cached value when present and unexpired.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key value. |
required |
Returns:
| Type | Description |
|---|---|
object | None
|
object | None: The result produced by the operation. |
Source code in src/solidworks_mcp/cache/response_cache.py
make_key ¶
Build a deterministic cache key from an operation payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
str
|
Callable object executed by the helper. |
required |
payload
|
object
|
The payload value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The resulting text value. |
Source code in src/solidworks_mcp/cache/response_cache.py
set ¶
Store a cache value with expiration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key value. |
required |
value
|
object
|
The value value. |
required |
ttl_seconds
|
int | None
|
The ttl seconds value. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
None. |
Source code in src/solidworks_mcp/cache/response_cache.py
RouteResult
dataclass
¶
Route execution metadata.
Attributes:
| Name | Type | Description |
|---|---|---|
route |
str
|
The route value. |
used_cache |
bool
|
The used cache value. |