|
| 1 | +# Daemon Configuration |
| 2 | + |
| 3 | +## Global Configuration |
| 4 | + |
| 5 | +!!! info "Precedence" |
| 6 | + The order of precedence for these options is: |
| 7 | + `CLI flag > configuration file > default value` |
| 8 | + |
| 9 | +The `mcpd daemon` command supports persistent configuration through configuration files and CLI commands. |
| 10 | +This allows you to configure API server settings, [CORS](https://developer.mozilla.org/en-US/docs/Glossary/CORS) policies, |
| 11 | +and various timeout values that persist across daemon restarts. |
| 12 | + |
| 13 | +The daemon configuration is managed using the following commands: |
| 14 | + |
| 15 | +- `mcpd config daemon get [key]` - Retrieve configuration values |
| 16 | +- `mcpd config daemon set <key=value>` - Set configuration values |
| 17 | +- `mcpd config daemon remove <key>` - Remove configuration values |
| 18 | +- `mcpd config daemon list` - List currently configured and all available configuration keys |
| 19 | +- `mcpd config daemon validate` - Validate current configuration |
| 20 | + |
| 21 | +For further information please check visit our [CLI Overview](/mcpd/commands/mcpd). |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +## Configuration Structure |
| 26 | + |
| 27 | +The daemon configuration is organized into two main sections: |
| 28 | + |
| 29 | +### API Configuration (`api.*`) |
| 30 | + |
| 31 | +Controls the HTTP API server settings. |
| 32 | + |
| 33 | +| Setting | Type | Description | Default | Example | |
| 34 | +|------------------------|------------|---------------------------------|----------------|------------------| |
| 35 | +| `api.addr` | `string` | Server bind address (host:port) | `0.0.0.0:8090` | `localhost:8080` | |
| 36 | +| `api.timeout.shutdown` | `duration` | Graceful shutdown timeout | `30s` | `60s` | |
| 37 | + |
| 38 | +#### CORS Configuration (`api.cors.*`) |
| 39 | + |
| 40 | +Cross-Origin Resource Sharing settings for browser clients. |
| 41 | + |
| 42 | +| Setting | Type | Description | Default | Example | |
| 43 | +|------------------------------|------------|-------------------------------|-------------------------------------|-------------------------------------------------| |
| 44 | +| `api.cors.enable` | `bool` | Enable CORS support | `false` | `true` | |
| 45 | +| `api.cors.allow_origins` | `[]string` | Allowed request origins | `["*"]` | `["localhost:3000", "https://app.example.com"]` | |
| 46 | +| `api.cors.allow_methods` | `[]string` | Allowed HTTP methods | `["GET", "POST", "PUT", "DELETE"]` | `["GET", "POST"]` | |
| 47 | +| `api.cors.allow_headers` | `[]string` | Allowed request headers | `["Content-Type", "Authorization"]` | `["Content-Type", "API-Key"]` | |
| 48 | +| `api.cors.expose_headers` | `[]string` | Headers exposed to client | `[]` | `["ETag", "Last-Modified"]` | |
| 49 | +| `api.cors.allow_credentials` | `bool` | Allow credentials in requests | `false` | `true` | |
| 50 | +| `api.cors.max_age` | `duration` | Preflight cache duration | `0s` | `24h` | |
| 51 | + |
| 52 | +### MCP Configuration (`mcp.*`) |
| 53 | + |
| 54 | +Model Context Protocol server management settings. |
| 55 | + |
| 56 | +| Setting | Type | Description | Default | Example | |
| 57 | +|------------------------|------------|-------------------------------|---------|---------| |
| 58 | +| `mcp.timeout.init` | `duration` | Server initialization timeout | `30s` | `60s` | |
| 59 | +| `mcp.timeout.shutdown` | `duration` | Server shutdown timeout | `10s` | `30s` | |
| 60 | +| `mcp.timeout.health` | `duration` | Health check timeout | `5s` | `10s` | |
| 61 | +| `mcp.interval.health` | `duration` | Health check interval | `30s` | `60s` | |
| 62 | + |
| 63 | +## Configuration Examples |
| 64 | + |
| 65 | +### Basic API Configuration |
| 66 | + |
| 67 | +```bash |
| 68 | +# Set server address |
| 69 | +mcpd config daemon set api.addr="localhost:8080" |
| 70 | + |
| 71 | +# Configure shutdown timeout |
| 72 | +mcpd config daemon set api.timeout.shutdown="60s" |
| 73 | +``` |
| 74 | + |
| 75 | +### CORS Configuration |
| 76 | + |
| 77 | +```bash |
| 78 | +# Enable CORS |
| 79 | +mcpd config daemon set api.cors.enable=true |
| 80 | + |
| 81 | +# Set allowed origins |
| 82 | +mcpd config daemon set api.cors.allow_origins="localhost:3000,https://app.example.com" |
| 83 | + |
| 84 | +# Allow credentials |
| 85 | +mcpd config daemon set api.cors.allow_credentials=true |
| 86 | + |
| 87 | +# Set preflight cache duration |
| 88 | +mcpd config daemon set api.cors.max_age="24h" |
| 89 | +``` |
| 90 | + |
| 91 | +### MCP Server Configuration |
| 92 | + |
| 93 | +```bash |
| 94 | +# Set longer initialization timeout |
| 95 | +mcpd config daemon set mcp.timeout.init="60s" |
| 96 | + |
| 97 | +# Configure health check frequency |
| 98 | +mcpd config daemon set mcp.interval.health="60s" |
| 99 | + |
| 100 | +# Set health check timeout |
| 101 | +mcpd config daemon set mcp.timeout.health="10s" |
| 102 | +``` |
| 103 | + |
| 104 | +### Retrieving Configuration |
| 105 | + |
| 106 | +```bash |
| 107 | +# Get all configuration |
| 108 | +mcpd config daemon get |
| 109 | + |
| 110 | +# Get API configuration only |
| 111 | +mcpd config daemon get api |
| 112 | + |
| 113 | +# Get specific setting |
| 114 | +mcpd config daemon get api.cors.enable |
| 115 | + |
| 116 | +# List all configured keys |
| 117 | +mcpd config daemon list |
| 118 | + |
| 119 | +# List all available keys |
| 120 | +mcpd config daemon list --available |
| 121 | +``` |
| 122 | + |
| 123 | +### Removing Configuration |
| 124 | + |
| 125 | +```bash |
| 126 | +# Remove a specific setting (reverts to default) |
| 127 | +mcpd config daemon remove api.cors.enable |
| 128 | + |
| 129 | +# Remove entire section |
| 130 | +mcpd config daemon remove api.cors |
| 131 | + |
| 132 | +# Remove multiple settings |
| 133 | +mcpd config daemon remove api.cors.enable api.cors.max_age |
| 134 | +``` |
| 135 | + |
| 136 | +## Configuration File Storage |
| 137 | + |
| 138 | +Configuration is stored in the `.mcpd.toml` file in TOML format: |
| 139 | + |
| 140 | +```toml |
| 141 | +[[servers]] |
| 142 | + name = "time" |
| 143 | + package = "uvx::[email protected]" |
| 144 | + tools = ["get_current_time", "convert_time"] |
| 145 | + |
| 146 | +[daemon] |
| 147 | + [daemon.api] |
| 148 | + addr = "localhost:8080" |
| 149 | + [daemon.api.timeout] |
| 150 | + shutdown = "1m0s" |
| 151 | + [daemon.api.cors] |
| 152 | + enable = true |
| 153 | + allow_origins = ["localhost:3000", "https://app.example.com"] |
| 154 | + allow_credentials = true |
| 155 | + max_age = "24h0m0s" |
| 156 | + [daemon.mcp] |
| 157 | + [daemon.mcp.timeout] |
| 158 | + shutdown = "30s" |
| 159 | + init = "1m0s" |
| 160 | + health = "10s" |
| 161 | + [daemon.mcp.interval] |
| 162 | + health = "1m0s" |
| 163 | +``` |
| 164 | + |
| 165 | +## Data Types |
| 166 | + |
| 167 | +### Duration Format |
| 168 | + |
| 169 | +Duration values follow this time/duration format: |
| 170 | + |
| 171 | +- `30s` - 30 seconds |
| 172 | +- `5m` - 5 minutes |
| 173 | +- `2h` - 2 hours |
| 174 | +- `1m30s` - 1 minute 30 seconds |
| 175 | + |
| 176 | +### String Arrays |
| 177 | + |
| 178 | +String arrays can be provided as comma-separated values: |
| 179 | +```bash |
| 180 | +mcpd config daemon set api.cors.allow_origins "localhost:3000,https://app.example.com" |
| 181 | +``` |
| 182 | + |
| 183 | +### Boolean Values |
| 184 | + |
| 185 | +Boolean values should use: `true`, `false`. |
| 186 | + |
| 187 | +## Configuration Validation |
| 188 | + |
| 189 | +Use the `validate` command to check your configuration: |
| 190 | + |
| 191 | +```bash |
| 192 | +mcpd config daemon validate |
| 193 | +``` |
| 194 | + |
| 195 | +Common validation errors: |
| 196 | +- Invalid address formats (must be `host:port`) |
| 197 | +- Invalid duration formats |
| 198 | +- Invalid CORS origin URLs |
0 commit comments