solidworks_mcp¶
solidworks_mcp ¶
SolidWorks MCP Server - Python Implementation with FastMCP and PydanticAI.
This is a comprehensive Python implementation of the SolidWorks MCP server, providing 88+ tools for SolidWorks automation with enhanced security, configurability, and modern Python architectures.
Original TypeScript implementation rights and IP remain with the original author. This Python implementation adds FastMCP integration, PydanticAI capabilities, and comprehensive testing for local and remote deployment scenarios.
Author: Andrew Bartels (hobby mechanical engineer learning LLMs and MCP) License: MIT
Attributes¶
__all__
module-attribute
¶
Classes¶
SolidWorksMCPConfig ¶
Bases: BaseModel
Main configuration for SolidWorks MCP Server.
Attributes:
| Name | Type | Description |
|---|---|---|
adapter_type |
AdapterType
|
The adapter type value. |
allowed_hosts |
list[str]
|
The allowed hosts value. |
allowed_origins |
list[str]
|
The allowed origins value. |
api_key |
SecretStr | None
|
The api key value. |
api_key_required |
bool
|
The api key required value. |
api_keys |
list[str]
|
The api keys value. |
cache_dir |
Path | None
|
The cache dir value. |
circuit_breaker_enabled |
bool
|
The circuit breaker enabled value. |
circuit_breaker_threshold |
int
|
The circuit breaker threshold value. |
circuit_breaker_timeout |
int
|
The circuit breaker timeout value. |
complexity_parameter_threshold |
int
|
The complexity parameter threshold value. |
complexity_score_threshold |
float
|
The complexity score threshold value. |
connection_pool_size |
int
|
The connection pool size value. |
connection_pooling |
bool
|
The connection pooling value. |
cors_origins |
list[str]
|
The cors origins value. |
data_dir |
Path
|
The data dir value. |
database_url |
str
|
The database url value. |
debug |
bool
|
The debug value. |
deployment_mode |
DeploymentMode
|
The deployment mode value. |
enable_analysis_tools |
bool
|
The enable analysis tools value. |
enable_audit_logging |
bool
|
The enable audit logging value. |
enable_circuit_breaker |
bool
|
The enable circuit breaker value. |
enable_connection_pooling |
bool
|
The enable connection pooling value. |
enable_cors |
bool
|
The enable cors value. |
enable_design_tables |
bool
|
The enable design tables value. |
enable_intelligent_routing |
bool
|
The enable intelligent routing value. |
enable_macro_recording |
bool
|
The enable macro recording value. |
enable_pdm |
bool
|
The enable pdm value. |
enable_rate_limiting |
bool
|
The enable rate limiting value. |
enable_response_cache |
bool
|
The enable response cache value. |
enable_sql_integration |
bool
|
The enable sql integration value. |
enable_windows_validation |
bool
|
The enable windows validation value. |
host |
str
|
The host value. |
log_file |
Path | None
|
The log file value. |
log_level |
str
|
The log level value. |
max_connections |
int
|
The max connections value. |
max_retries |
int
|
The max retries value. |
mock_solidworks |
bool
|
The mock solidworks value. |
model_config |
Any
|
The model config value. |
pdm_server |
str | None
|
The pdm server value. |
pdm_vault |
str | None
|
The pdm vault value. |
port |
int
|
The port value. |
rate_limit_enabled |
bool
|
The rate limit enabled value. |
rate_limit_per_minute |
int
|
The rate limit per minute value. |
response_cache_max_entries |
int
|
The response cache max entries value. |
response_cache_ttl_seconds |
int
|
The response cache ttl seconds value. |
security_level |
SecurityLevel
|
The security level value. |
solidworks_path |
str | None
|
The solidworks path value. |
solidworks_year |
int | None
|
The solidworks year value. |
sql_connection |
str | None
|
The sql connection value. |
state_file |
str | None
|
The state file value. |
testing |
bool
|
The testing value. |
timeout_seconds |
float
|
The timeout seconds value. |
worker_processes |
int
|
The worker processes value. |
Attributes¶
can_use_solidworks
property
¶
Check if SolidWorks integration is possible.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if use solidworks, otherwise False. |
is_windows
property
¶
Check if running on Windows.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if windows, otherwise False. |
Functions¶
from_env
classmethod
¶
Build configuration from environment variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env_file
|
str | None
|
The env file value. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
SolidWorksMCPConfig |
SolidWorksMCPConfig
|
The result produced by the operation. |
Source code in src/solidworks_mcp/config.py
get_database_config ¶
Get database configuration.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: A dictionary containing the resulting values. |
get_security_config ¶
Get security configuration.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: A dictionary containing the resulting values. |
Source code in src/solidworks_mcp/config.py
model_post_init ¶
Post-initialization setup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
__context
|
Any
|
The context value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
None. |
Source code in src/solidworks_mcp/config.py
set_cache_dir
classmethod
¶
Set default cache directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
Path | None
|
The v value. |
required |
info
|
ValidationInfo
|
The info value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
The result produced by the operation. |
Source code in src/solidworks_mcp/config.py
set_log_file
classmethod
¶
Set default log file path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
Path | None
|
The v value. |
required |
info
|
ValidationInfo
|
The info value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
The result produced by the operation. |
Source code in src/solidworks_mcp/config.py
sync_legacy_alias_fields ¶
Sync test/developer alias fields into canonical runtime fields.
Several fixtures and scripts still populate compatibility fields such as
rate_limit_enabled and connection_pooling. Runtime code reads the canonical
fields, so normalize them here after validation.
Returns:
| Name | Type | Description |
|---|---|---|
SolidWorksMCPConfig |
SolidWorksMCPConfig
|
The result produced by the operation. |
Source code in src/solidworks_mcp/config.py
validate_adapter_type
classmethod
¶
Validate adapter type based on platform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
AdapterType
|
The v value. |
required |
info
|
ValidationInfo
|
The info value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AdapterType |
AdapterType
|
The result produced by the operation. |
Source code in src/solidworks_mcp/config.py
validate_complexity_parameter_threshold
classmethod
¶
Validate the complexity parameter threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
int
|
The v value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The computed numeric result. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Complexity_parameter_threshold must be >= 1. |
Source code in src/solidworks_mcp/config.py
validate_complexity_score_threshold
classmethod
¶
Validate the complexity score threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
float
|
The v value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The computed numeric result. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Complexity_score_threshold must be in (0, 1]. |
Source code in src/solidworks_mcp/config.py
validate_port
classmethod
¶
Validate the port.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
int
|
The v value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The computed numeric result. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Port must be between 1 and 65535. |
Source code in src/solidworks_mcp/config.py
validate_response_cache_max_entries
classmethod
¶
Validate response cache size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
int
|
The v value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The computed numeric result. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Response_cache_max_entries must be >= 1. |
Source code in src/solidworks_mcp/config.py
validate_response_cache_ttl_seconds
classmethod
¶
Validate default response cache TTL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
int
|
The v value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The computed numeric result. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Response_cache_ttl_seconds must be >= 1. |
Source code in src/solidworks_mcp/config.py
validate_timeout
classmethod
¶
Validate the timeout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
float
|
The v value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The computed numeric result. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Timeout_seconds must be > 0. |
Source code in src/solidworks_mcp/config.py
Functions¶
__dir__ ¶
Build internal dir.
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: A list containing the resulting items. |
__getattr__ ¶
Build internal getattr.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The result produced by the operation. |
Raises:
| Type | Description |
|---|---|
AttributeError
|
If the operation cannot be completed. |