# MCP Course: Error when running tiny-agents example

**URL:** <https://discuss.huggingface.co/t/mcp-course-error-when-running-tiny-agents-example/172083>\
**Category:** Course\
**Created:** [December 29, 2025, 8:09pm UTC](https://discuss.huggingface.co/t/mcp-course-error-when-running-tiny-agents-example/172083 "2025-12-29T20:09:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![krosenke](https://avatars.discourse-cdn.com/v4/letter/k/b5a626/32.png) [@krosenke](https://discuss.huggingface.co/u/krosenke)\
**Post date:** [December 29, 2025, 8:09pm UTC](https://discuss.huggingface.co/t/mcp-course-error-when-running-tiny-agents-example/172083/1 "2025-12-29T20:09:02Z")

</div>

Error when running tiny-agents example

I’m following the MCP course and I’m stuck at the end of the MCP Clients section. When running the command “tiny-agents run agent.json” I get the error below.  
I followed all instructions. What am I missing?

An unexpected error occurred: ‘config’  
Traceback (most recent call last):  
File “C:\Python312\Lib\site-packages\huggingface\_hub\inference\_mcp\cli.py”, line 134, in run\_agent  
await agent.load\_tools()  
File “C:\Python312\Lib\site-packages\huggingface\_hub\inference\_mcp\agent.py”, line 57, in load\_tools  
await self.add\_mcp\_server(cfg[“type”], \*\*cfg[“config”])  
~~~^^^^^^^^^^  
KeyError: ‘config’

An unexpected error occurred: ‘config’  
╭───────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────╮  
│ C:\Python312\Lib\site-packages\huggingface\_hub\inference\_mcp\cli.py:225 in run │  
│ │  
│ 222 │ │ raise typer.Exit(code=130) │  
│ 223 │ except Exception as e: │  
│ 224 │ │ print(f"\n[bold red]An unexpected error occurred: {e}[/bold red]“, flush=True) │  
│ ❱ 225 │ │ raise e │  
│ 226 │  
│ 227 │  
│ 228 if **name** == “ **main** ”: │  
│ │  
│ ╭────── locals ───────╮ │  
│ │ path = ‘agent.json’ │ │  
│ ╰─────────────────────╯ │  
│ │  
│ C:\Python312\Lib\site-packages\huggingface\_hub\inference\_mcp\cli.py:219 in run │  
│ │  
│ 216 │ ), │  
│ 217 ): │  
│ 218 │ try: │  
│ ❱ 219 │ │ asyncio.run(run\_agent(path)) │  
│ 220 │ except KeyboardInterrupt: │  
│ 221 │ │ print(”\n[red]Application terminated by KeyboardInterrupt.[/red]“, flush=True) │  
│ 222 │ │ raise typer.Exit(code=130) │  
│ │  
│ ╭────── locals ───────╮ │  
│ │ path = ‘agent.json’ │ │  
│ ╰─────────────────────╯ │  
│ │  
│ C:\Python312\Lib\asyncio\runners.py:194 in run │  
│ │  
│ 191 │ │ │ “asyncio.run() cannot be called from a running event loop”) │  
│ 192 │ │  
│ 193 │ with Runner(debug=debug, loop\_factory=loop\_factory) as runner: │  
│ ❱ 194 │ │ return runner.run(main) │  
│ 195 │  
│ 196 │  
│ 197 def \_cancel\_all\_tasks(loop): │  
│ │  
│ ╭─────────────────────────────── locals ───────────────────────────────╮ │  
│ │ debug = None │ │  
│ │ loop\_factory = None │ │  
│ │ main = \<coroutine object run\_agent at 0x000001F738D7C9F0\> │ │  
│ │ runner = \<asyncio.runners.Runner object at 0x000001F739D026C0\> │ │  
│ ╰──────────────────────────────────────────────────────────────────────╯ │  
│ │  
│ C:\Python312\Lib\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 0x000001F739D12840\> │ │  
│ │ coro = \<coroutine object run\_agent at 0x000001F738D7C9F0\> │ │  
│ │ self = \<asyncio.runners.Runner object at 0x000001F739D026C0\> │ │  
│ │ sigint\_handler = functools.partial(\<bound method Runner.\_on\_sigint of \<asyncio.runners.Runner object at │ │  
│ │ 0x000001F739D026C0\>\>, main\_task=\<Task finished name=‘Task-1’ coro=\<run\_agent() done, defined at │ │  
│ │ C:\Python312\Lib\site-packages\huggingface\_hub\inference\_mcp\cli.py:28\> │ │  
│ │ exception=KeyError(‘config’)\>) │ │  
│ │ task = \<Task finished name=‘Task-1’ coro=\<run\_agent() done, defined at │ │  
│ │ C:\Python312\Lib\site-packages\huggingface\_hub\inference\_mcp\cli.py:28\> │ │  
│ │ exception=KeyError(‘config’)\> │ │  
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │  
│ │  
│ C:\Python312\Lib\asyncio\base\_events.py:687 in run\_until\_complete │  
│ │  
│ 684 │ │ if not future.done(): │  
│ 685 │ │ │ raise RuntimeError(‘Event loop stopped before Future completed.’) │  
│ 686 │ │ │  
│ ❱ 687 │ │ return future.result() │  
│ 688 │ │  
│ 689 │ def stop(self): │  
│ 690 │ │ “”“Stop running the event loop. │  
│ │  
│ ╭───────────────────────────────────────────────────── locals ─────────────────────────────────────────────────────╮ │  
│ │ future = \<Task finished name=‘Task-1’ coro=\<run\_agent() done, defined at │ │  
│ │ C:\Python312\Lib\site-packages\huggingface\_hub\inference\_mcp\cli.py:28\> │ │  
│ │ exception=KeyError(‘config’)\> │ │  
│ │ new\_task = False │ │  
│ │ self = │ │  
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │  
│ │  
│ C:\Python312\Lib\site-packages\huggingface\_hub\inference\_mcp\cli.py:194 in run\_agent │  
│ │  
│ 191 │ except Exception as e: │  
│ 192 │ │ tb\_str = traceback.format\_exc() │  
│ 193 │ │ print(f”\n[bold red]An unexpected error occurred: {e}\n{tb\_str}[/bold red]”, flu │  
│ ❱ 194 │ │ raise e │  
│ 195 │ │  
│ 196 │ finally: │  
│ 197 │ │ if sigint\_registered\_in\_loop: │  
│ │  
│ ╭───────────────────────────────────────────────────── locals ─────────────────────────────────────────────────────╮ │  
│ │ abort\_event = \<asyncio.locks.Event object at 0x000001F739DE9340 [unset]\> │ │  
│ │ agent = \<huggingface\_hub.inference.\_mcp.agent.Agent object at 0x000001F739DE93A0\> │ │  
│ │ agent\_path = ‘agent.json’ │ │  
│ │ config = { │ │  
│ │ │ ‘model’: ‘Qwen/Qwen2.5-72B-Instruct’, │ │  
│ │ │ ‘provider’: ‘nebius’, │ │  
│ │ │ ‘servers’: [ │ │  
│ │ │ │ {‘type’: ‘stdio’, ‘command’: ‘npx’, ‘args’: [‘@playwright/mcp@latest’]} │ │  
│ │ │ ] │ │  
│ │ } │ │  
│ │ exit\_event = \<asyncio.locks.Event object at 0x000001F739DE9370 [unset]\> │ │  
│ │ first\_sigint = True │ │  
│ │ inputs = │ │  
│ │ loop = │ │  
│ │ original\_sigint\_handler = functools.partial(\<bound method Runner.\_on\_sigint of \<asyncio.runners.Runner object │ │  
│ │ at 0x000001F739D026C0\>\>, main\_task=\<Task finished name=‘Task-1’ coro=\<run\_agent() │ │  
│ │ done, defined at │ │  
│ │ C:\Python312\Lib\site-packages\huggingface\_hub\inference\_mcp\cli.py:28\> │ │  
│ │ exception=KeyError(‘config’)\>) │ │  
│ │ prompt = None │ │  
│ │ servers = [{‘type’: ‘stdio’, ‘command’: ‘npx’, ‘args’: [‘@playwright/mcp@latest’]}] │ │  
│ │ sigint\_registered\_in\_loop = False │ │  
│ │ tb\_str = ‘Traceback (most recent call last):\n File │ │  
│ │ “C:\Python312\Lib\site-packag’+346 │ │  
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │  
│ │  
│ C:\Python312\Lib\site-packages\huggingface\_hub\inference\_mcp\cli.py:134 in run\_agent │  
│ │  
│ 131 │ │ │ servers=servers, │  
│ 132 │ │ │ prompt=prompt, │  
│ 133 │ │ ) as agent: │  
│ ❱ 134 │ │ │ await agent.load\_tools() │  
│ 135 │ │ │ print(f”[bold blue]Agent loaded with {len(agent.available\_tools)} tools:[/bo │  
│ 136 │ │ │ for t in agent.available\_tools: │  
│ 137 │ │ │ │ print(f"[blue] • {t.function.name}[/blue]") │  
│ │  
│ ╭───────────────────────────────────────────────────── locals ─────────────────────────────────────────────────────╮ │  
│ │ abort\_event = \<asyncio.locks.Event object at 0x000001F739DE9340 [unset]\> │ │  
│ │ agent = \<huggingface\_hub.inference.\_mcp.agent.Agent object at 0x000001F739DE93A0\> │ │  
│ │ agent\_path = ‘agent.json’ │ │  
│ │ config = { │ │  
│ │ │ ‘model’: ‘Qwen/Qwen2.5-72B-Instruct’, │ │  
│ │ │ ‘provider’: ‘nebius’, │ │  
│ │ │ ‘servers’: [ │ │  
│ │ │ │ {‘type’: ‘stdio’, ‘command’: ‘npx’, ‘args’: [‘@playwright/mcp@latest’]} │ │  
│ │ │ ] │ │  
│ │ } │ │  
│ │ exit\_event = \<asyncio.locks.Event object at 0x000001F739DE9370 [unset]\> │ │  
│ │ first\_sigint = True │ │  
│ │ inputs = │ │  
│ │ loop = │ │  
│ │ original\_sigint\_handler = functools.partial(\<bound method Runner.\_on\_sigint of \<asyncio.runners.Runner object │ │  
│ │ at 0x000001F739D026C0\>\>, main\_task=\<Task finished name=‘Task-1’ coro=\<run\_agent() │ │  
│ │ done, defined at │ │  
│ │ C:\Python312\Lib\site-packages\huggingface\_hub\inference\_mcp\cli.py:28\> │ │  
│ │ exception=KeyError(‘config’)\>) │ │  
│ │ prompt = None │ │  
│ │ servers = [{‘type’: ‘stdio’, ‘command’: ‘npx’, ‘args’: [‘@playwright/mcp@latest’]}] │ │  
│ │ sigint\_registered\_in\_loop = False │ │  
│ │ tb\_str = ‘Traceback (most recent call last):\n File │ │  
│ │ "C:\Python312\Lib\site-packag’+346 │ │  
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │  
│ │  
│ C:\Python312\Lib\site-packages\huggingface\_hub\inference\_mcp\agent.py:57 in load\_tools │  
│ │  
│ 54 │ │  
│ 55 │ async def load\_tools(self) → None: │  
│ 56 │ │ for cfg in self.\_servers\_cfg: │  
│ ❱ 57 │ │ │ await self.add\_mcp\_server(cfg[“type”], \*\*cfg[“config”]) │  
│ 58 │ │  
│ 59 │ async def run( │  
│ 60 │ │ self, │  
│ │  
│ ╭───────────────────────────────────── locals ─────────────────────────────────────╮ │  
│ │ cfg = {‘type’: ‘stdio’, ‘command’: ‘npx’, ‘args’: [‘@playwright/mcp@latest’]} │ │  
│ │ self = \<huggingface\_hub.inference.\_mcp.agent.Agent object at 0x000001F739DE93A0\> │ │  
│ ╰──────────────────────────────────────────────────────────────────────────────────╯ │  
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯  
KeyError: ‘config’

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [December 29, 2025, 11:42pm UTC](https://discuss.huggingface.co/t/mcp-course-error-when-running-tiny-agents-example/172083/2 "2025-12-29T23:42:04Z")

</div>

The probable cause seems to be this.

* * *

### Root cause

You are running a **Python** Tiny Agents runner (traceback is in `huggingface_hub ... inference_mcp ... cli.py`). That runner iterates `servers` and does `cfg["config"]`. Your `agent.json` has a server entry with **no** `"config"` key, so it crashes with `KeyError: 'config'`.

This happens because the HF course and HF JS docs show a **different** (flat) server shape that is valid for the **JS** CLI (`npx @huggingface/tiny-agents ...`), while some **Python** runners expect a nested `"config"` object.

You can see the course page showing a flat server entry (`command` and `args` at the top level) and telling you to run with `npx @huggingface/tiny-agents run agent.json`. ([Hugging Face](https://huggingface.co/learn/mcp-course/en/unit2/tiny-agents "Building Tiny Agents with MCP and the Hugging Face Hub - Hugging Face MCP Course"))  
You can also see the JS tiny-agents docs showing the same flat shape and the same `npx @huggingface/tiny-agents run ...` usage. ([Hugging Face](https://huggingface.co/docs/huggingface.js/en/tiny-agents/README "@huggingface/tiny-agents"))

Separately, you can see configs that use the nested `"config"` shape in the wild (example: AMD’s guide uses `"config": {"command": "...npx.cmd", "args": ["-y", ...]}`) while still running `tiny-agents run`. ([AMD](https://www.amd.com/ja/developer/resources/technical-articles/2025/local-tiny-agents--mcp-agents-on-ryzen-ai-with-lemonade-server.html "Local Tiny Agents: MCP Agents on Ryzen AI with Lemonade Server"))

* * *

## Why there are two shapes (background)

### Shape A. “Flat server object” (common in JS tiny-agents examples)

Used in:

- HF MCP course “Tiny Agents MCP Client in the Command Line” example JSON. ([Hugging Face](https://huggingface.co/learn/mcp-course/en/unit2/tiny-agents "Building Tiny Agents with MCP and the Hugging Face Hub - Hugging Face MCP Course"))
- HF JS tiny-agents docs example JSON. ([Hugging Face](https://huggingface.co/docs/huggingface.js/en/tiny-agents/README "@huggingface/tiny-agents"))

Looks like:

```json
{
  "type": "stdio",
  "command": "npx",
  "args": ["@playwright/mcp@latest"]
}

```

### Shape B. “Nested config” (some Python runners and other guides)

Used in:

- AMD guide example JSON (explicitly shows `config` nesting and Windows `npx.cmd`). ([AMD](https://www.amd.com/ja/developer/resources/technical-articles/2025/local-tiny-agents--mcp-agents-on-ryzen-ai-with-lemonade-server.html "Local Tiny Agents: MCP Agents on Ryzen AI with Lemonade Server"))
- HF Hub issue reports also discuss nested `config` being passed around and causing KeyErrors depending on the library version. ([GitHub](https://github.com/huggingface/huggingface_hub/issues/3203 "KeyError: 'command' in add\_mcp\_server when running tiny-agent due to incorrect params structure · Issue #3203 · huggingface/huggingface\_hub · GitHub"))

Looks like:

```json
{
  "type": "stdio",
  "config": {
    "command": "npx",
    "args": ["@playwright/mcp@latest"]
  }
}

```

### Why it’s confusing

The course page is explicitly teaching the **JS** CLI path (`npx @huggingface/tiny-agents ...`) and shows the flat JSON. ([Hugging Face](https://huggingface.co/learn/mcp-course/en/unit2/tiny-agents "Building Tiny Agents with MCP and the Hugging Face Hub - Hugging Face MCP Course"))  
But your command `tiny-agents run agent.json` is executing a **Python** -installed command (based on the traceback path). That Python runner expects the nested key and fails.

* * *

## Fix 1 (most direct): add `"config"` in your `agent.json`

Replace your server entry:

```json
{ "type": "stdio", "command": "npx", "args": ["@playwright/mcp@latest"] }

```

With:

```json
{
  "type": "stdio",
  "config": {
    "command": "npx",
    "args": ["@playwright/mcp@latest"]
  }
}

```

Full example matching your model/provider:

```json
{
  "model": "Qwen/Qwen2.5-72B-Instruct",
  "provider": "nebius",
  "servers": [
    {
      "type": "stdio",
      "config": {
        "command": "npx",
        "args": ["@playwright/mcp@latest"]
      }
    }
  ]
}

```

### Windows-hardening tweaks (strongly recommended)

On Windows, it is often more reliable to point to `npx.cmd` explicitly and disable prompts:

AMD’s working Windows example uses a full path to `npx.cmd` and passes `-y` in args. ([AMD](https://www.amd.com/ja/developer/resources/technical-articles/2025/local-tiny-agents--mcp-agents-on-ryzen-ai-with-lemonade-server.html "Local Tiny Agents: MCP Agents on Ryzen AI with Lemonade Server"))

So you can do:

```json
{
  "type": "stdio",
  "config": {
    "command": "C:\\Program Files\\nodejs\\npx.cmd",
    "args": ["-y", "@playwright/mcp@latest"]
  }
}

```

* * *

## Fix 2 (keep the course JSON): run the JS CLI exactly as the course says

If you want to keep the **flat** server JSON as shown in the course, run it the way the course instructs:

- `npx @huggingface/tiny-agents run agent.json` ([Hugging Face](https://huggingface.co/learn/mcp-course/en/unit2/tiny-agents "Building Tiny Agents with MCP and the Hugging Face Hub - Hugging Face MCP Course"))

This matches the flat schema shown in both the course and the JS docs. ([Hugging Face](https://huggingface.co/learn/mcp-course/en/unit2/tiny-agents "Building Tiny Agents with MCP and the Hugging Face Hub - Hugging Face MCP Course"))

* * *

## Version drift is real (why you see KeyErrors at all)

Hugging Face has a known class of issues where the runner expects one structure but receives the other. Example: a Hub issue report shows `KeyError: 'command'` when a nested `config` dict is provided but the underlying code expects `params["command"]` at the top level. ([GitHub](https://github.com/huggingface/huggingface_hub/issues/3203 "KeyError: 'command' in add\_mcp\_server when running tiny-agent due to incorrect params structure · Issue #3203 · huggingface/huggingface\_hub · GitHub"))

Your case is the mirror image: the runner expects `cfg["config"]`, but your JSON is flat.

This is why two people can “follow the docs” and still hit different KeyErrors.

* * *

## Quick sanity checks (so you stop guessing)

### 1) Confirm which `tiny-agents` you are running

Your traceback indicates Python, but you can confirm by checking where the executable resolves:

- Windows: `where tiny-agents`

If it points into a Python Scripts directory, you are on the Python runner.

### 2) Confirm you installed the course’s prerequisites

The course explicitly says you need Node tooling (`npm` and `npx`) even if you are using Python, and it shows installing `huggingface_hub[mcp]` with a minimum version. ([Hugging Face](https://huggingface.co/learn/mcp-course/en/unit1/mcp-clients "MCP Clients - Hugging Face MCP Course"))

* * *

## High-quality references (keep these open while debugging)

- HF MCP Course Unit 2 Tiny Agents page (shows flat JSON + `npx @huggingface/tiny-agents run ...`).  
[https://huggingface.co/learn/mcp-course/en/unit2/tiny-agents](https://huggingface.co/learn/mcp-course/en/unit2/tiny-agents) ([Hugging Face](https://huggingface.co/learn/mcp-course/en/unit2/tiny-agents "Building Tiny Agents with MCP and the Hugging Face Hub - Hugging Face MCP Course"))

- HF JS tiny-agents docs (flat JSON examples and CLI usage).  
[https://huggingface.co/docs/huggingface.js/en/tiny-agents/README](https://huggingface.co/docs/huggingface.js/en/tiny-agents/README)_toggle “Define your own agent”_ ([Hugging Face](https://huggingface.co/docs/huggingface.js/en/tiny-agents/README "@huggingface/tiny-agents"))

- HF Hub MCP Python reference (defines stdio params like `command`, `args`, `env`, `cwd`).  
[https://huggingface.co/docs/huggingface\_hub/en/package\_reference/mcp](https://huggingface.co/docs/huggingface_hub/en/package_reference/mcp) ([Hugging Face](https://huggingface.co/docs/huggingface_hub/en/package_reference/mcp "MCP Client"))

- HF Hub issue illustrating schema mismatch leading to KeyErrors (`KeyError: 'command'`).  
[https://github.com/huggingface/huggingface\_hub/issues/3203](https://github.com/huggingface/huggingface_hub/issues/3203) ([GitHub](https://github.com/huggingface/huggingface_hub/issues/3203 "KeyError: 'command' in add\_mcp\_server when running tiny-agent due to incorrect params structure · Issue #3203 · huggingface/huggingface\_hub · GitHub"))

- AMD guide showing a working Windows nested `config` + `npx.cmd` + `-y` pattern.  
[https://www.amd.com/ja/developer/resources/technical-articles/2025/local-tiny-agents–mcp-agents-on-ryzen-ai-with-lemonade-server.html](https://www.amd.com/ja/developer/resources/technical-articles/2025/local-tiny-agents--mcp-agents-on-ryzen-ai-with-lemonade-server.html) ([AMD](https://www.amd.com/ja/developer/resources/technical-articles/2025/local-tiny-agents--mcp-agents-on-ryzen-ai-with-lemonade-server.html "Local Tiny Agents: MCP Agents on Ryzen AI with Lemonade Server"))

* * *

### Summary

- Your error is exactly: runner expects `servers[*].config`, your JSON does not have it.
- Fix path A: nest `command` and `args` under `"config"`.
- Fix path B: keep flat JSON and run with `npx @huggingface/tiny-agents ...` as the course shows.
- On Windows, prefer `npx.cmd` and `-y` for reliability.

---

<div class="post-metadata">

**Author:** ![krosenke](https://avatars.discourse-cdn.com/v4/letter/k/b5a626/32.png) [@krosenke](https://discuss.huggingface.co/u/krosenke)\
**Post date:** [December 31, 2025, 4:46pm UTC](https://discuss.huggingface.co/t/mcp-course-error-when-running-tiny-agents-example/172083/3 "2025-12-31T16:46:09Z")

</div>

Thank you for the detailed explanation! It helped me to resolve the issue.

I used option 1 and added “config” to the json file.

**Notes:**

- I got this error and fixed it by changing the provider to novita:

`Error during agent run: Model Qwen/Qwen2.5-72B-Instruct is not supported by provider nebius.`

- There is no video on page [https://huggingface.co/learn/mcp-course/en/unit1/mcp-clients#setup](https://huggingface.co/learn/mcp-course/en/unit1/mcp-clients#setup); only a picture is displayed.

---

<div class="post-metadata">

**Author:** ![Robeee](https://avatars.discourse-cdn.com/v4/letter/r/3be4f8/32.png) [@Robeee](https://discuss.huggingface.co/u/Robeee)\
**Post date:** [January 13, 2026, 5:20am UTC](https://discuss.huggingface.co/t/mcp-course-error-when-running-tiny-agents-example/172083/4 "2026-01-13T05:20:20Z")

</div>

Hi there if you’re still stuck with this error I just overcame it by searching for what models does nebius support and got this huggingface link: [Models available on Nebius AI – Hugging Face](https://huggingface.co/models?inference_provider=nebius)

The model i switched to was `Qwen/Qwen3-30B-A3B-Instruct-2507` and it fixed the error for me.

All the best
