[GH-ISSUE #260] issue: Startup Error: "asyncio.run() cannot be called from a running event loop" #119

Closed
opened 2026-10-18 21:11:56 +00:00 by bsakaguchi · 5 comments
Owner

Originally created by @daryltucker on GitHub (Oct 10, 2025).
Original GitHub issue: https://github.com/open-webui/mcpo/issues/260

Originally assigned to: @taylorwilsdon on GitHub.

Check Existing Issues

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

mcpo Version

v1.0
sha256:af810dc3deb1769425bb0f0001d27097a434322f8e66a4d095369a7c087047e8

Open WebUI Version (if applicable)

No response

Operating System

It's whatever you packaged open-webui/mcpo:main

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

Able to run Streamable HTTP MCP Server

Actual Behavior

MCP Server fails to start.

Steps to Reproduce

  1. image: ghcr.io/open-webui/mcpo:main
  2. command: ["mcpo", "--config", "/mcp-config.json", "--server-type", "streamable-http", "--", "http://127.0.0.1:8002/mcp"]

Runs fine without the --server-type and everything after.
Documentation states I should be able to use this command to run mcpo in Streamable HTTP mode.

Logs & Screenshots

2025-10-10 21:40:31,423 - INFO - Starting MCPO Server...
2025-10-10 21:40:31,423 - INFO -   Name: MCP OpenAPI Proxy
2025-10-10 21:40:31,423 - INFO -   Version: 1.0
2025-10-10 21:40:31,423 - INFO -   Description: Automatically generated API from MCP Tool Schemas
2025-10-10 21:40:31,423 - INFO -   Hostname: de5317d14cfa
2025-10-10 21:40:31,424 - INFO -   Port: 8000
2025-10-10 21:40:31,424 - INFO -   API Key: Not Provided
2025-10-10 21:40:31,424 - INFO -   CORS Allowed Origins: ['*']
2025-10-10 21:40:31,424 - INFO -   Path Prefix: /
Starting MCP OpenAPI Proxy with config file: /mcp-config.json
╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /app/src/mcpo/__init__.py:126 in main                                        │
│                                                                              │
│   123 │   │   path_prefix = f"/{path_prefix}"                                │
│   124 │                                                                      │
│   125 │   # Run your async run function from mcpo.main                       │
│ ❱ 126 │   asyncio.run(                                                       │
│   127 │   │   run(                                                           │
│   128 │   │   │   host,                                                      │
│   129 │   │   │   port,                                                      │
│                                                                              │
│ ╭──────────────── locals ─────────────────╮                                  │
│ │            api_key = None               │                                  │
│ │        config_path = '/mcp-config.json' │                                  │
│ │ cors_allow_origins = ['*']              │                                  │
│ │        description = None               │                                  │
│ │                env = None               │                                  │
│ │           env_dict = {}                 │                                  │
│ │           env_path = None               │                                  │
│ │            headers = None               │                                  │
│ │               host = '0.0.0.0'          │                                  │
│ │         hot_reload = False              │                                  │
│ │               name = None               │                                  │
│ │        path_prefix = '/'                │                                  │
│ │               port = 8000               │                                  │
│ │     server_command = None               │                                  │
│ │        server_type = 'streamable-http'  │                                  │
│ │       ssl_certfile = None               │                                  │
│ │        ssl_keyfile = None               │                                  │
│ │        strict_auth = False              │                                  │
│ │            version = None               │                                  │
│ ╰─────────────────────────────────────────╯                                  │
│                                                                              │
│ /usr/lib/python3.11/asyncio/runners.py:190 in run                            │
│                                                                              │
│   187 │   │   │   "asyncio.run() cannot be called from a running event loop" │
│   188 │                                                                      │
│   189 │   with Runner(debug=debug) as runner:                                │
│ ❱ 190 │   │   return runner.run(main)                                        │
│   191                                                                        │
│   192                                                                        │
│   193 def _cancel_all_tasks(loop):                                           │
│                                                                              │
│ ╭────────────────────────── locals ──────────────────────────╮               │
│ │  debug = None                                              │               │
│ │   main = <coroutine object run at 0x2b1c64d0>              │               │
│ │ runner = <asyncio.runners.Runner object at 0x7f7ebdc07d50> │               │
│ ╰────────────────────────────────────────────────────────────╯               │
│                                                                              │
│ /usr/lib/python3.11/asyncio/runners.py:118 in run                            │
│                                                                              │
│   115 │   │                                                                  │
│   116 │   │   self._interrupt_count = 0                                      │
│   117 │   │   try:                                                           │
│ ❱ 118 │   │   │   return self._loop.run_until_complete(task)                 │
│   119 │   │   except exceptions.CancelledError:                              │
│   120 │   │   │   if self._interrupt_count > 0:                              │
│   121 │   │   │   │   uncancel = getattr(task, "uncancel", None)             │
│                                                                              │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │        context = <_contextvars.Context object at 0x7f7ebba39d80>         │ │
│ │           coro = <coroutine object run at 0x2b1c64d0>                    │ │
│ │           self = <asyncio.runners.Runner object at 0x7f7ebdc07d50>       │ │
│ │ sigint_handler = functools.partial(<bound method Runner._on_sigint of    │ │
│ │                  <asyncio.runners.Runner object at 0x7f7ebdc07d50>>,     │ │
│ │                  main_task=<Task finished name='Task-1' coro=<run()      │ │
│ │                  done, defined at /app/src/mcpo/main.py:436>             │ │
│ │                  exception=TypeError("'NoneType' object is not           │ │
│ │                  subscriptable")>)                                       │ │
│ │           task = <Task finished name='Task-1' coro=<run() done, defined  │ │
│ │                  at /app/src/mcpo/main.py:436>                           │ │
│ │                  exception=TypeError("'NoneType' object is not           │ │
│ │                  subscriptable")>                                        │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│                                                                              │
│ /usr/lib/python3.11/asyncio/base_events.py:653 in run_until_complete         │
│                                                                              │
│    650 │   │   if not future.done():                                         │
│    651 │   │   │   raise RuntimeError('Event loop stopped before Future comp │
│    652 │   │                                                                 │
│ ❱  653 │   │   return future.result()                                        │
│    654 │                                                                     │
│    655 │   def stop(self):                                                   │
│    656 │   │   """Stop running the event loop.                               │
│                                                                              │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │   future = <Task finished name='Task-1' coro=<run() done, defined at     │ │
│ │            /app/src/mcpo/main.py:436> exception=TypeError("'NoneType'    │ │
│ │            object is not subscriptable")>                                │ │
│ │ new_task = False                                                         │ │
│ │     self = <_UnixSelectorEventLoop running=False closed=True             │ │
│ │            debug=False>                                                  │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│                                                                              │
│ /app/src/mcpo/main.py:542 in run                                             │
│                                                                              │
│   539 │   │   main_app.state.headers = headers                               │
│   540 │   elif server_type == "streamable-http":                             │
│   541 │   │   logger.info(                                                   │
│ ❱ 542 │   │   │   f"Configuring for a single StreamableHTTP MCP Server with  │
│   543 │   │   )                                                              │
│   544 │   │   main_app.state.server_type = "streamable-http"                 │
│   545 │   │   main_app.state.args = server_command[0]  # Expects URL as the  │
│                                                                              │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │     api_dependency = None                                                │ │
│ │            api_key = None                                                │ │
│ │        config_path = '/mcp-config.json'                                  │ │
│ │ connection_timeout = None                                                │ │
│ │ cors_allow_origins = ['*']                                               │ │
│ │        description = 'Automatically generated API from MCP Tool Schemas' │ │
│ │            headers = None                                                │ │
│ │               host = '0.0.0.0'                                           │ │
│ │         hot_reload = False                                               │ │
│ │             kwargs = {                                                   │ │
│ │                      │   'strict_auth': False,                           │ │
│ │                      │   'server_type': 'streamable-http',               │ │
│ │                      │   'config_path': '/mcp-config.json',              │ │
│ │                      │   'name': None,                                   │ │
│ │                      │   'description': None,                            │ │
│ │                      │   'version': None,                                │ │
│ │                      │   'server_command': None,                         │ │
│ │                      │   'ssl_certfile': None,                           │ │
│ │                      │   'ssl_keyfile': None,                            │ │
│ │                      │   'path_prefix': '/',                             │ │
│ │                      │   ... +2                                          │ │
│ │                      }                                                   │ │
│ │           main_app = <fastapi.applications.FastAPI object at             │ │
│ │                      0x7f7ebc85bdd0>                                     │ │
│ │               name = 'MCP OpenAPI Proxy'                                 │ │
│ │        path_prefix = '/'                                                 │ │
│ │               port = 8000                                                │ │
│ │     server_command = None                                                │ │
│ │        server_type = 'streamable-http'                                   │ │
│ │   shutdown_handler = <mcpo.main.GracefulShutdown object at               │ │
│ │                      0x7f7ebba3a310>                                     │ │
│ │       ssl_certfile = None                                                │ │
│ │        ssl_keyfile = None                                                │ │
│ │        strict_auth = False                                               │ │
│ │            version = '1.0'                                               │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────╯
TypeError: 'NoneType' object is not subscriptable

Additional Information

To use a Streamable HTTP-compatible MCP server, specify the server type and endpoint:
```bash
mcpo --port 8000 --api-key "top-secret" --server-type "streamable-http" -- http://127.0.0.1:8002/mcp
```

I don't understand how I could be messing this up.

Originally created by @daryltucker on GitHub (Oct 10, 2025). Original GitHub issue: https://github.com/open-webui/mcpo/issues/260 Originally assigned to: @taylorwilsdon on GitHub. ### Check Existing Issues - [x] I have searched the existing issues and discussions. - [x] I am using the latest version of mcpo. ### mcpo Version v1.0 sha256:af810dc3deb1769425bb0f0001d27097a434322f8e66a4d095369a7c087047e8 ### Open WebUI Version (if applicable) _No response_ ### Operating System It's whatever you packaged open-webui/mcpo:main ### 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 Able to run Streamable HTTP MCP Server ### Actual Behavior MCP Server fails to start. ### Steps to Reproduce 1. image: ghcr.io/open-webui/mcpo:main 2. command: ["mcpo", "--config", "/mcp-config.json", "--server-type", "streamable-http", "--", "http://127.0.0.1:8002/mcp"] Runs fine without the `--server-type` and everything after. Documentation states I should be able to use this command to run `mcpo` in Streamable HTTP mode. ### Logs & Screenshots ```bash 2025-10-10 21:40:31,423 - INFO - Starting MCPO Server... 2025-10-10 21:40:31,423 - INFO - Name: MCP OpenAPI Proxy 2025-10-10 21:40:31,423 - INFO - Version: 1.0 2025-10-10 21:40:31,423 - INFO - Description: Automatically generated API from MCP Tool Schemas 2025-10-10 21:40:31,423 - INFO - Hostname: de5317d14cfa 2025-10-10 21:40:31,424 - INFO - Port: 8000 2025-10-10 21:40:31,424 - INFO - API Key: Not Provided 2025-10-10 21:40:31,424 - INFO - CORS Allowed Origins: ['*'] 2025-10-10 21:40:31,424 - INFO - Path Prefix: / Starting MCP OpenAPI Proxy with config file: /mcp-config.json ╭───────────────────── Traceback (most recent call last) ──────────────────────╮ │ /app/src/mcpo/__init__.py:126 in main │ │ │ │ 123 │ │ path_prefix = f"/{path_prefix}" │ │ 124 │ │ │ 125 │ # Run your async run function from mcpo.main │ │ ❱ 126 │ asyncio.run( │ │ 127 │ │ run( │ │ 128 │ │ │ host, │ │ 129 │ │ │ port, │ │ │ │ ╭──────────────── locals ─────────────────╮ │ │ │ api_key = None │ │ │ │ config_path = '/mcp-config.json' │ │ │ │ cors_allow_origins = ['*'] │ │ │ │ description = None │ │ │ │ env = None │ │ │ │ env_dict = {} │ │ │ │ env_path = None │ │ │ │ headers = None │ │ │ │ host = '0.0.0.0' │ │ │ │ hot_reload = False │ │ │ │ name = None │ │ │ │ path_prefix = '/' │ │ │ │ port = 8000 │ │ │ │ server_command = None │ │ │ │ server_type = 'streamable-http' │ │ │ │ ssl_certfile = None │ │ │ │ ssl_keyfile = None │ │ │ │ strict_auth = False │ │ │ │ version = None │ │ │ ╰─────────────────────────────────────────╯ │ │ │ │ /usr/lib/python3.11/asyncio/runners.py:190 in run │ │ │ │ 187 │ │ │ "asyncio.run() cannot be called from a running event loop" │ │ 188 │ │ │ 189 │ with Runner(debug=debug) as runner: │ │ ❱ 190 │ │ return runner.run(main) │ │ 191 │ │ 192 │ │ 193 def _cancel_all_tasks(loop): │ │ │ │ ╭────────────────────────── locals ──────────────────────────╮ │ │ │ debug = None │ │ │ │ main = <coroutine object run at 0x2b1c64d0> │ │ │ │ runner = <asyncio.runners.Runner object at 0x7f7ebdc07d50> │ │ │ ╰────────────────────────────────────────────────────────────╯ │ │ │ │ /usr/lib/python3.11/asyncio/runners.py:118 in run │ │ │ │ 115 │ │ │ │ 116 │ │ self._interrupt_count = 0 │ │ 117 │ │ try: │ │ ❱ 118 │ │ │ return self._loop.run_until_complete(task) │ │ 119 │ │ except exceptions.CancelledError: │ │ 120 │ │ │ if self._interrupt_count > 0: │ │ 121 │ │ │ │ uncancel = getattr(task, "uncancel", None) │ │ │ │ ╭───────────────────────────────── locals ─────────────────────────────────╮ │ │ │ context = <_contextvars.Context object at 0x7f7ebba39d80> │ │ │ │ coro = <coroutine object run at 0x2b1c64d0> │ │ │ │ self = <asyncio.runners.Runner object at 0x7f7ebdc07d50> │ │ │ │ sigint_handler = functools.partial(<bound method Runner._on_sigint of │ │ │ │ <asyncio.runners.Runner object at 0x7f7ebdc07d50>>, │ │ │ │ main_task=<Task finished name='Task-1' coro=<run() │ │ │ │ done, defined at /app/src/mcpo/main.py:436> │ │ │ │ exception=TypeError("'NoneType' object is not │ │ │ │ subscriptable")>) │ │ │ │ task = <Task finished name='Task-1' coro=<run() done, defined │ │ │ │ at /app/src/mcpo/main.py:436> │ │ │ │ exception=TypeError("'NoneType' object is not │ │ │ │ subscriptable")> │ │ │ ╰──────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /usr/lib/python3.11/asyncio/base_events.py:653 in run_until_complete │ │ │ │ 650 │ │ if not future.done(): │ │ 651 │ │ │ raise RuntimeError('Event loop stopped before Future comp │ │ 652 │ │ │ │ ❱ 653 │ │ return future.result() │ │ 654 │ │ │ 655 │ def stop(self): │ │ 656 │ │ """Stop running the event loop. │ │ │ │ ╭───────────────────────────────── locals ─────────────────────────────────╮ │ │ │ future = <Task finished name='Task-1' coro=<run() done, defined at │ │ │ │ /app/src/mcpo/main.py:436> exception=TypeError("'NoneType' │ │ │ │ object is not subscriptable")> │ │ │ │ new_task = False │ │ │ │ self = <_UnixSelectorEventLoop running=False closed=True │ │ │ │ debug=False> │ │ │ ╰──────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /app/src/mcpo/main.py:542 in run │ │ │ │ 539 │ │ main_app.state.headers = headers │ │ 540 │ elif server_type == "streamable-http": │ │ 541 │ │ logger.info( │ │ ❱ 542 │ │ │ f"Configuring for a single StreamableHTTP MCP Server with │ │ 543 │ │ ) │ │ 544 │ │ main_app.state.server_type = "streamable-http" │ │ 545 │ │ main_app.state.args = server_command[0] # Expects URL as the │ │ │ │ ╭───────────────────────────────── locals ─────────────────────────────────╮ │ │ │ api_dependency = None │ │ │ │ api_key = None │ │ │ │ config_path = '/mcp-config.json' │ │ │ │ connection_timeout = None │ │ │ │ cors_allow_origins = ['*'] │ │ │ │ description = 'Automatically generated API from MCP Tool Schemas' │ │ │ │ headers = None │ │ │ │ host = '0.0.0.0' │ │ │ │ hot_reload = False │ │ │ │ kwargs = { │ │ │ │ │ 'strict_auth': False, │ │ │ │ │ 'server_type': 'streamable-http', │ │ │ │ │ 'config_path': '/mcp-config.json', │ │ │ │ │ 'name': None, │ │ │ │ │ 'description': None, │ │ │ │ │ 'version': None, │ │ │ │ │ 'server_command': None, │ │ │ │ │ 'ssl_certfile': None, │ │ │ │ │ 'ssl_keyfile': None, │ │ │ │ │ 'path_prefix': '/', │ │ │ │ │ ... +2 │ │ │ │ } │ │ │ │ main_app = <fastapi.applications.FastAPI object at │ │ │ │ 0x7f7ebc85bdd0> │ │ │ │ name = 'MCP OpenAPI Proxy' │ │ │ │ path_prefix = '/' │ │ │ │ port = 8000 │ │ │ │ server_command = None │ │ │ │ server_type = 'streamable-http' │ │ │ │ shutdown_handler = <mcpo.main.GracefulShutdown object at │ │ │ │ 0x7f7ebba3a310> │ │ │ │ ssl_certfile = None │ │ │ │ ssl_keyfile = None │ │ │ │ strict_auth = False │ │ │ │ version = '1.0' │ │ │ ╰──────────────────────────────────────────────────────────────────────────╯ │ ╰──────────────────────────────────────────────────────────────────────────────╯ TypeError: 'NoneType' object is not subscriptable ``` ### Additional Information ```` To use a Streamable HTTP-compatible MCP server, specify the server type and endpoint: ```bash mcpo --port 8000 --api-key "top-secret" --server-type "streamable-http" -- http://127.0.0.1:8002/mcp ``` ```` I don't understand how I could be messing this up.
bsakaguchi 2026-10-18 21:11:56 +00:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@daryltucker commented on GitHub (Oct 10, 2025):

This is the second time, reading the documentation, I feel like there is a way to put mcpo in HTTP Streamable Mode, or SSE.

If this isn't the case please clarify. I wont close this ticket this time so you can see what's going on.

<!-- gh-comment-id:3392426766 --> @daryltucker commented on GitHub (Oct 10, 2025): This is the second time, reading the documentation, I feel like there is a way to put `mcpo` in HTTP Streamable Mode, or SSE. If this isn't the case please clarify. I wont close this ticket this time so you can see what's going on.
Author
Owner

@daryltucker commented on GitHub (Oct 10, 2025):

I thought maybe you wanted me to painstakingly do this to all of my entries:

    "time": {
      "command": "uvx",
      "args": ["mcp-server-time", "--local-timezone=America/New_York"]
    },
    "time-stream": {
      "type": "streamable-http",
      "url": "http://192.168.18.1:8000/time"
    },

But not even that works because time isn't being served when mcpo starts up....

<!-- gh-comment-id:3392494782 --> @daryltucker commented on GitHub (Oct 10, 2025): I thought maybe you wanted me to painstakingly do this to all of my entries: ``` "time": { "command": "uvx", "args": ["mcp-server-time", "--local-timezone=America/New_York"] }, "time-stream": { "type": "streamable-http", "url": "http://192.168.18.1:8000/time" }, ``` But not even that works because `time` isn't being served when `mcpo` starts up....
Author
Owner

@daryltucker commented on GitHub (Oct 10, 2025):

cat mcpo-streamable.jq
. as $config
| {
    server: $config.server,
    mcpServers: (
      $config.mcpServers
      | to_entries
      | map(
          .key as $tool_name
          | {
              key: ($tool_name + "-stream"),
              value: {
                "type": "streamable-http",
                "url": "http://192.168.18.1:8000/" + $tool_name
              }
            }
        )
      | from_entries
    )
  }


cat actual_mcpo_config.json | jq -f mcpo-streamable.jq
  "mcpServers": {
    "time-stream": {
      "type": "streamable-http",
      "url": "http://192.168.18.1:8000/time"
    }
}

So I guess I'll just set up a second mcpo server and init after this first one starts....

<!-- gh-comment-id:3392512585 --> @daryltucker commented on GitHub (Oct 10, 2025): ```bash cat mcpo-streamable.jq . as $config | { server: $config.server, mcpServers: ( $config.mcpServers | to_entries | map( .key as $tool_name | { key: ($tool_name + "-stream"), value: { "type": "streamable-http", "url": "http://192.168.18.1:8000/" + $tool_name } } ) | from_entries ) } cat actual_mcpo_config.json | jq -f mcpo-streamable.jq "mcpServers": { "time-stream": { "type": "streamable-http", "url": "http://192.168.18.1:8000/time" } } ``` So I guess I'll just set up a second `mcpo` server and init after this first one starts....
Author
Owner

@daryltucker commented on GitHub (Oct 10, 2025):

https://github.com/modelcontextprotocol/inspector/issues/860

<!-- gh-comment-id:3392515492 --> @daryltucker commented on GitHub (Oct 10, 2025): https://github.com/modelcontextprotocol/inspector/issues/860
Author
Owner

@taylorwilsdon commented on GitHub (Oct 18, 2025):

What MCP are you actually running here? If it's actually mcp-server-time (https://github.com/Taki-Ta/mcp-server-time) that project does not appear to support streamable HTTP, so that's not going to work. mcpo is a proxy to expose an MCP as an OpenAPI spec tool server, it doesn't take something that doesn't support streamable http and make it streamable http - that flag is for a server that's running AS streamable HTTP.

From the logs in the initial listing, it was trying to start with a blank config. I'm guess-suming /mcp-config.json isn't a valid path? Unless you're actually storing mcp-config in your system root.

<!-- gh-comment-id:3418751938 --> @taylorwilsdon commented on GitHub (Oct 18, 2025): What MCP are you actually running here? If it's actually mcp-server-time (https://github.com/Taki-Ta/mcp-server-time) that project does not appear to support streamable HTTP, so that's not going to work. mcpo is a proxy to expose an MCP as an OpenAPI spec tool server, it doesn't take something that doesn't support streamable http and make it streamable http - that flag is for a server that's running AS streamable HTTP. From the logs in the initial listing, it was trying to start with a blank config. I'm guess-suming `/mcp-config.json` isn't a valid path? Unless you're actually storing mcp-config in your system root.
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#119
No description provided.