Skip to content

[BUG]: MCP servers fail to load from anythingllm_mcp_servers.json in Docker (TypeError: Cannot convert undefined or null to object) #4579

@danny0094

Description

@danny0094

How are you running AnythingLLM?

Docker (local)

What happened?

Description
In AnythingLLM v1.9.0 (Docker build), the file
/app/server/storage/plugins/anythingllm_mcp_servers.json
is correctly detected by the backend, but the MCP Hypervisor fails to parse it and throws a TypeError when booting MCP servers.
As a result, no MCP servers are loaded or started.

Error Log:

[backend] info: [MCPHypervisor] MCP Config File: /app/server/storage/plugins/anythingllm_mcp_servers.json [backend] error: Error listing MCP servers: TypeError: Cannot convert undefined or null to object at get mcpServerConfigs [as mcpServerConfigs] (/app/server/utils/MCP/hypervisor/index.js:104:19) at MCPCompatibilityLayer.bootMCPServers (/app/server/utils/MCP/hypervisor/index.js:390:36) at MCPCompatibilityLayer.reloadMCPServers (/app/server/utils/MCP/hypervisor/index.js:138:16)

Expected Behavior
AnythingLLM should:
Properly parse the JSON config file,
Load each MCP server definition listed under mcpServers, and
Automatically boot those servers according to the configuration.
Actual Behavior
The file is detected and logged by the MCP Hypervisor.
The JSON is valid and accessible inside the container.
Still, the process crashes with a TypeError and no MCP servers are initialized.
Environment
AnythingLLM version: v1.9.0 (Docker)
Host OS: Ubuntu Server 22.04
Docker network: danny_ai-net
Mounted volume: /opt/anythingllm/storage:/app/server/storage
Container name: anythingllm

MCP Config Example

 {
  "mcpServers": {
    "sequentialthinking": {
      "displayName": "Sequential Thinking",
      "description": "Run the Sequential Thinking MCP Server as a tool",
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "--network",
        "danny_ai-net",
        "-p",
        "4001:3000",
        "--name",
        "mcp-sequentialthinking",
        "mcp/sequentialthinking",
        "--transport",
        "http"
      ],
      "autoStart": true,
      "timeout": 120000
    }
  }
}

The file has been verified with jq and is valid JSON.
Possible Cause
In /app/server/utils/MCP/hypervisor/index.js,
the mcpServerConfigs getter seems to receive undefined, likely due to an initialization or fallback issue when the plugin directory is empty or when the JSON parser doesn’t correctly handle the file’s structure inside Docker volumes.
Workaround
No stable workaround found.
The error persists even with a valid JSON file, correct volume mount, and proper permissions.
Additional Notes
MCP support was announced in v1.9.0 but may not be fully functional in the Docker build.
This issue prevents all MCP server configurations from loading in containerized setups.
Please confirm if the MCP parser initialization is missing or mis-referencing the storage path in Docker builds.

Are there known steps to reproduce?

Steps to Reproduce

  1. Run the official AnythingLLM Docker image (mintplexlabs/anythingllm:1.9.0)

  2. Mount a valid storage directory to /app/server/storage, e.g.:
    -v /opt/anythingllm/storage:/app/server/storage

  3. Inside that storage path, create the file:
    /app/server/storage/plugins/anythingllm_mcp_servers.json

  4. Add a valid MCP config such as:

{
  "mcpServers": {
    "sequentialthinking": {
      "displayName": "Sequential Thinking",
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "mcp/sequentialthinking"
      ]
    }
  }
}

  1. Restart the container:
    docker restart anythingllm

  2. Check the logs:
    docker logs -n 50 anythingllm | grep MCP

Result:
The backend throws

TypeError: Cannot convert undefined or null to object

Possible Cause / Fix Ideas
The getter mcpServerConfigs in
/app/server/utils/MCP/hypervisor/index.js

likely receives undefined because the MCP parser doesn’t handle an existing JSON object correctly when the plugin folder is empty or uninitialized.
Adding a simple null-check or fallback could fix the crash:

const configs = this._configs || {};
for (const key of Object.keys(configs)) { ... }

It’s also possible that this._configs is initialized after the JSON file is parsed, causing the first access to fail.
Confirming that storage/plugins is properly resolved in Docker (not overwritten at runtime) might also help.

Metadata

Metadata

Assignees

Labels

investigatingCore team or maintainer will or is currently looking into this issuepossible bugBug was reported but is not confirmed or is unable to be replicated.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions