solidworks_mcp.setup.registration¶
solidworks_mcp.setup.registration ¶
Add or remove the server entry for one client, by that client's own means.
Most clients read a JSON file (:class:JsonFileRegistrar); Claude Code is
configured through its claude mcp command (:class:ClaudeCliRegistrar).
:func:registrar_for picks one, so the setup wizard never needs to know
which kind of client it is talking to.
Attributes¶
Classes¶
ClaudeCliRegistrar ¶
Registers the server with claude mcp add --scope user.
Bind to Claude Code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
Client
|
The Claude Code client; |
required |
run
|
Runner
|
How to run a command ( |
run
|
Source code in src/solidworks_mcp/setup/registration.py
Methods:¶
apply ¶
Run claude mcp to add or remove the server.
Without claude on the PATH, or with dry_run, nothing runs and
the change reports the command for the user to run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entry
|
dict[str, Any] | None
|
The entry to register, or |
required |
dry_run
|
bool
|
Report the command, and run nothing. |
required |
Returns:
| Type | Description |
|---|---|
EntryChange
|
What happened; |
Raises:
| Type | Description |
|---|---|
ConfigFileError
|
|
Source code in src/solidworks_mcp/setup/registration.py
Client
dataclass
¶
Client(key: str, name: str, found: bool, config_path: Path | None, section: str = 'mcpServers', stdio_type: bool = False, restart_hint: str = '')
One MCP client and how to register a server with it.
Attributes:
| Name | Type | Description |
|---|---|---|
key |
str
|
The name used with |
name |
str
|
The name shown to the user. |
found |
bool
|
Whether the client looks installed. |
config_path |
Path | None
|
Its JSON config file; |
section |
str
|
The object in the config that holds the servers. |
stdio_type |
bool
|
Whether entries need |
restart_hint |
str
|
What to do after setup so the client loads the server. |
Methods:¶
entry ¶
Build the server entry in the shape this client expects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
str
|
The absolute launcher path. |
required |
args
|
list[str]
|
The launcher's arguments. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The JSON entry for the config file. |
Source code in src/solidworks_mcp/setup/clients.py
ConfigFileError ¶
Bases: Exception
A client config file can't be read or safely changed.
EntryChange
dataclass
¶
What happened to the server entry in one client's config.
Attributes:
| Name | Type | Description |
|---|---|---|
location |
str
|
Where the entry lives (a file path, or a description). |
action |
str
|
|
backup |
Path | None
|
The copy made before writing, if a file was overwritten. |
previous |
str | None
|
For an |
JsonFileRegistrar ¶
Edits the solidworks entry in the client's JSON config file.
It also implements :class:OldEntryCleaner, since it can read the file.
Bind to a file-configured client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
Client
|
A client whose |
required |
Source code in src/solidworks_mcp/setup/registration.py
Methods:¶
apply ¶
Set or remove the entry in the file (see :func:set_entry).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entry
|
dict[str, Any] | None
|
The entry to write, or |
required |
dry_run
|
bool
|
Report what would change, and change nothing. |
required |
Returns:
| Type | Description |
|---|---|
EntryChange
|
What happened, with the backup made before writing. |
Source code in src/solidworks_mcp/setup/registration.py
old_entries ¶
List the file's older entries that start this server.
Returns:
| Type | Description |
|---|---|
list[tuple[str, str]]
|
|
Source code in src/solidworks_mcp/setup/registration.py
remove_entry ¶
Remove one entry from the file, with the same care as :meth:apply.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The entry's key. |
required |
dry_run
|
bool
|
Report what would change, and change nothing. |
required |
Returns:
| Type | Description |
|---|---|
EntryChange
|
What happened, with the backup made before writing. |
Source code in src/solidworks_mcp/setup/registration.py
OldEntryCleaner ¶
Bases: Protocol
Finds and removes older entries that start this same server.
Only registrars that can read their client's entries implement this. Claude Code's are held by its CLI, so it doesn't.
Methods:¶
old_entries ¶
List the older entries for this server.
Returns:
| Type | Description |
|---|---|
list[tuple[str, str]]
|
|
remove_entry ¶
Remove one entry by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The entry's key. |
required |
dry_run
|
bool
|
Report what would change, and change nothing. |
required |
Returns:
| Type | Description |
|---|---|
EntryChange
|
What happened. |
Source code in src/solidworks_mcp/setup/registration.py
Registrar ¶
Bases: Protocol
Changes a client's solidworks entry.
Methods:¶
apply ¶
Add or update entry, or remove the entry when it is None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entry
|
dict[str, Any] | None
|
The entry to write, or |
required |
dry_run
|
bool
|
Report what would change, and change nothing. |
required |
Returns:
| Type | Description |
|---|---|
EntryChange
|
What happened. |
Source code in src/solidworks_mcp/setup/registration.py
Functions:¶
launcher_name ¶
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 |
str
|
folder; |
Source code in src/solidworks_mcp/setup/legacy.py
old_entries ¶
Name every entry, besides solidworks, that starts this server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
servers
|
dict[str, Any]
|
A config's server entries ( |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Their names, in the config's order. |
Source code in src/solidworks_mcp/setup/legacy.py
registrar_for ¶
The registrar that knows how to configure client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
Client
|
A client from :func: |
required |
Returns:
| Type | Description |
|---|---|
Registrar
|
A file registrar for file-configured clients, else the Claude CLI one. |
Source code in src/solidworks_mcp/setup/registration.py
server_entries ¶
Read every server entry in a config, for inspection in code only.
Callers must not print the entries: they may hold other servers' secrets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
The JSON config file. |
required |
section
|
str
|
The object that holds the servers ( |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The entries by name; |
dict[str, Any]
|
section isn't an object. |
Source code in src/solidworks_mcp/setup/config_file.py
set_entry ¶
set_entry(path: Path, section: str, name: str, entry: dict[str, Any] | None, *, dry_run: bool = False) -> EntryChange
Set section.name to entry, or delete it when entry is None.
Every other key in the file keeps its value and order. Before writing, the file is backed up; it is then written atomically as UTF-8 without a BOM, and read back to confirm it parses and holds the new entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
The JSON config file; created, with its folder, if missing. |
required |
section
|
str
|
The object that holds the servers. |
required |
name
|
str
|
The server's key in that object. |
required |
entry
|
dict[str, Any] | None
|
The new entry, or |
required |
dry_run
|
bool
|
Work out the action but write nothing. |
False
|
Returns:
| Type | Description |
|---|---|
EntryChange
|
What happened (or, with |
Raises:
| Type | Description |
|---|---|
ConfigFileError
|
The file can't be parsed, the section isn't an object, or the written file doesn't hold the entry. |