solidworks_mcp.setup.handshake¶
solidworks_mcp.setup.handshake ¶
Start the server the way a client will and confirm it lists its tools.
This is the MCP stdio handshake a client performs: initialize, the
initialized notification, then tools/list. Setup runs it before
writing any config, so a broken launcher is caught here rather than as a
silent failure inside the client.
Attributes¶
_INITIALIZE
module-attribute
¶
_INITIALIZE = {'jsonrpc': '2.0', 'id': 1, 'method': 'initialize', 'params': {'protocolVersion': '2025-06-18', 'capabilities': {}, 'clientInfo': {'name': 'solidworks-mcp-setup', 'version': '1'}}}
_INITIALIZED
module-attribute
¶
Classes¶
HandshakeResult
dataclass
¶
The outcome of the start-up check.
Attributes:
| Name | Type | Description |
|---|---|---|
ok |
bool
|
Whether the server answered and listed at least one tool. |
tools |
int
|
How many tools it listed. |
message |
str
|
One line for the user. |
Functions:¶
_converse ¶
Send the handshake and read the two replies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process
|
Popen[bytes]
|
The started server, with piped stdin and stdout. |
required |
deadline
|
float
|
|
required |
Returns:
| Type | Description |
|---|---|
HandshakeResult
|
The check's outcome. |
Source code in src/solidworks_mcp/setup/handshake.py
_failed ¶
Describe a missing reply, with the exit code if the server has exited.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process
|
Popen[bytes]
|
The server process. |
required |
what
|
str
|
What it failed to do. |
required |
Returns:
| Type | Description |
|---|---|
HandshakeResult
|
A failed result. |
Source code in src/solidworks_mcp/setup/handshake.py
_line_reader ¶
Read stream line by line on a daemon thread.
A thread lets the reader wait with a timeout: readline on a pipe
blocks with no timeout of its own on Windows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stream
|
IO[bytes] | None
|
The server's stdout. |
required |
Returns:
| Type | Description |
|---|---|
_Lines
|
A queue of lines, ending with |
Source code in src/solidworks_mcp/setup/handshake.py
_response ¶
Wait for the JSON-RPC reply to request_id.
Lines that aren't JSON (a stray banner) and other messages (log notifications) are skipped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lines
|
_Lines
|
The server's stdout lines. |
required |
request_id
|
int
|
The |
required |
deadline
|
float
|
|
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
The reply, or |
Source code in src/solidworks_mcp/setup/handshake.py
_send ¶
Write one JSON-RPC message as a line on the server's stdin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
process
|
Popen[bytes]
|
The server process. |
required |
message
|
dict[str, Any]
|
The JSON-RPC message. |
required |
Source code in src/solidworks_mcp/setup/handshake.py
check_server ¶
Start command args and run the MCP handshake over its stdio.
The process is always killed afterwards. Its stderr goes to a temporary file: an unread pipe can fill up and stall the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
str
|
The launcher to start. |
required |
args
|
list[str]
|
Its arguments (setup passes |
required |
timeout
|
float
|
Seconds to wait for both replies, in total. |
90.0
|
Returns:
| Type | Description |
|---|---|
HandshakeResult
|
Whether it worked, the tool count and a message. |