Docs
⚙️ Configuration
librechat.yaml
Settings
MCP Servers

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:

KeyTypeDescriptionExample
<serverName>ObjectEach 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

KeyTypeDescriptionExample
typeStringSpecifies 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"
commandString(For `stdio` type) The command or executable to run to start the MCP server.command: "npx"
argsArray of Strings(For `stdio` type) Command line arguments to pass to the `command`.args: ["-y", "@modelcontextprotocol/server-puppeteer"]
urlString(For `websocket` or `sse` type) The URL to connect to the MCP server.url: "http://localhost:3001/sse"
iconPathString(Optional) Defines the tool's display icon shown in the tool selection dialog.iconPath: "/path/to/icon.svg"
envObject(Optional, `stdio` type only) Environment variables to use when spawning the process.env: NODE_ENV: "production"
stderrString 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 or command.

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 the command.

url

  • Type: String
  • Description: (For websocket or sse type) The URL to connect to the MCP server.
  • Notes:
    • For sse type, the URL must start with http:// or https://.
    • For websocket type, the URL must start with ws:// or wss://.

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’s child_process.spawn.
  • Default Value: "inherit" (messages to stderr will be printed to the parent process’s stderr).

Notes

  • Type Inference:
    • If type is omitted:
      • If url is specified and starts with http:// or https://, type defaults to sse.
      • If url is specified and starts with ws:// or wss://, type defaults to websocket.
      • If command is specified, type defaults to stdio.
  • 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 and command are specified, the type 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’s stderr.

References


By properly configuring the mcpServers in your librechat.yaml, you can enhance LibreChat’s functionality and integrate custom tools and services seamlessly.