[GH-ISSUE #72] issue: API_ACCESS_TOKEN not working #35

Closed
opened 2026-10-18 21:10:41 +00:00 by bsakaguchi · 10 comments
Owner

Originally created by @LukeScrewdriver on GitHub (Apr 13, 2025).
Original GitHub issue: https://github.com/open-webui/mcpo/issues/72

Check Existing Issues

  • I have searched the existing issues and discussions.
  • I am using the latest version of mcpo.

mcpo Version

v0.0.11

Open WebUI Version (if applicable)

No response

Operating System

Unraid

Browser (if applicable)

No response

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both MCPO and Open WebUI.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have listed steps to reproduce the bug in detail.

Expected Behavior

I expect mcpo to be able to connect to the mcp server with the environnement variable API_ACCESS_TOKEN

Actual Behavior

The software crashes. Reading the logs it gives the error 401 Unauthorized as if the token is not being received

Steps to Reproduce

Honestly to reproduce the issue you need a home assistant server.
I start by attaching my configuration and the documentation provided by home assistant (for claude)

Logs & Screenshots

Logs:

ERROR:      + Exception Group Traceback (most recent call last):
  |   File "/app/.venv/lib/python3.11/site-packages/starlette/routing.py", line 692, in lifespan
  |     async with self.lifespan_context(app) as maybe_state:
  |   File "/usr/lib/python3.11/contextlib.py", line 204, in __aenter__
  |     return await anext(self.gen)
  |            ^^^^^^^^^^^^^^^^^^^^^
  |   File "/app/.venv/lib/python3.11/site-packages/mcpo/main.py", line 83, in lifespan
  |     await stack.enter_async_context(
  |   File "/usr/lib/python3.11/contextlib.py", line 638, in enter_async_context
  |     result = await _enter(cm)
  |              ^^^^^^^^^^^^^^^^
  |   File "/usr/lib/python3.11/contextlib.py", line 204, in __aenter__
  |     return await anext(self.gen)
  |            ^^^^^^^^^^^^^^^^^^^^^
  |   File "/app/.venv/lib/python3.11/site-packages/mcpo/main.py", line 101, in lifespan
  |     async with sse_client(url=args[0]) as (reader, writer):
  |   File "/usr/lib/python3.11/contextlib.py", line 204, in __aenter__
  |     return await anext(self.gen)
  |            ^^^^^^^^^^^^^^^^^^^^^
  |   File "/app/.venv/lib/python3.11/site-packages/mcp/client/sse.py", line 43, in sse_client
  |     async with anyio.create_task_group() as tg:
  |   File "/app/.venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__
  |     raise BaseExceptionGroup(
  | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/app/.venv/lib/python3.11/site-packages/mcp/client/sse.py", line 53, in sse_client
    |     event_source.response.raise_for_status()
    |   File "/app/.venv/lib/python3.11/site-packages/httpx/_models.py", line 829, in raise_for_status
    |     raise HTTPStatusError(message, request=request, response=self)
    | httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'http://192.168.1.40:8123/mcp_server/sse'
    | For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
    +------------------------------------

Configuration:

{
  "mcpServers": {
    "home-assistant": {
      "url":"http://192.168.1.40:8123/mcp_server/sse",
      "env": {
        "API_ACCESS_TOKEN": "<my token>"
      }
    },
    "time": {
      "command": "uvx",
      "args": ["mcp-server-time", "--local-timezone=Europe/Rome"]
    }
  }
}

Additional Information

No response

Originally created by @LukeScrewdriver on GitHub (Apr 13, 2025). Original GitHub issue: https://github.com/open-webui/mcpo/issues/72 ### Check Existing Issues - [x] I have searched the existing issues and discussions. - [x] I am using the latest version of mcpo. ### mcpo Version v0.0.11 ### Open WebUI Version (if applicable) _No response_ ### Operating System Unraid ### Browser (if applicable) _No response_ ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** MCPO and Open WebUI. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have listed steps to reproduce the bug in detail. ### Expected Behavior I expect mcpo to be able to connect to the mcp server with the environnement variable `API_ACCESS_TOKEN` ### Actual Behavior The software crashes. Reading the logs it gives the error `401 Unauthorized` as if the token is not being received ### Steps to Reproduce Honestly to reproduce the issue you need a home assistant server. I start by attaching my configuration and the documentation provided by [home assistant](https://www.home-assistant.io/integrations/mcp_server/) (for claude) ### Logs & Screenshots **Logs:** ``` ERROR: + Exception Group Traceback (most recent call last): | File "/app/.venv/lib/python3.11/site-packages/starlette/routing.py", line 692, in lifespan | async with self.lifespan_context(app) as maybe_state: | File "/usr/lib/python3.11/contextlib.py", line 204, in __aenter__ | return await anext(self.gen) | ^^^^^^^^^^^^^^^^^^^^^ | File "/app/.venv/lib/python3.11/site-packages/mcpo/main.py", line 83, in lifespan | await stack.enter_async_context( | File "/usr/lib/python3.11/contextlib.py", line 638, in enter_async_context | result = await _enter(cm) | ^^^^^^^^^^^^^^^^ | File "/usr/lib/python3.11/contextlib.py", line 204, in __aenter__ | return await anext(self.gen) | ^^^^^^^^^^^^^^^^^^^^^ | File "/app/.venv/lib/python3.11/site-packages/mcpo/main.py", line 101, in lifespan | async with sse_client(url=args[0]) as (reader, writer): | File "/usr/lib/python3.11/contextlib.py", line 204, in __aenter__ | return await anext(self.gen) | ^^^^^^^^^^^^^^^^^^^^^ | File "/app/.venv/lib/python3.11/site-packages/mcp/client/sse.py", line 43, in sse_client | async with anyio.create_task_group() as tg: | File "/app/.venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__ | raise BaseExceptionGroup( | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception) +-+---------------- 1 ---------------- | Traceback (most recent call last): | File "/app/.venv/lib/python3.11/site-packages/mcp/client/sse.py", line 53, in sse_client | event_source.response.raise_for_status() | File "/app/.venv/lib/python3.11/site-packages/httpx/_models.py", line 829, in raise_for_status | raise HTTPStatusError(message, request=request, response=self) | httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'http://192.168.1.40:8123/mcp_server/sse' | For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 +------------------------------------ ``` **Configuration:** ``` { "mcpServers": { "home-assistant": { "url":"http://192.168.1.40:8123/mcp_server/sse", "env": { "API_ACCESS_TOKEN": "<my token>" } }, "time": { "command": "uvx", "args": ["mcp-server-time", "--local-timezone=Europe/Rome"] } } } ``` ### Additional Information _No response_
bsakaguchi 2026-10-18 21:10:41 +00:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@tjbck commented on GitHub (Apr 13, 2025):

You need to set the ENV from the SSE server side.

<!-- gh-comment-id:2800117032 --> @tjbck commented on GitHub (Apr 13, 2025): You need to set the ENV from the SSE server side.
Author
Owner

@LukeScrewdriver commented on GitHub (Apr 14, 2025):

I can't.
After re-reading the documentation I realized that the configuration file I used is wrong.
What I would need is the ability to attach a header with with the token for authentication.
Like this

<!-- gh-comment-id:2802786425 --> @LukeScrewdriver commented on GitHub (Apr 14, 2025): I can't. After re-reading the documentation I realized that the configuration file I used is wrong. What I would need is the ability to attach a header with with the token for authentication. [Like this](https://github.com/sparfenyuk/mcp-proxy?tab=readme-ov-file#11-configuration)
Author
Owner

@thibmaek commented on GitHub (Apr 26, 2025):

Same here, trying to add Home Assistant's MCP server into my mcpo config. The env property is not taking into account and doesn't seem like there is a way to provide headers. Open WebUI itself is unable to use the SSE server Home Assistant provides

<!-- gh-comment-id:2832317414 --> @thibmaek commented on GitHub (Apr 26, 2025): Same here, trying to add [Home Assistant's MCP server](https://www.home-assistant.io/integrations/mcp_server/) into my mcpo config. The `env` property is not taking into account and doesn't seem like there is a way to provide headers. Open WebUI itself is unable to use the SSE server Home Assistant provides
Author
Owner

@LukeScrewdriver commented on GitHub (Apr 26, 2025):

@thibmaek This way mcpo can connect to home assistant's MCP server without any problems.
The only thing I don't understand is why when I ask it for something it always returns {}

{
  "mcpServers": {
    "home-assistant":{
      "command":"uvx",
      "args": ["mcp-proxy"],
      "env":{
        "SSE_URL": "http://localhost:8123/mcp_server/sse",
        "API_ACCESS_TOKEN": "<your_access_token_here>"
      }
    }
  }
}
<!-- gh-comment-id:2832328428 --> @LukeScrewdriver commented on GitHub (Apr 26, 2025): @thibmaek This way mcpo can connect to home assistant's MCP server without any problems. The only thing I don't understand is why when I ask it for something it always returns `{}` ``` { "mcpServers": { "home-assistant":{ "command":"uvx", "args": ["mcp-proxy"], "env":{ "SSE_URL": "http://localhost:8123/mcp_server/sse", "API_ACCESS_TOKEN": "<your_access_token_here>" } } } } ```
Author
Owner

@SadmL commented on GitHub (May 18, 2025):

@LukeScrewdriver
I've used
https://www.home-assistant.io/integrations/mcp_server#example-cursor

and it works, but instead uvx I'm using pipx

{
  "mcpServers": {
    "home-assistant": {
      "command": "pipx",
      "args": ["run", "mcp-proxy", "https://my-url/mcp_server/sse"],
      "env": {
        "API_ACCESS_TOKEN": "my-token"
      }
    }
  }
}
<!-- gh-comment-id:2888896491 --> @SadmL commented on GitHub (May 18, 2025): @LukeScrewdriver I've used https://www.home-assistant.io/integrations/mcp_server#example-cursor and it works, but instead `uvx` I'm using `pipx` ``` { "mcpServers": { "home-assistant": { "command": "pipx", "args": ["run", "mcp-proxy", "https://my-url/mcp_server/sse"], "env": { "API_ACCESS_TOKEN": "my-token" } } } } ```
Author
Owner

@Pounii25 commented on GitHub (Jun 8, 2025):

@LukeScrewdriver I've used https://www.home-assistant.io/integrations/mcp_server#example-cursor

and it works, but instead uvx I'm using pipx

{
  "mcpServers": {
    "home-assistant": {
      "command": "pipx",
      "args": ["run", "mcp-proxy", "https://my-url/mcp_server/sse"],
      "env": {
        "API_ACCESS_TOKEN": "my-token"
      }
    }
  }
}

I cannot use pipx into mcpo, how do you do that?

<!-- gh-comment-id:2953730672 --> @Pounii25 commented on GitHub (Jun 8, 2025): > [@LukeScrewdriver](https://github.com/LukeScrewdriver) I've used https://www.home-assistant.io/integrations/mcp_server#example-cursor > > and it works, but instead `uvx` I'm using `pipx` > > ``` > { > "mcpServers": { > "home-assistant": { > "command": "pipx", > "args": ["run", "mcp-proxy", "https://my-url/mcp_server/sse"], > "env": { > "API_ACCESS_TOKEN": "my-token" > } > } > } > } > ``` I cannot use pipx into mcpo, how do you do that?
Author
Owner

@LukeScrewdriver commented on GitHub (Jun 8, 2025):

@LukeScrewdriver I've used https://www.home-assistant.io/integrations/mcp_server#example-cursor

and it works, but instead uvx I'm using pipx

{
  "mcpServers": {
    "home-assistant": {
      "command": "pipx",
      "args": ["run", "mcp-proxy", "https://my-url/mcp_server/sse"],
      "env": {
        "API_ACCESS_TOKEN": "my-token"
      }
    }
  }
}

I cannot use pipx into mcpo, how do you do that?

In fact, it didn't work for me either.
However now in the latest version you can specify custom headers so all this configuration is no longer needed.

<!-- gh-comment-id:2953786476 --> @LukeScrewdriver commented on GitHub (Jun 8, 2025): > > [@LukeScrewdriver](https://github.com/LukeScrewdriver) I've used https://www.home-assistant.io/integrations/mcp_server#example-cursor > > > > and it works, but instead `uvx` I'm using `pipx` > > > > ``` > > { > > "mcpServers": { > > "home-assistant": { > > "command": "pipx", > > "args": ["run", "mcp-proxy", "https://my-url/mcp_server/sse"], > > "env": { > > "API_ACCESS_TOKEN": "my-token" > > } > > } > > } > > } > > ``` > > I cannot use pipx into mcpo, how do you do that? In fact, it didn't work for me either. However now in the latest version you can specify custom headers so all this configuration is no longer needed.
Author
Owner

@Pounii25 commented on GitHub (Jun 8, 2025):

@LukeScrewdriver I've used https://www.home-assistant.io/integrations/mcp_server#example-cursor
and it works, but instead uvx I'm using pipx

{
  "mcpServers": {
    "home-assistant": {
      "command": "pipx",
      "args": ["run", "mcp-proxy", "https://my-url/mcp_server/sse"],
      "env": {
        "API_ACCESS_TOKEN": "my-token"
      }
    }
  }
}

I cannot use pipx into mcpo, how do you do that?

In fact, it didn't work for me either. However now in the latest version you can specify custom headers so all this configuration is no longer needed.

ok, then apparently I just need to handle local certificate. There is a setting for this also?

<!-- gh-comment-id:2954232925 --> @Pounii25 commented on GitHub (Jun 8, 2025): > > > [@LukeScrewdriver](https://github.com/LukeScrewdriver) I've used https://www.home-assistant.io/integrations/mcp_server#example-cursor > > > and it works, but instead `uvx` I'm using `pipx` > > > ``` > > > { > > > "mcpServers": { > > > "home-assistant": { > > > "command": "pipx", > > > "args": ["run", "mcp-proxy", "https://my-url/mcp_server/sse"], > > > "env": { > > > "API_ACCESS_TOKEN": "my-token" > > > } > > > } > > > } > > > } > > > ``` > > > > > > I cannot use pipx into mcpo, how do you do that? > > In fact, it didn't work for me either. However now in the latest version you can specify custom headers so all this configuration is no longer needed. ok, then apparently I just need to handle local certificate. There is a setting for this also?
Author
Owner

@Pounii25 commented on GitHub (Jun 8, 2025):

ok I got it working with this config

"home-assistant": {
      "command":"uvx",
      "args": ["mcp-proxy"],
      "env":{
        "SSE_URL": "http://my-internal-ip:8123/mcp_server/sse",
        "API_ACCESS_TOKEN": "my-token"
      }
    }

But how to use the new config with the headers? Sorry for a dumb question. Also interested to tell mcpo server to accept local certs, already loaded with docker compose with volume, but still not accepted.

<!-- gh-comment-id:2954266177 --> @Pounii25 commented on GitHub (Jun 8, 2025): ok I got it working with this config ``` "home-assistant": { "command":"uvx", "args": ["mcp-proxy"], "env":{ "SSE_URL": "http://my-internal-ip:8123/mcp_server/sse", "API_ACCESS_TOKEN": "my-token" } } ``` But how to use the new config with the headers? Sorry for a dumb question. Also interested to tell mcpo server to accept local certs, already loaded with docker compose with volume, but still not accepted.
Author
Owner

@h4de5 commented on GitHub (Jul 21, 2025):

I tried this, but without any luck. it still says 401 not authorized.
I already tested the token using curl and it works correctly.

    "homeassistant": {
      "type": "sse",
      "url": "https://YOUR_HA_SERVER:8123/mcp_server/sse",
      "headers": {
        "Authorization": "Bearer YOUR_LONG_LIVED_TOKEN"
      }
    }
<!-- gh-comment-id:3095898057 --> @h4de5 commented on GitHub (Jul 21, 2025): I tried this, but without any luck. it still says 401 not authorized. I already tested the token using curl and it works correctly. ```json "homeassistant": { "type": "sse", "url": "https://YOUR_HA_SERVER:8123/mcp_server/sse", "headers": { "Authorization": "Bearer YOUR_LONG_LIVED_TOKEN" } } ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
open-webui/mcpo#35
No description provided.