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/MyLinks/
iconPath: /home/user/MyLinks/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
urlorcommand.
command
- Type: String
- Description: (For
stdiotype) The command or executable to run to start the MCP server.
args
- Type: Array of Strings
- Description: (For
stdiotype) Command line arguments to pass to thecommand.
url
- Type: String
- Description: (For
websocketorssetype) The URL to connect to the MCP server. - Notes:
- For
ssetype, the URL must start withhttp://orhttps://. - For
websockettype, 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,
stdiotype only) - Description: Environment variables to use when spawning the process.
stderr
- Type: String or Stream or Number (Optional,
stdiotype only) - Description: How to handle
stderrof the child process. This matches the semantics of Node’schild_process.spawn. - Default Value:
"inherit"(messages tostderrwill be printed to the parent process’sstderr).
Notes
- Type Inference:
- If
typeis omitted:- If
urlis specified and starts withhttp://orhttps://,typedefaults tosse. - If
urlis specified and starts withws://orwss://,typedefaults towebsocket. - If
commandis specified,typedefaults 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: inheritsse MCP Server
sse MCP Server
everything:
url: http://localhost:3001/ssewebsocket MCP Server
websocket MCP Server
myWebSocketServer:
url: ws://localhost:8080MCP Server with Custom Icon
MCP Server with Icon
filesystem:
command: npx
args:
- -y
- "@modelcontextprotocol/server-filesystem"
- /home/user/MyLinks/
iconPath: /home/user/MyLinks/client/public/assets/logo.svgImporting MCP Server Configurations
The mcpServers configurations allow MyLinks 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
urlandcommandare specified, thetypemust 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
stderrallows 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 MyLinks’s functionality and integrate custom tools and services seamlessly.