dynmcp 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -102,6 +102,64 @@ When no `--` command is provided, `dynmcp` looks for a config file in this order
102
102
 
103
103
  MCP names (the keys in the config) must match `^[a-z0-9][a-z0-9-]*$`.
104
104
 
105
+ ## Environment Variable Interpolation
106
+
107
+ Config files can reference environment variables in any string-typed leaf value using shell-style syntax. This is useful for keeping secrets (bearer tokens, API keys) and host-specific values (paths, ports) out of the config file itself.
108
+
109
+ ```json
110
+ {
111
+ "mcp": {
112
+ "remote": {
113
+ "transport": "streamable-http",
114
+ "url": "${MCP_URL:-https://example.com/mcp}",
115
+ "headers": {
116
+ "Authorization": "Bearer ${MCP_TOKEN}"
117
+ }
118
+ }
119
+ }
120
+ }
121
+ ```
122
+
123
+ ### Syntax
124
+
125
+ | Form | Behavior |
126
+ |---|---|
127
+ | `${VAR}` | Replaced with the value of `VAR`. Hard error at startup if `VAR` is undefined. |
128
+ | `${VAR:-default}` | Replaced with `VAR` if set and non-empty, otherwise the literal `default` (may contain spaces, colons, etc.). |
129
+ | `$${...}` | Escape — emits a literal `${...}` with no interpolation. |
130
+
131
+ Interpolation only applies to **leaf string values** inside the `mcp` map (and nested objects/arrays within it). Map keys, the top-level `$schema` field, and the top-level `env` field are never interpolated. Partial-string interpolation works — `"Bearer ${TOKEN}"` is valid.
132
+
133
+ If any referenced variables are missing without a default, `dynmcp` exits at startup with an error listing **all** of them at once (not one at a time).
134
+
135
+ ### Sources (`env` field)
136
+
137
+ A top-level `env` field controls where variables are read from:
138
+
139
+ | Value | Behavior |
140
+ |---|---|
141
+ | `"enable"` (default) | Loads `.env` file (if present) and merges with `process.env`. `.env` values take precedence over `process.env` for the same key. |
142
+ | `"dotenv"` | Loads from `.env` file only. `process.env` is ignored. |
143
+ | `"process"` | Reads from `process.env` only. No `.env` file is loaded. |
144
+ | `"disable"` | Disables interpolation entirely — `${VAR}` is left literal. |
145
+
146
+ ```json
147
+ {
148
+ "env": "process",
149
+ "mcp": { /* ... */ }
150
+ }
151
+ ```
152
+
153
+ ### `.env` File Discovery
154
+
155
+ By default, `dynmcp` looks for a file literally named `.env` in the current working directory. To use a different path, pass `--env` / `-e`:
156
+
157
+ ```bash
158
+ dynmcp --env ./secrets.env
159
+ ```
160
+
161
+ Combining `--env` with `env: "disable"` or `env: "process"` is rejected as incoherent (no `.env` would be loaded). If `--env` points to a file that does not exist, `dynmcp` exits with an error.
162
+
105
163
  ## CLI Reference
106
164
 
107
165
  ```
@@ -113,6 +171,7 @@ dynmcp [options] [-- <upstream-command> [upstream-args...]]
113
171
  | `--version` | `-v` | Print the package version and exit |
114
172
  | `--help` | `-h` | Print usage information and exit |
115
173
  | `--config <path>` | `-c` | Path to config file (JSON or YAML) |
174
+ | `--env <path>` | `-e` | Path to a custom `.env` file for variable interpolation |
116
175
  | `--` | | Everything after is the upstream MCP command (single-MCP mode) |
117
176
 
118
177
  ### Mode Resolution