BackendClient#

class ansys.aedt.mcp.lanes.client.BackendClient(port: int, host: str = '127.0.0.1', path: str = DEFAULT_PATH, auth_token: str | None = None)#

MCP client bound to one lane backend.

Use it as an async context manager:

>>> async with BackendClient(port=8090, auth_token=token) as backend:
...     port = await backend.discover_aedt_port()
Parameters:
portint

HTTP port of the lane.

hoststr, default: “127.0.0.1”

Host of the lane.

pathstr, default: “/mcp/”

MCP endpoint path.

auth_tokenstr, optional

Bearer token of the lane.

Overview#

call

Call a tool on the lane.

check_status

Return the parsed check_aedt_status payload.

discover_aedt_port

Return the gRPC port of the AEDT session the lane is connected to.

connect_aedt

Connect the lane to an existing AEDT session.

url

__aenter__

Open the MCP session.

__aexit__

Close the MCP session.

Import detail#

from ansys.aedt.mcp.lanes.client import BackendClient

Attribute detail#

BackendClient.url#

Method detail#

async BackendClient.__aenter__() → BackendClient#

Open the MCP session.

async BackendClient.__aexit__(exc_type: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) → None#

Close the MCP session.

async BackendClient.call(tool_name: str, arguments: dict[str, Any] | None = None) → str#

Call a tool on the lane.

Parameters:
tool_namestr

Tool name.

argumentsdict[str, Any], optional

Tool arguments.

Returns:
str

Text payload of the result.

Raises:
BackendAuthError

If the lane rejected the token.

RuntimeError

If the client is not open or the call fails.

async BackendClient.check_status() → dict[str, Any]#

Return the parsed check_aedt_status payload.

Returns:
dict[str, Any]

Status payload, or {"raw": text} when the lane returned plain text.

async BackendClient.discover_aedt_port() → int | None#

Return the gRPC port of the AEDT session the lane is connected to.

Returns:
int or None

AEDT gRPC port, or None when the lane is not connected.

async BackendClient.connect_aedt(port: int, non_graphical: bool = True) → str#

Connect the lane to an existing AEDT session.

Parameters:
portint

AEDT gRPC port.

non_graphicalbool, default: True

Whether the session runs without a UI.

Returns:
str

Output of connect_to_aedt.