You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(config): add drop-in configuration support with dynamic reload
Add support for flexible configuration management through both main config files and drop-in directories
- Load config from --config (main file) and --config-dir (drop-in directory)
- Drop-in files processed in alphabetical order for predictable overrides
- Partial configuration support - drop-in files can override specific values
- Dynamic configuration reload via SIGHUP signal
- SIGHUP support requires either --config or --config-dir flag at startup
Signed-off-by: Nader Ziada <[email protected]>
|`--port`| Starts the MCP server in Streamable HTTP mode (path /mcp) and Server-Sent Event (SSE) (path /sse) mode and listens on the specified port . |
191
191
|`--log-level`| Sets the logging level (values [from 0-9](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/logging.md)). Similar to [kubectl logging levels](https://kubernetes.io/docs/reference/kubectl/quick-reference/#kubectl-output-verbosity-and-debugging). |
192
+
|`--config`| (Optional) Path to the main TOML configuration file. See [Drop-in Configuration](#drop-in-configuration) section below for details. |
193
+
|`--config-dir`| (Optional) Path to drop-in configuration directory. Files are loaded in lexical (alphabetical) order. See [Drop-in Configuration](#drop-in-configuration) section below for details. |
192
194
|`--kubeconfig`| Path to the Kubernetes configuration file. If not provided, it will try to resolve the configuration (in-cluster, default location, etc.). |
193
195
|`--list-output`| Output format for resource list operations (one of: yaml, table) (default "table") |
194
196
|`--read-only`| If set, the MCP server will run in read-only mode, meaning it will not allow any write operations (create, update, delete) on the Kubernetes cluster. This is useful for debugging or inspecting the cluster without making changes. |
195
197
|`--disable-destructive`| If set, the MCP server will disable all destructive operations (delete, update, etc.) on the Kubernetes cluster. This is useful for debugging or inspecting the cluster without accidentally making changes. This option has no effect when `--read-only` is used. |
196
198
|`--toolsets`| Comma-separated list of toolsets to enable. Check the [🛠️ Tools and Functionalities](#tools-and-functionalities) section for more information. |
197
199
|`--disable-multi-cluster`| If set, the MCP server will disable multi-cluster support and will only use the current context from the kubeconfig file. This is useful if you want to restrict the MCP server to a single cluster. |
The Kubernetes MCP server supports flexible configuration through both a main config file and drop-in files. **Both are optional** - you can use either, both, or neither (server will use built-in defaults).
204
+
205
+
#### Configuration Loading Order
206
+
207
+
Configuration values are loaded and merged in the following order (later sources override earlier ones):
2.**Main Configuration File** - Optional, loaded via `--config` flag
211
+
3.**Drop-in Files** - Optional, loaded from `--config-dir` in **lexical (alphabetical) order**
212
+
213
+
#### How Drop-in Files Work
214
+
215
+
-**File Naming**: Use numeric prefixes to control loading order (e.g., `00-base.toml`, `10-cluster.toml`, `99-override.toml`)
216
+
-**File Extension**: Only `.toml` files are processed; dotfiles (starting with `.`) are ignored
217
+
-**Partial Configuration**: Drop-in files can contain only a subset of configuration options
218
+
-**Merge Behavior**: Values present in a drop-in file override previous values; missing values are preserved
219
+
220
+
#### Dynamic Configuration Reload
221
+
222
+
To reload configuration after modifying config files, send a `SIGHUP` signal to the running server process.
223
+
224
+
**Prerequisite**: SIGHUP reload requires the server to be started with either the `--config` flag or `--config-dir` flag (or both). If neither is specified, SIGHUP signals will be ignored.
225
+
226
+
**How to reload:**
227
+
228
+
```shell
229
+
# Find the process ID
230
+
ps aux | grep kubernetes-mcp-server
231
+
232
+
# Send SIGHUP to reload configuration
233
+
kill -HUP <pid>
234
+
235
+
# Or use pkill
236
+
pkill -HUP kubernetes-mcp-server
237
+
```
238
+
239
+
The server will:
240
+
- Reload the main config file and all drop-in files
241
+
- Update configuration values (log level, output format, etc.)
242
+
- Rebuild the toolset registry with new tool configurations
243
+
- Log the reload status
244
+
245
+
**Note**: Changing `kubeconfig` or cluster-related settings requires a server restart. Only tool configurations, log levels, and output formats can be reloaded dynamically.
246
+
247
+
**Note**: SIGHUP reload is not available on Windows. On Windows, restart the server to reload configuration.
# Override only the toolsets - all other config preserved
270
+
toolsets = ["core", "config", "helm", "logs"]
271
+
```
272
+
273
+
**Example drop-in file** (`99-local.toml`):
274
+
```toml
275
+
# Local development overrides
276
+
log_level = 9
277
+
read_only = true
278
+
```
279
+
280
+
**To apply changes:**
281
+
```shell
282
+
# Edit config files
283
+
vim /etc/kubernetes-mcp-server/config.d/99-local.toml
284
+
285
+
# Reload without restarting
286
+
pkill -HUP kubernetes-mcp-server
287
+
```
288
+
199
289
## 🛠️ Tools and Functionalities <aid="tools-and-functionalities"></a>
200
290
201
291
The Kubernetes MCP server supports enabling or disabling specific groups of tools and functionalities (tools, resources, prompts, and so on) via the `--toolsets` command-line flag or `toolsets` configuration option.
0 commit comments