Repository navigation
Description
Summary
Every infer mcp command that saves mcp.yaml writes the file back with each ${VAR} reference replaced by the variable's value, or by nothing when it is unset. A header written as x-api-key: ${AGENTMAIL_API_KEY} turns into the plain key on disk, readable by anyone who can read the file, and the reference is gone for every later run.
LoadMCP reads the file through configutils.LoadYAML, which runs os.ExpandEnv over the whole text before unmarshalling. That is right for running, since a server's headers must hold the values. But CreateEntry, UpdateEntry and DeleteEntry, behind add, update, remove, enable and disable, save that same expanded config with SaveMCP, and so do enable-global and disable-global. SaveYAML also writes the file with mode 0644.
The same round trip, LoadYAML then SaveYAML, loads and saves agents.yaml (whose environment values may be ${VAR} references), keybindings.yaml and plugins.yaml. compute.yaml already avoids it: LoadComputeFile reads without expansion, so infer compute edits keep ${VAR}.
Found while building the desktop's MCPs tab (inference-gateway/desktop#480), which edits mcp.yaml itself to keep references intact. Hosted servers with headers come from #1757.
Steps to Reproduce
-
Write a server whose header is a reference:
# ~/.infer/mcp.yaml enabled: true servers: - name: hosted enabled: true url: http://127.0.0.1:9/mcp headers: x-api-key: ${MCP_CHECK_KEY}
-
Run
MCP_CHECK_KEY=fake-secret-value infer mcp disable hosted. -
Read the file:
grep x-api-key ~/.infer/mcp.yaml.
Expected Behavior
x-api-key: ${MCP_CHECK_KEY}. A command that edits the file changes the entry it was asked to change and writes every other value as it was written, references included. infer mcp start, stop and status, which do not save, already leave the file as written.
Actual Behavior
x-api-key: fake-secret-value. With MCP_CHECK_KEY unset, the header is written empty instead, and from then on the MCP supervisor skips the server as one with an unresolved header.
Acceptance Criteria
-
infer mcp add,update,remove,enable,disable,enable-globalanddisable-globalkeep every${VAR}reference inmcp.yamlas written. Running keeps expanding them as today. -
infer agentscommands that saveagents.yamlkeep${VAR}references inenvironmentthe same way, and so does every other config that is loaded withLoadYAMLand saved withSaveYAML. - Files that can hold secrets after an edit are written with mode 0600, or the save keeps the file's existing mode.
- A test edits a file holding a
${VAR}reference with that variable set, and asserts the reference survives.
Activity
inference-gateway-releaser commentedon Nov 9, 2026
🎉 This issue has been resolved in version 0.250.0 🎉
The release is available on:
Your semantic-release bot 📦🚀