Chroma MCP: .env file ignored (set CHROMA_DOTENV_PATH to the absolute path)
Fixes the Chroma MCP server ignoring environment variables because the dotenv file is not loaded. The server reads a .env file only from the path in CHROMA_DOTENV_PATH (default .chroma_env in the working directory), and the MCP server's working directory is not yours. The fix is setting CHROMA_DOTENV_PATH to the absolute file path. Use when env vars work in the shell but not under the MCP client; not for wrong values.
TL;DR: Your .env file is not being read because the MCP server looks for it in its own working directory, not yours. Set CHROMA_DOTENV_PATH to the absolute path of your .env file, or put the variables directly in the client config env block.
(env vars silently ignored; server behaves as if CHROMA_HOST etc. were unset)Fix it
- Option A, absolute dotenv path. In the client config
envblock:
{
"env": {
"CHROMA_DOTENV_PATH": "[HOME]/..."
}
}- Option B, skip the file. Put the variables directly in the
envblock:
{
"env": {
"CHROMA_CLIENT_TYPE": "http",
"CHROMA_HOST": "YOUR_CHROMA_HOST",
"CHROMA_PORT": "8000"
}
}- Restart the MCP client.
Expected: the server picks up the configured values. Connection succeeds.
When to use this
- Variables in
.envwork when you run the server by hand but are ignored under the MCP client. - The server behaves as if no configuration was given.
When NOT to use this
- The values are wrong. A loaded-but-wrong value fails differently (auth errors, connection refused to the wrong host).
- You already use the
envblock. Then the file is irrelevant.
Compatibility
- chroma-mcp with dotenv support.
Why it happens
Relative dotenv paths resolve against the process working directory. Your terminal's directory and the MCP server's directory are different things (GUI clients often use the app bundle or system root). The default .chroma_env lookup misses, the server falls back to defaults, and nothing tells you the file was skipped.
Edge cases
- The dotenv path itself must be absolute. A relative
CHROMA_DOTENV_PATHhas the same problem one level up. - Command-line args beat env vars beat dotenv. If both are set, args win. Check for conflicts.
- Secrets in a
.envfile are still secrets. Keep the file out of git.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.