The backend.py module#

Summary#

make_verifier

Create a token verifier that accepts exactly token.

is_lane_backend

Check whether this process was spawned as a lane backend.

apply_lane_backend_hooks

Secure app with the lane token and apply the AEDT version fixes.

TOKEN_ENV

Environment variable holding the lane bearer token.

CLIENT_ID

Client ID attached to requests authenticated with the lane token.

Description#

Hooks that turn a regular HTTP server into a token-protected lane backend.

The lane spawner starts python -m ansys.aedt.mcp --transport http ... with a per-lane secret in TOKEN_ENV. When server.launcher finds that variable, it calls apply_lane_backend_hooks(). That function:

  • removes the secret from the environment so AEDT and any other child process never inherit it,

  • requires the lane bearer token on every HTTP request, and

  • applies the PyAEDT version fixes from aedt_compat.

Without the variable, the server behaves exactly as before.

Module detail#

backend.make_verifier(token: str) → fastmcp.server.auth.TokenVerifier#

Create a token verifier that accepts exactly token.

Parameters:
tokenstr

Expected bearer token.

Returns:
fastmcp.server.auth.TokenVerifier

Verifier using a constant-time comparison.

backend.is_lane_backend() → bool#

Check whether this process was spawned as a lane backend.

Returns:
bool

True if TOKEN_ENV is set.

backend.apply_lane_backend_hooks(app: fastmcp.FastMCP) → bool#

Secure app with the lane token and apply the AEDT version fixes.

Parameters:
appfastmcp.FastMCP

Server about to run as a lane backend.

Returns:
bool

True if the hooks were applied, False if TOKEN_ENV is not set.

backend.TOKEN_ENV = 'ANSYS_AEDT_MCP_LANE_TOKEN'#

Environment variable holding the lane bearer token.

backend.CLIENT_ID = 'ansys-aedt-mcp-lanes'#

Client ID attached to requests authenticated with the lane token.