qdk_chemistry.ui.workspace module

Bind a plugin MCP process to one explicit workspace.

qdk_chemistry.ui.workspace.current_workspace_root()[source]

Return the immutable workspace binding for this MCP process.

Return type:

Path | None

qdk_chemistry.ui.workspace.configure_workspace(path)[source]

Bind this process to one workspace for relative file resolution.

Parameters:

path (Path) – Absolute path to the workspace directory.

Return type:

dict[str, object]

Returns:

A mapping that confirms the binding and gives the resolved workspace root.

Raises:
  • OSError – If workspace storage directories cannot be created.

  • ValueError – If path is relative or does not identify a directory.

  • RuntimeError – If this process is already bound to a different workspace.

async qdk_chemistry.ui.workspace.bind_workspace(ctx, workspace_root=None)[source]

Bind this MCP process to the active workspace before other QDK tools.

Parameters:
  • ctx (Context) – MCP request context used to discover the client workspace when workspace_root is omitted.

  • workspace_root (str | None) – Absolute workspace directory. When omitted, the client must provide exactly one file URI workspace root.

Return type:

dict[str, object]

Returns:

A mapping that reports whether binding succeeded. Successful results include the resolved workspace root and binding source; failed results include an error message.

async qdk_chemistry.ui.workspace.workspace_binding_middleware(context, call_next)[source]

Require a workspace binding before plugin tools resolve relative paths.

Parameters:
  • context (ServerRequestContext[Any, Any]) – Incoming MCP request context.

  • call_next (Callable[[ServerRequestContext[Any, Any]], Awaitable[BaseModel | dict[str, Any] | None]]) – Handler that receives the request after binding succeeds.

Return type:

BaseModel | dict[str, Any] | None

Returns:

The downstream handler result.

Raises:

RuntimeError – If binding is required but neither an existing binding nor a single client workspace root is available.