The backend.py module#
Summary#
Create a token verifier that accepts exactly |
|
Check whether this process was spawned as a lane backend. |
|
Secure |
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:
- token
str Expected bearer token.
- token
- Returns:
fastmcp.server.auth.TokenVerifierVerifier using a constant-time comparison.
- backend.apply_lane_backend_hooks(app: fastmcp.FastMCP) bool#
Secure
appwith the lane token and apply the AEDT version fixes.
- 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.