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
📚 docs: MCP server Dynamic User Field Placeholders (#326)
- Updated the `mcp_servers.mdx` and `agents.mdx` files to include dynamic user field placeholders for headers, URLs, and environment variables.
- Added detailed descriptions and examples for user field placeholders such as `{{LIBRECHAT_USER_EMAIL}}`, `{{LIBRECHAT_USER_ROLE}}`, and others.
- Improved clarity on the usage of environment variables and their integration with user-specific data.
Copy file name to clipboardExpand all lines: pages/docs/configuration/librechat_yaml/object_structure/mcp_servers.mdx
+57-4Lines changed: 57 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,7 @@ mcpServers:
56
56
['command', 'String', '(For `stdio` type) The command or executable to run to start the MCP server.', 'command: "npx"'],
57
57
['args', 'Array of Strings', '(For `stdio` type) Command line arguments to pass to the `command`.', 'args: ["-y", "@modelcontextprotocol/server-puppeteer"]'],
58
58
['url', 'String', '(For `websocket`, `streamable-http`, or `sse` type) The URL to connect to the MCP server.', 'url: "http://localhost:3001/sse"'],
59
-
['headers', 'Object', '(Optional, for `sse` and `streamable-http` types) Custom headers to send with the request. Supports user ID substitution with `{{LIBRECHAT_USER_ID}}` and environment variables with `${ENV_VAR}`.', 'headers:\n X-User-ID: "{{LIBRECHAT_USER_ID}}"\n X-API-Key: "${SOME_API_KEY}"'],
59
+
['headers', 'Object', '(Optional, for `sse` and `streamable-http` types) Custom headers to send with the request. Supports dynamic user field substitution with `{{LIBRECHAT_USER_*}}` placeholders and environment variables with `${ENV_VAR}`.', 'headers:\n X-User-ID: "{{LIBRECHAT_USER_ID}}"\n X-API-Key: "${SOME_API_KEY}"'],
60
60
['iconPath', 'String', '(Optional) Defines the tool\'s display icon shown in the tool selection dialog.', 'iconPath: "/path/to/icon.svg"'],
61
61
['chatMenu', 'Boolean', '(Optional) When set to `false`, excludes the MCP server from the chatarea dropdown (MCPSelect) for quick and easy access. Defaults to `true`.', 'chatMenu: false'],
62
62
['timeout', 'Number', '(Optional) Timeout in milliseconds for MCP server requests. Determines how long to wait for a response for tool requests.', 'timeout: 30000'],
@@ -85,7 +85,7 @@ mcpServers:
85
85
#### `url`
86
86
87
87
- **Type:** String
88
-
- **Description:** (For `websocket`, `streamable-http`, or `sse` type) The URL to connect to the MCP server.
88
+
- **Description:** (For `websocket`, `streamable-http`, or `sse` type) The URL to connect to the MCP server. Supports dynamic user field placeholders (`{{LIBRECHAT_USER_*}}`) and environment variable substitution (`${ENV_VAR}`).
89
89
- **Notes:**
90
90
- For `sse` type, the URL must start with `http://` or `https://`.
91
91
- For `streamable-http` type, the URL must start with `http://` or `https://`.
@@ -97,11 +97,38 @@ mcpServers:
97
97
- **Description:** Custom headers to send with the request.
98
98
- **Special Values:**
99
99
- `{{LIBRECHAT_USER_ID}}`: Will be replaced with the current user's ID, enabling multi-user support.
100
+
- `{{LIBRECHAT_USER_*}}`: Dynamic user field placeholders. Replace `*` with the UPPERCASE version of any allowed field.
100
101
- `${ENV_VAR}`: Will be replaced with the value of the environment variable `ENV_VAR`.
| `{{LIBRECHAT_USER_APPLEID}}` | `appleId` | String | Apple account ID |
120
+
| `{{LIBRECHAT_USER_EMAILVERIFIED}}` | `emailVerified` | Boolean → String | Email verification status ("true" or "false") |
121
+
| `{{LIBRECHAT_USER_TWOFACTORENABLED}}` | `twoFactorEnabled` | Boolean → String | 2FA status ("true" or "false") |
122
+
| `{{LIBRECHAT_USER_TERMSACCEPTED}}` | `termsAccepted` | Boolean → String | Terms acceptance status ("true" or "false") |
123
+
124
+
**Note:** Missing fields will be replaced with empty strings.
125
+
101
126
- **Example:**
102
127
```yaml
103
128
headers:
104
129
X-User-ID: "{{LIBRECHAT_USER_ID}}"
130
+
X-User-Email: "{{LIBRECHAT_USER_EMAIL}}"
131
+
X-User-Role: "{{LIBRECHAT_USER_ROLE}}"
105
132
X-API-Key: "${SOME_API_KEY}"
106
133
Authorization: "Bearer ${SOME_AUTH_TOKEN}"
107
134
```
@@ -120,7 +147,7 @@ mcpServers:
120
147
#### `env`
121
148
122
149
- **Type:** Object (Optional, `stdio` type only)
123
-
- **Description:** Environment variables to use when spawning the process.
150
+
- **Description:** Environment variables to use when spawning the process. Supports the same dynamic user field placeholders as headers (`{{LIBRECHAT_USER_*}}`) and environment variable substitution (`${ENV_VAR}`).
- `{{LIBRECHAT_USER_ROLE}}`- User's role (e.g., "user", "admin")
279
+
- And many more fields (see headers section for complete list)
232
280
- **User Idle Management:**
233
281
- User connections are monitored for activity and will be disconnected after 15 minutes of inactivity.
234
282
- **Environment Variables:**
235
283
- **In `env` (for `stdio` type):** Useful for setting up specific runtime environments or configurations required by the MCP server process.
236
284
- **In `headers` (for `sse` and `streamable-http` types):** Use `${ENV_VAR}` syntax to reference environment variables in header values.
285
+
- **Dynamic User Fields:**
286
+
- User field placeholders are replaced at runtime with the authenticated user's information
287
+
- Only non-sensitive fields are available (passwords and other sensitive data are excluded)
288
+
- Missing fields default to empty strings
289
+
- Boolean fields are converted to string representations ("true" or "false")
237
290
- **Error Handling (`stderr`):**
238
291
- Configuring `stderr` allows you to manage how error messages from the MCP server process are handled. The default `"inherit"` means that the errors will be printed to the parent process's `stderr`.
0 commit comments