Back to Mistral Rs

MCP configuration schema

docs/src/content/docs/reference/mcp-config-schema.md

0.8.173.6 KB
Original Source

When mistral.rs acts as an MCP (Model Context Protocol) client, it reads a JSON config describing servers to connect to.

Top-level fields

json
{
  "servers": [ ... ],
  "auto_register_tools": true,
  "tool_timeout_secs": 30,
  "max_concurrent_calls": 10
}
FieldTypeDefaultPurpose
serversarrayrequiredList of MCP servers.
auto_register_toolsboolrequiredExpose every tool from every connected server to the model. Has no serde default; omitting it is a parse error, so always set it (use true).
tool_timeout_secsint30Per-tool-call timeout.
max_concurrent_callsint10Cap on concurrent MCP calls.

Server entry

json
{
  "name": "filesystem",
  "source": { ... },
  "enabled": true,
  "tool_prefix": "fs",
  "bearer_token": "...",
  "id": "fs-1",
  "resources": ["file://**"]
}
FieldTypeRequiredPurpose
namestringeffectively yesServer name. No validation rejects omission (it defaults to an empty string), but the entry is unusable without it.
sourceobjecteffectively yesTransport configuration. Omission defaults to an empty-URL Http source, which will not connect.
enabledboolno (default true)Disable a server without removing the entry.
tool_prefixstringno (auto-generated mcp_<uuid>)Prefix applied to tool names.
bearer_tokenstringnoOptional bearer token.
idstringno (auto UUID)Stable identifier for the server.
resourcesarraynoResource URI patterns the server exposes, e.g. ["file://**"], used for resource discovery and subscription.

Transports, source object

Process (stdio)

json
{
  "type": "Process",
  "command": "npx",
  "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
  "env": { "KEY": "value" },
  "work_dir": "/path"
}
FieldPurpose
typeLiteral "Process".
commandExecutable to run.
argsArguments.
envOptional environment variables.
work_dirOptional working directory.

HTTP

json
{
  "type": "Http",
  "url": "https://mcp.example.com",
  "headers": { "Authorization": "Bearer ..." },
  "timeout_secs": 60
}
FieldPurpose
typeLiteral "Http".
urlEndpoint URL.
headersOptional request headers.
timeout_secsOptional per-source timeout.

WebSocket

json
{
  "type": "WebSocket",
  "url": "wss://mcp.example.com/ws",
  "headers": { ... },
  "timeout_secs": 60
}

Same fields as HTTP with a WebSocket URL.

Tool name prefix

Tools from a server with tool_prefix = "fs" are exposed as fs_read_file, fs_list_directory, etc. The separator is an underscore. Without tool_prefix, an auto-generated mcp_<uuid> prefix is used.

Example

json
{
  "servers": [
    {
      "name": "filesystem",
      "tool_prefix": "fs",
      "source": {
        "type": "Process",
        "command": "npx",
        "args": ["-y", "@modelcontextprotocol/server-filesystem", "/srv/agent-workspace"]
      }
    },
    {
      "name": "github",
      "source": {
        "type": "Http",
        "url": "https://mcp.github.example.com",
        "headers": {
          "Authorization": "Bearer xxx"
        }
      }
    }
  ],
  "auto_register_tools": true,
  "max_concurrent_calls": 8,
  "tool_timeout_secs": 45
}

Pass it on the CLI:

bash
mistralrs serve --mcp-config mcp.json -m Qwen/Qwen3-4B

The same path can be supplied via the MCP_CONFIG_PATH environment variable.