Skip to content

[Bug] Optional env vars are set to empty strings, should be omitted #611

@danbarr

Description

@danbarr

Bug Description

I encountered this with the buildkite MCP but it could be impacting others.

It has an optional env var, which expects an integer value. When I run this MCP via the UI, and don't enter anything for that env, the UI is apparently setting this environment variable anyway, but to an empty string.

Instead, the var just shouldn't be set.

Steps to Reproduce

  1. Run the buildkite MCP from the registry - enter anything for the required API key secret, it doesn't need to be valid. Also, enter stdio for the command args (to work around [Bug] UI is not passing default args defined in registry #610)
  2. Note the server stays in "Starting state"
  3. Get the logs and note the error:
buildkite-mcp-server: error: --job-log-token-threshold: expected a valid 64 bit int but got "" (from envar JOB_LOG_TOKEN_THRESHOLD="")
Usage: buildkite-mcp-server stdio [flags]
  1. Inspect the container's environment and note JOB_LOG_TOKEN_THRESHOLD:
$ docker inspect buildkite | jq ".[].Config.Env"
[
  "MCP_TRANSPORT=stdio",
  "JOB_LOG_TOKEN_THRESHOLD=",
  "BUILDKITE_API_TOKEN=fakevalue",
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:/ko-app",
  "SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt",
  "KO_DATA_PATH=/var/run/ko"
]

Expected Behavior

Env vars that the user doesn't provide a value for shouldn't be set on the container. In the case of buildkite, JOB_LOG_TOKEN_THRESHOLD should not get set.

Running this same MCP from the CLI, we can see it doesn't get set:

$ docker inspect buildkite | jq ".[].Config.Env"
[
  "BUILDKITE_API_TOKEN=fakevalue",
  "MCP_TRANSPORT=stdio",
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:/ko-app",
  "SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt",
  "KO_DATA_PATH=/var/run/ko"
]

Actual Behavior

The env var is being set with an empty value. This can cause MCPs to fail if they validate based on an expected type or format.

Priority

Medium

Environment

No response

Additional Context

No response

Metadata

Metadata

Assignees

Labels

BugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions