MCP Servers Object Structure
Example
MCP Servers Object Structure
# Example MCP Servers Object Structure
mcpServers:
everything:
# type: sse # type can optionally be omitted
url: http://localhost:3001/sse
puppeteer:
type: stdio
command: npx
args:
- -y
- "@modelcontextprotocol/server-puppeteer"
filesystem:
# type: stdio
command: npx
args:
- -y
- "@modelcontextprotocol/server-filesystem"
- /home/user/LibreChat/
iconPath: /home/user/LibreChat/client/public/assets/logo.svg
mcp-obsidian:
command: npx
args:
- -y
- "mcp-obsidian"
- /path/to/obsidian/vault
<serverName>
Key:
Key | Type | Description | Example |
---|---|---|---|
<serverName> | Object | Each key under `mcpServers` represents an individual MCP server configuration, identified by a unique name. This name is used to reference the server configuration within the application. |
Subkeys
Key | Type | Description | Example |
---|---|---|---|
type | String | Specifies the connection type to the MCP server. Valid options are `"stdio"`, `"websocket"`, or `"sse"`. If omitted, it defaults based on the presence and format of `url` or `command`. | type: "stdio" |
command | String | (For `stdio` type) The command or executable to run to start the MCP server. | command: "npx" |
args | Array of Strings | (For `stdio` type) Command line arguments to pass to the `command`. | args: ["-y", "@modelcontextprotocol/server-puppeteer"] |
url | String | (For `websocket` or `sse` type) The URL to connect to the MCP server. | url: "http://localhost:3001/sse" |
iconPath | String | (Optional) Defines the tool's display icon shown in the tool selection dialog. | iconPath: "/path/to/icon.svg" |
env | Object | (Optional, `stdio` type only) Environment variables to use when spawning the process. | env: NODE_ENV: "production" |
stderr | String or Stream or Number | (Optional, `stdio` type only) How to handle `stderr` of the child process. Defaults to `"inherit"`. | stderr: "inherit" |
type
- Type: String
- Description: Specifies the connection type to the MCP server. Valid options are
"stdio"
,"websocket"
, or"sse"
. - Default Value: Determined based on the presence and format of
url
orcommand
.
command
- Type: String
- Description: (For
stdio
type) The command or executable to run to start the MCP server.
args
- Type: Array of Strings
- Description: (For
stdio
type) Command line arguments to pass to thecommand
.
url
- Type: String
- Description: (For
websocket
orsse
type) The URL to connect to the MCP server. - Notes:
- For
sse
type, the URL must start withhttp://
orhttps://
. - For
websocket
type, the URL must start withws://
orwss://
.
- For
iconPath
- Type: String (Optional)
- Description: Defines the tool’s display icon shown in the tool selection dialog.
env
- Type: Object (Optional,
stdio
type only) - Description: Environment variables to use when spawning the process.
stderr
- Type: String or Stream or Number (Optional,
stdio
type only) - Description: How to handle
stderr
of the child process. This matches the semantics of Node’schild_process.spawn
. - Default Value:
"inherit"
(messages tostderr
will be printed to the parent process’sstderr
).
Notes
- Type Inference:
- If
type
is omitted:- If
url
is specified and starts withhttp://
orhttps://
,type
defaults tosse
. - If
url
is specified and starts withws://
orwss://
,type
defaults towebsocket
. - If
command
is specified,type
defaults tostdio
.
- If
- If
- Connection Types:
stdio
: Starts an MCP server as a child process and communicates via standard input/output.websocket
: Connects to an external MCP server via WebSocket.sse
: Connects to an external MCP server via Server-Sent Events (SSE).
Examples
stdio
MCP Server
stdio MCP Server
puppeteer:
type: stdio
command: npx
args:
- -y
- "@modelcontextprotocol/server-puppeteer"
env:
NODE_ENV: "production"
stderr: inherit
sse
MCP Server
sse MCP Server
everything:
url: http://localhost:3001/sse
websocket
MCP Server
websocket MCP Server
myWebSocketServer:
url: ws://localhost:8080
MCP Server with Custom Icon
MCP Server with Icon
filesystem:
command: npx
args:
- -y
- "@modelcontextprotocol/server-filesystem"
- /home/user/LibreChat/
iconPath: /home/user/LibreChat/client/public/assets/logo.svg
Importing MCP Server Configurations
The mcpServers
configurations allow LibreChat to dynamically interact with various MCP servers, which can perform specialized tasks or provide specific functionalities within the application. This modular approach facilitates extending the application’s capabilities by simply adding or modifying server configurations.
Additional Information
- Default Behavior:
- Initialization happens at startup, and the app must be restarted for changes to take effect.
- If both
url
andcommand
are specified, thetype
must be explicitly defined to avoid ambiguity.
- Environment Variables (
env
):- Useful for setting up specific runtime environments or configurations required by the MCP server process.
- Error Handling (
stderr
):- 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’sstderr
.
- Configuring
References
By properly configuring the mcpServers
in your librechat.yaml
, you can enhance LibreChat’s functionality and integrate custom tools and services seamlessly.