Skip to content

solidworks_mcp.setup.legacy

solidworks_mcp.setup.legacy

Recognise older, hand-made config entries that start this same server.

Before solidworks-mcp setup existed, the README had people add entries under names of their choosing, launched through run-mcp.ps1, start_local_server_claude.py and similar. Left in place beside the new solidworks entry, they load every tool twice, and the PowerShell ones can break the stdio connection.

The rule reads only an entry's command and args. Secrets live in env and headers, which are never looked at. It matches this project's own launcher names exactly, so another vendor's SolidWorks server is never mistaken for this one.

Attributes

SERVER_NAME module-attribute

SERVER_NAME = 'solidworks'

_OLD_SCRIPTS module-attribute

_OLD_SCRIPTS = frozenset({'run-mcp.ps1', 'run-mcp-claude.ps1', 'start_local_server.py', 'start_local_server_claude.py'})

_OUR_LAUNCHERS module-attribute

_OUR_LAUNCHERS = frozenset({'solidworks-mcp', 'solidworks-mcp.exe', 'solidworks-mcp-python', 'solidworks-mcp-python.exe'})

_OUR_MODULES module-attribute

_OUR_MODULES = frozenset({'solidworks_mcp.server', 'solidworks_mcp'})

Functions:

launcher_name

launcher_name(entry: Any) -> str

The program file an entry starts, for showing to the user.

Parameters:

Name Type Description Default
entry Any

A server entry from a client config.

required

Returns:

Type Description
str

The file name of its command (e.g. powershell.exe), without the

str

folder; ? if it has none.

Source code in src/solidworks_mcp/setup/legacy.py
def launcher_name(entry: Any) -> str:
    """The program file an entry starts, for showing to the user.

    Args:
        entry: A server entry from a client config.

    Returns:
        The file name of its ``command`` (e.g. ``powershell.exe``), without the
        folder; ``?`` if it has none.
    """
    command = entry.get("command") if isinstance(entry, dict) else None
    return (
        PureWindowsPath(command).name if isinstance(command, str) and command else "?"
    )

old_entries

old_entries(servers: dict[str, Any]) -> list[str]

Name every entry, besides solidworks, that starts this server.

Parameters:

Name Type Description Default
servers dict[str, Any]

A config's server entries (mcpServers or servers).

required

Returns:

Type Description
list[str]

Their names, in the config's order.

Source code in src/solidworks_mcp/setup/legacy.py
def old_entries(servers: dict[str, Any]) -> list[str]:
    """Name every entry, besides ``solidworks``, that starts this server.

    Args:
        servers: A config's server entries (``mcpServers`` or ``servers``).

    Returns:
        Their names, in the config's order.
    """
    return [
        name
        for name, entry in servers.items()
        if name != SERVER_NAME and starts_this_server(entry)
    ]

starts_this_server

starts_this_server(entry: Any) -> bool

Whether a config entry launches this project's server.

Parameters:

Name Type Description Default
entry Any

A server entry from a client config.

required

Returns:

Type Description
bool

True when its command is one of this package's launchers, or its

bool

arguments name one of this project's launch scripts or modules.

Source code in src/solidworks_mcp/setup/legacy.py
def starts_this_server(entry: Any) -> bool:
    """Whether a config entry launches this project's server.

    Args:
        entry: A server entry from a client config.

    Returns:
        True when its command is one of this package's launchers, or its
        arguments name one of this project's launch scripts or modules.
    """
    if not isinstance(entry, dict):
        return False
    command = entry.get("command")
    args = entry.get("args")
    words = [command] if isinstance(command, str) else []
    if isinstance(args, list):
        words += [a for a in args if isinstance(a, str)]

    # PureWindowsPath splits on both / and \, whatever OS this runs on.
    names = {PureWindowsPath(word).name.lower() for word in words}
    if names & _OLD_SCRIPTS or names & _OUR_LAUNCHERS:
        return True
    # `-m solidworks_mcp.server`: the word after each -m is a module name.
    modules = {words[i + 1] for i, word in enumerate(words[:-1]) if word == "-m"}
    return bool(modules & _OUR_MODULES)