astrid-runtime/astrid · error

MCP attach workspace must be an absolute path: {}

Error message

MCP attach workspace must be an absolute path: {}

What it means

absolute_workspace normalizes the workspace path for the attach registration and requires it to be absolute before canonicalizing. A relative workspace argument (or an unset one whose current_dir lookup can't apply) is rejected so the daemon receives an unambiguous path.

Source

Thrown at crates/astrid-cli/src/commands/mcp/attach.rs:75

    stream
        .write_all(b"\n")
        .await
        .context("failed to terminate MCP attach registration")?;
    stream
        .flush()
        .await
        .context("failed to flush MCP attach registration")?;
    proxy_stdio(stream).await?;
    Ok(ExitCode::SUCCESS)
}

fn absolute_workspace(workspace: Option<&Path>) -> Result<PathBuf> {
    let path = workspace.map_or(
        std::env::current_dir().context("failed to read MCP attach cwd")?,
        PathBuf::from,
    );
    if !path.is_absolute() {
        anyhow::bail!(
            "MCP attach workspace must be an absolute path: {}",
            path.display()
        );
    }
    std::fs::canonicalize(&path)
        .with_context(|| format!("failed to resolve MCP attach workspace {}", path.display()))
}

fn build_registration(
    caller: &astrid_core::PrincipalId,
    workspace: Option<&Path>,
    ready: &super::lifecycle::GatewayReady,
) -> Result<AttachRegistration> {
    let host = std::env::var("ASTRID_HOST")
        .or_else(|_| std::env::var("AOS_MCP_HOST"))
        .or_else(|_| std::env::var("MCP_HOST"))
        .ok()
        .filter(|value| !value.trim().is_empty())

View on GitHub (pinned to affd8760f4)

Solutions

  1. Pass an absolute path: `aos mcp attach --workspace /home/me/project`
  2. Prefix the path with $(pwd) in scripts
  3. Check for a typo such as a missing leading '/' or '~' not expanded by the program

Example fix

// before
$ aos mcp attach --workspace ./myproject
// after
$ aos mcp attach --workspace "$(pwd)/myproject"
Defensive patterns

Strategy: validation

Validate before calling

let ws = workspace.unwrap_or_else(|| std::env::current_dir().unwrap());
assert!(ws.is_absolute(), "workspace must be absolute: {}", ws.display());

Type guard

fn is_absolute_ws(p: &Path) -> bool { p.is_absolute() }

Try / catch

match absolute_workspace(Some(&ws)) {
    Err(e) if e.to_string().contains("absolute path") => eprintln!("pass an absolute --workspace"),
    other => other,
}

Prevention

When it happens

Trigger: Passing a relative path (e.g. "." or "./ws") to `aos mcp attach --workspace` and the path failing path.is_absolute().

Common situations: Invoking the CLI from scripts with a relative directory; shell cwd differing from expectation; forgetting to convert a configured relative workspace to an absolute path.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/d469f73f60392754. Report an issue: GitHub.