Skip to content

Bridge API

Generic WebSocket bridge for non-Python DCCs. Implements the server-side of the dcc-mcp-core WebSocket JSON-RPC 2.0 bridge protocol.

Exported symbols: DccBridge, BridgeError, BridgeConnectionError, BridgeTimeoutError, BridgeRpcError

DccBridge

WebSocket bridge server that waits for a DCC plugin to connect.

Constructor

ParameterTypeDefaultDescription
hoststr"localhost"Bind address for the WebSocket server
portint9001Port for the WebSocket server
timeoutfloat30.0Default timeout in seconds for call()
server_namestr"dcc-mcp-server"Name advertised in the hello_ack handshake
server_versionstr | Nonepackage versionVersion advertised in hello_ack

Properties

PropertyTypeDescription
endpointstrWebSocket endpoint URL (e.g. "ws://localhost:9001")

Methods

MethodReturnsDescription
connect(wait_for_dcc=False)NoneStart the WebSocket server
call(method, **params)AnySynchronous RPC to the DCC plugin (thread-safe)
disconnect()NoneShut down the WebSocket server
is_connected()boolWhether a DCC plugin has completed the handshake
python
from dcc_mcp_core import DccBridge

# Context manager
with DccBridge(port=9001) as bridge:
    info = bridge.call("ps.getDocumentInfo")
    layers = bridge.call("ps.listLayers", include_hidden=True)

Exceptions

ExceptionParentDescription
BridgeErrorExceptionBase class for all DccBridge errors
BridgeConnectionErrorBridgeErrorDCC plugin not connected or connection lost
BridgeTimeoutErrorBridgeErrorCall timed out
BridgeRpcErrorBridgeErrorDCC plugin returned JSON-RPC error; attributes: .code, .message, .data

Released under the MIT License.