Skip to content

Commit 1010883

Browse files
committed
docs: update documentation for universal ${} placeholder syntax support
1 parent 7752efc commit 1010883

File tree

3 files changed

+39
-23
lines changed

3 files changed

+39
-23
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ MCP Hub is a MCP client for neovim that seamlessly integrates [MCP (Model Contex
6565
| **Marketplace** ||||
6666
| | Server Discovery || Browse from verified MCP servers |
6767
| | Installation || Manual and auto install with AI |
68+
| **Configuration** ||||
69+
| | Universal `${}` Syntax || Environment variables and command execution across all fields |
6870
| **Advanced** ||||
6971
| | Smart File-watching || Smart updates with config file watching |
7072
| | Multi-instance || All neovim instances stay in sync |

doc/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ Like any MCP client, MCP Hub requires a configuration file to define the MCP ser
9191
| **Marketplace** ||||
9292
| | Server Discovery || Browse from verified MCP servers |
9393
| | Installation || Manual and auto install with AI |
94+
| **Configuration** ||||
95+
| | Universal `${}` Syntax || Environment variables and command execution across all fields |
9496
| **Advanced** ||||
9597
| | Smart File-watching || Smart updates with config file watching |
9698
| | Multi-instance || All neovim instances stay in sync |
@@ -105,3 +107,4 @@ Like any MCP client, MCP Hub requires a configuration file to define the MCP ser
105107

106108

107109

110+

doc/mcp/servers_json.md

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
MCPHub.nvim like other MCP clients uses a JSON configuration file to manage MCP servers. This `config` file is located at `~/.config/mcphub/servers.json` by default and supports real-time updates across all Neovim instances. You can set `config` option to a custom location.
44

55
> [!NOTE]
6-
> You can use a single config file for any MCP client like VSCode, Cursor, Cline, Zed etc as long as the config file follows the below structure. With MCPHub.nvim, `config` file can be safely added to source control as it allows some special placeholder values in the `env` and `headers` fields on MCP Servers.
6+
> You can use a single config file for any MCP client like VSCode, Cursor, Cline, Zed etc as long as the config file follows the below structure. With MCPHub.nvim, `config` file can be safely added to source control as it supports **universal `${}` placeholder syntax** for environment variables and command execution across all configuration fields.
77
88
## Manage Servers
99

@@ -53,34 +53,50 @@ The `config` file should have a `mcpServers` key. This contains `stdio` and `rem
5353
{
5454
"mcpServers": {
5555
"local-server": {
56-
"command": "uvx",
57-
"args": ["mcp-server-fetch"]
56+
"command": "${MCP_BINARY_PATH}/server",
57+
"args": [
58+
"--token", "${API_TOKEN}",
59+
"--secret", "${cmd: op read op://vault/secret}"
60+
],
61+
"env": {
62+
"API_TOKEN": "${cmd: aws ssm get-parameter --name /app/token --query Parameter.Value --output text}",
63+
"DB_URL": "postgresql://user:${DB_PASSWORD}@localhost/myapp",
64+
"DB_PASSWORD": "password123",
65+
"FALLBACK_VAR": null
66+
}
5867
}
5968
}
6069
}
6170
```
6271

6372
##### Required fields:
64-
- `command`: The executable to start the server
73+
- `command`: The executable to start the server (supports `${VARIABLE}` and `${cmd: command}`)
6574

6675
##### Optional fields:
67-
- `args`: Array of command arguments
68-
- `env`: Optional environment variables
76+
- `args`: Array of command arguments (supports `${VARIABLE}` and `${cmd: command}` placeholders)
77+
- `env`: Environment variables with placeholder resolution and system fallback
6978
- `dev`: Development mode configuration for auto-restart on file changes
7079
- `name`: Display name that will be shown in the UI
7180
- `description`: Short description about the server (useful when the server is disabled and `auto_toggle_mcp_servers` is `true`)
7281

73-
##### `env` Special Values
82+
##### Universal `${}` Placeholder Syntax
83+
84+
**All fields** support the universal placeholder syntax:
85+
- **`${ENV_VAR}`** - Resolves environment variables
86+
- **`${cmd: command args}`** - Executes commands and uses output
87+
- **`null` or `""`** - Falls back to `process.env`
7488

75-
The `env` field supports several special values. Given `API_KEY=secret` in the environment:
89+
Given `API_KEY=secret` in the environment:
7690

7791
| Example | Becomes | Description |
7892
|-------|---------|-------------|
7993
| `"API_KEY": ""` | `"API_KEY": "secret"` | Empty string falls back to `process.env.API_KEY` |
80-
| `"API_KEY": null` | `"SERVER_URL": "secret"` | `null` falls back to `process.env.API_KEY` |
81-
| `"AUTH": "Bearer ${API_KEY}"` | `"AUTH": "Bearer secret"` | `${}` Placeholder values are also replaced |
82-
| `"TOKEN": "$: cmd:op read op://example/token"` | `"TOKEN": "secret"` | Values starting with `$: ` will be executed as shell command |
83-
| `"HOME": "/home/ubuntu"` | `"HOME": "/home/ubuntu"` | Used as-is |
94+
| `"API_KEY": null` | `"API_KEY": "secret"` | `null` falls back to `process.env.API_KEY` |
95+
| `"AUTH": "Bearer ${API_KEY}"` | `"AUTH": "Bearer secret"` | `${}` Placeholder values are replaced |
96+
| `"TOKEN": "${cmd: op read op://vault/token}"` | `"TOKEN": "secret"` | Commands are executed and output used |
97+
| `"HOME": "/home/ubuntu"` | `"HOME": "/home/ubuntu"` | Used as-is |
98+
99+
> ⚠️ **Legacy Syntax**: `$VAR` (args) and `$: command` (env) are deprecated but still supported with warnings. Use `${VAR}` and `${cmd: command}` instead.
84100
85101
##### `dev` Development Mode
86102

@@ -136,30 +152,25 @@ MCPHub supports both `streamable-http` and `sse` remote servers.
136152
{
137153
"mcpServers": {
138154
"remote-server": {
139-
"url": "https://api.example.com/mcp",
155+
"url": "https://${PRIVATE_DOMAIN}/mcp",
140156
"headers": {
141-
"Authorization": "Bearer ${API_KEY}"
157+
"Authorization": "Bearer ${cmd: op read op://vault/api/token}",
158+
"X-Custom-Header": "${CUSTOM_VALUE}"
142159
}
143160
}
144161
}
145162
}
146163
```
147164

148165
##### Required fields:
149-
- `url`: Remote server endpoint
166+
- `url`: Remote server endpoint (supports `${VARIABLE}` and `${cmd: command}` placeholders)
150167

151168
##### Optional fields:
152-
- `headers`: Optional authentication headers
169+
- `headers`: Authentication headers (supports `${VARIABLE}` and `${cmd: command}` placeholders)
153170
- `name`: Display name that will be shown in the UI
154171
- `description`: Short description about the server (useful when the server is disabled and `auto_toggle_mcp_servers` is `true`)
155172

156-
##### `headers` Special Values
157-
158-
The `headers` field supports `${...}` Placeholder values. Given `API_KEY=secret` in the environment:
159-
160-
| Example | Becomes | Description |
161-
|-------|-------------|---------|
162-
| `"Authorization": "Bearer ${API_KEY}"` |`"AUTH": "Bearer secret"` | `${}` Placeholder values are replaced |
173+
> **Note**: Remote servers use the same universal `${}` placeholder syntax as local servers. See the Universal Placeholder Syntax section above for full details.
163174
164175
## MCPHub Specific Fields
165176

0 commit comments

Comments
 (0)