Skip to content

MCP env var expansion misses ${VAR} brace syntax #1612

@bungles411

Description

@bungles411

Description

The expandEnvVarsInRecord function in packages/providers/src/claude/provider.ts (line 222) uses a regex that only matches $VAR syntax but not the more explicit ${VAR} brace syntax.

Current regex:

val.replace(/\$([A-Z_][A-Z0-9_]*)/g, ...)

Problem: MCP config files commonly use ${VAR} notation (standard in shell, Docker, and most templating systems). When users write:

{
  "my-server": {
    "env": {
      "API_KEY": "${MY_API_KEY}"
    }
  }
}

The braces are left in the expanded value, producing {actual_value} instead of actual_value.

Proposed Fix

Update the regex to handle both forms:

val.replace(/\$(?:\{([A-Z_][A-Z0-9_]*)\}|([A-Z_][A-Z0-9_]*))/g, (_, braced, bare) => {
  const varName = braced ?? bare;
  const envVal = process.env[varName];
  if (envVal === undefined) {
    missingVars.push(varName);
  }
  return envVal ?? '';
});

Environment

  • OS: Windows 11
  • Archon: v0.3.10 (dev branch)
  • Node: via Bun runtime

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions