Errors using Flox with Claude MCP demo

I’m trying to run through this Claude MCP weather example on my M4 Mac. Since the example requires a newer version of python3 than my Mac has, I have used my flox default environment to install uv and python313. However, it appears that the Claude Desktop settings to launch the MCP server using a command like “uv run weather.py” is not working.

I can launch it from my zsh shell which has the flox environment setup properly.

I’m wondering if when Claude Desktop launches and tries to invoke “uv”, which is a flox managed package, that it is unable to find it because flox default environment is not activated for Claude Desktop.

2025-03-30T16:14:26.346Z [weather] [error] spawn uv ENOENT {"context":"connection","stack":"Error: spawn uv ENOENT\n    at ChildProcess._handle.onexit (node:internal/child_process:285:19)\n    at onErrorNT (node:internal/child_process:483:16)\n    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)"}
2025-03-30T16:14:26.347Z [weather] [error] spawn uv ENOENT {"stack":"Error: spawn uv ENOENT\n    at ChildProcess._handle.onexit (node:internal/child_process:285:19)\n    at onErrorNT (node:internal/child_process:483:16)\n    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)"}
2025-03-30T16:14:26.347Z [weather] [info] Server transport closed
2025-03-30T16:14:26.348Z [weather] [info] Client transport closed
2025-03-30T16:14:26.348Z [weather] [info] Server transport closed unexpectedly, this is likely due to the process exiting early. If you are developing this MCP server you can add output to stderr (i.e. `console.error('...')` in JavaScript, `print('...', file=sys.stderr)` in python) and it will appear in this log.
2025-03-30T16:14:26.348Z [weather] [error] Server disconnected. For troubleshooting guidance, please visit our [debugging documentation](https://modelcontextprotocol.io/docs/tools/debugging) {"context":"connection"}
2025-03-30T16:15:15.349Z [weather] [info] Initializing server...
2025-03-30T16:15:15.356Z [weather] [error] spawn uv ENOENT {"context":"connection","stack":"Error: spawn uv ENOENT\n    at ChildProcess._handle.onexit (node:internal/child_process:285:19)\n    at onErrorNT (node:internal/child_process:483:16)\n    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)"}
2025-03-30T16:15:15.356Z [weather] [error] spawn uv ENOENT {"stack":"Error: spawn uv ENOENT\n    at ChildProcess._handle.onexit (node:internal/child_process:285:19)\n    at onErrorNT (node:internal/child_process:483:16)\n    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)"}
2025-03-30T16:15:15.360Z [weather] [info] Server transport closed
2025-03-30T16:15:15.360Z [weather] [info] Client transport closed
2025-03-30T16:15:15.360Z [weather] [info] Server transport closed unexpectedly, this is likely due to the process exiting early. If you are developing this MCP server you can add output to stderr (i.e. `console.error('...')` in JavaScript, `print('...', file=sys.stderr)` in python) and it will appear in this log.
2025-03-30T16:15:15.360Z [weather] [error] Server disconnected. For troubleshooting guidance, please visit our [debugging documentation](https://modelcontextprotocol.io/docs/tools/debugging) {"context":"connection"}

I solved my problem by changing the command that Claude invokes from “uv …” to “run-weather.sh” which enables the flox environment and then runs the “uv” command.

BEFORE

{
    "mcpServers": {
        "weather": {
            "command": "uv",
            "args": [
                "--directory",
                "/ABSOLUTE/PATH/TO/PARENT/FOLDER/weather",
                "run",
                "weather.py"
            ]
        }
    }
}

AFTER AND WORKING

{
  "globalShortcut": "Alt+C",
  "mcpServers": {
    "weather": {
        "command": "/ABSOLUTE/PATH/TO/PARENT/FOLDER/weather/run-weather.sh"
    }
  }
}

AND run-weather.sh of:

#!/bin/zsh

eval "$(flox activate -d "$HOME")"

uv --directory /ABSOLUTE/PATH/TO/PARENT/FOLDER/weather run weather.py

I’m wondering if when Claude Desktop launches and tries to invoke “uv”, which is a flox managed package, that it is unable to find it because flox default environment is not activated for Claude Desktop.

That’s most likely the case indeed.
Since you just run uv, the binary needs to be on the PATH which among other things is managed by flox.
If you can, start Claude desktop from a shell with flox activated, alternatively let it find uv via flox like you have done.

If you want to do this without a separate script, you can also use the flox activate -- command, I.e.


{
    "mcpServers": {
        "weather": {
            "command": "flox",
            "args": [
                "--dir",
"/ABSOLUTE/PATH/TO/PARENT/FOLDER/weather",
                "--",
                "uv",
                "--directory",
"/ABSOLUTE/PATH/TO/PARENT/FOLDER/weather",

                "run",
                "weather.py"
            ]
        }
    }
}

There may be a current dir config value so you don’t have the path on there twice(?).

1 Like

Got it, this makes sense. I appreciate the explanation.