Skip to content

solidworks_mcp.selftest.environment

solidworks_mcp.selftest.environment

The report's environment section: SolidWorks, Python and this package.

Attributes

__version__ module-attribute

__version__ = '2.0.0'

Functions:

_package_version

_package_version(name: str) -> str | None

An installed distribution's version, or None when it isn't installed.

Source code in src/solidworks_mcp/selftest/environment.py
def _package_version(name: str) -> str | None:
    """An installed distribution's version, or ``None`` when it isn't installed."""
    try:
        return metadata.version(name)
    except metadata.PackageNotFoundError:
        return None

read_environment async

read_environment(adapter: Any, year: int | None) -> dict[str, Any]

Describe the setup the selftest ran on.

A value that can't be read is None; nothing here stops the run.

Parameters:

Name Type Description Default
adapter Any

The connected adapter.

required
year int | None

The SolidWorks year the server was started with.

required

Returns:

Type Description
dict[str, Any]

dict[str, Any]: solidworks (revision, language,

dict[str, Any]

templates, year), os, python, pywin32 and

dict[str, Any]

solidworks_mcp versions.

Source code in src/solidworks_mcp/selftest/environment.py
async def read_environment(adapter: Any, year: int | None) -> dict[str, Any]:
    """Describe the setup the selftest ran on.

    A value that can't be read is ``None``; nothing here stops the run.

    Args:
        adapter: The connected adapter.
        year: The SolidWorks year the server was started with.

    Returns:
        dict[str, Any]: ``solidworks`` (``revision``, ``language``,
        ``templates``, ``year``), ``os``, ``python``, ``pywin32`` and
        ``solidworks_mcp`` versions.
    """
    info = await adapter.get_application_info()
    data = info.data if info.is_success and info.data else {}
    return {
        "solidworks": {
            "revision": data.get("revision"),
            "language": data.get("language"),
            "year": year,
            "templates": data.get("templates") or {},
        },
        "os": platform.platform(),
        "python": platform.python_version(),
        "pywin32": _package_version("pywin32"),
        "solidworks_mcp": __version__,
    }