这是indexloc提供的服务,不要输入任何密码
Skip to content

[FEAT]: Environment Variable Management for MCP Servers for WSL command #3703

@suzuki-shm

Description

@suzuki-shm

What would you like to see?

Thank you for continuously implementing advanced features! I'm excited to see the new MCP client functionality in AnythingLLM.

I have tried out the new MCP server feature in AnythingLLM and wanted to share some observations.

Environment Variable Management

Currently, AnythingLLM may not support the env property in MCP server configurations.

The official MCP specification doesn’t include an env field, but tools like Claude Desktop and the VSCode extension allow us to declare environment variables directly in the JSON config for runtime use and within args.

As a result, users must pass environment variables as command-line arguments in args, and there’s no mechanism to inject them into the runtime environment itself.

In many MCP server repositories (e.g., mcp-servers), JSON examples leverage the env property extensively. By adding support for env in AnythingLLM, users could copy & paste existing MCP JSON configs without modification. It improves usability and adoption for MCP scenarios.

Thank you for considering this enhancement!

Appendix: Debug message at AnythingLLM Desktop

Case1: Try to use env property

{
  "mcpServers": {
    "github": {
      "command": "C:\\Windows\\System32\\wsl.exe",
      "args": [
        "bash",
        "-c",
        "/usr/bin/docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server"
      ],
      "anythingllm": {
        "autoStart": true
      },
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "MY_GITHUB_ACCESS_TOKEN"
      }
    }
  }
}

Result: Failed (MCP error -32000: Connection closed)

[backend] info: [r] Attempting to start MCP server: github
time="2025-04-23T11:44:56Z" level=fatal msg="GITHUB_PERSONAL_ACCESS_TOKEN not set"

Case2: Embed environment variable to args

{
  "mcpServers": {
    "github": {
      "command": "C:\\Windows\\System32\\wsl.exe",
      "args": [
        "bash",
        "-c",
        "/usr/bin/docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN=MY_GITHUB_ACCESS_TOKEN ghcr.io/github/github-mcp-server"
      ],
      "anythingllm": {
        "autoStart": true
      }
    }
  }
}

Result: Success

[backend] info: [r] Attempting to start MCP server: github
GitHub MCP Server running on stdio
[backend] info: [r] Successfully started 1 MCP servers: ["github"]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions