# Setting Up Hugging Face and DeepWiki MCP Servers with Per-Chat Opt-In in Bonsai

> Easily set up Hugging Face and DeepWiki MCP servers with per-chat opt-in in Bonsai. Control token costs by enabling these AI tools only when needed for specific conversations via Open WebUI.

- Repository: [PrismML-Eng/Bonsai-demo](https://github.com/PrismML-Eng/Bonsai-demo)
- Tags: how-to-guide
- Published: 2026-07-17

---

**The Bonsai demo automatically configures Hugging Face and DeepWiki as key-less MCP tool servers that users can toggle on a per-chat basis via the Open WebUI interface, incurring token costs only when enabled for specific conversations.**

The Bonsai demo repository provides pre-configured integrations with Hugging Face and DeepWiki through the Model Center Protocol (MCP), enabling powerful tool-calling capabilities without requiring API keys. These remote MCP servers are implemented with a per-chat opt-in mechanism that allows users to selectively enable tool access for individual conversations. This guide explains how the configuration works in [`scripts/start_openwebui.sh`](https://github.com/PrismML-Eng/Bonsai-demo/blob/main/scripts/start_openwebui.sh) and how to manage these servers both globally and at the conversation level.

## How Per-Chat MCP Opt-In Works in Bonsai

The Bonsai demo ships with two remote MCP tool servers—**Hugging Face** and **DeepWiki**—that are automatically made available to the Open WebUI chat interface. Unlike many tool integrations, these are **key-less services**, meaning no API tokens are required to authenticate requests.

When Open WebUI starts via [`scripts/start_openwebui.sh`](https://github.com/PrismML-Eng/Bonsai-demo/blob/main/scripts/start_openwebui.sh), the script constructs a JSON list of tool-server connections and stores it in the `TOOL_SERVER_CONNECTIONS` environment variable (lines 19-22). This list populates the **MCP selector** dropdown in the chat message box, allowing users to enable servers for individual conversations. Once toggled on, the tool schemas are injected into the system prompt for that chat only, with costs of approximately **2,600 tokens for Hugging Face** and **400 tokens for DeepWiki** added once per conversation rather than per request.

## Configuring the Default MCP Servers

### Understanding the Configuration Files

The default server list is defined in [`scripts/webui-config.json`](https://github.com/PrismML-Eng/Bonsai-demo/blob/main/scripts/webui-config.json), which contains a JSON array passed to the startup script via the `mcpServers` key (lines 1-2). This configuration includes both Hugging Face and DeepWiki entries with `enabled: true` by default:

```json
{
  "mcpServers": "[{\"id\":\"huggingface\",\"enabled\":true,\"name\":\"Hugging Face\",\"url\":\"https://huggingface.co/mcp\",\"requestTimeoutSeconds\":300},{\"id\":\"deepwiki\",\"enabled\":true,\"name\":\"DeepWiki\",\"url\":\"https://mcp.deepwiki.com/mcp\",\"requestTimeoutSeconds\":300}]",
  "showToolCallInProgress": true
}

```

### Environment Variable Setup

The [`scripts/start_openwebui.sh`](https://github.com/PrismML-Eng/Bonsai-demo/blob/main/scripts/start_openwebui.sh) script processes this configuration starting at **line 90**, assembling the final JSON array and exporting it as `TOOL_SERVER_CONNECTIONS`. The script concatenates the base servers with optional Brave Search if a `BRAVE_API_KEY` is present:

```bash

# From scripts/start_openwebui.sh (lines 19-22)

export TOOL_SERVER_CONNECTIONS='[
  {"id":"huggingface","type":"mcp","url":"https://huggingface.co/mcp","path":"","auth_type":"none","key":"","config":{"enable":true},"info":{"id":"huggingface","name":"Hugging Face","description":"Hugging Face MCP server"}},
  {"id":"deepwiki","type":"mcp","url":"https://mcp.deepwiki.com/mcp","path":"","auth_type":"none","key":"","config":{"enable":true},"info":{"id":"deepwiki","name":"DeepWiki","description":"DeepWiki MCP server"}}
]'

```

## Enabling and Disabling MCP Servers

### Global Configuration Changes

To disable a server globally, edit [`scripts/webui-config.json`](https://github.com/PrismML-Eng/Bonsai-demo/blob/main/scripts/webui-config.json) and set `"enabled":false` for the desired entry:

```bash
nano scripts/webui-config.json

```

Change the specific server entry:

```json
{
  "mcpServers": "[{\"id\":\"huggingface\",\"enabled\":true,\"name\":\"Hugging Face\",\"url\":\"https://huggingface.co/mcp\",\"requestTimeoutSeconds\":300},{\"id\":\"deepwiki\",\"enabled\":false,\"name\":\"DeepWiki\",\"url\":\"https://mcp.deepwiki.com/mcp\",\"requestTimeoutSeconds\":300}]",
  "showToolCallInProgress": true
}

```

Restart Open WebUI to apply changes:

```bash
./scripts/start_openwebui.sh

```

### Per-Chat UI Toggle

For per-chat opt-in without modifying configuration files:

1. Navigate to `http://localhost:9090` and start a new chat
2. Click the **MCP selector** (gear icon) at the bottom-right of the message box
3. Toggle **Hugging Face** or **DeepWiki** to *on*
4. The model can now call tools like `hf_fs`, `hub_repo_search`, or `deepwiki_query` for that conversation only

## Adding Custom MCP Servers

To extend the setup with additional MCP servers (such as a self-hosted instance), append a new JSON object to the `TOOL_SERVER_CONNECTIONS` export in [`scripts/start_openwebui.sh`](https://github.com/PrismML-Eng/Bonsai-demo/blob/main/scripts/start_openwebui.sh):

```bash

# Example custom server configuration

_CUSTOM_MCP=',{"id":"mydemo","type":"mcp","url":"http://127.0.0.1:9000/mcp","path":"","auth_type":"none","key":"","config":{"enable":true},"info":{"id":"mydemo","name":"My Demo","description":"Local MCP demo server"}}'

export TOOL_SERVER_CONNECTIONS='[
  {"id":"huggingface","type":"mcp","url":"https://huggingface.co/mcp","path":"","auth_type":"none","key":"","config":{"enable":true},"info":{"id":"huggingface","name":"Hugging Face","description":"Hugging Face MCP server"}},
  {"id":"deepwiki","type":"mcp","url":"https://mcp.deepwiki.com/mcp","path":"","auth_type":"none","key":"","config":{"enable":true},"info":{"id":"deepwiki","name":"DeepWiki","description":"DeepWiki MCP server"}},
  '"${_CUSTOM_MCP}"'
]'

```

After restarting, the new server appears in the MCP selector alongside the default options. See [`AGENTS.md`](https://github.com/PrismML-Eng/Bonsai-demo/blob/main/AGENTS.md) in the repository for additional details on programmatic server registration.

## Summary

- The Bonsai demo configures Hugging Face and DeepWiki as **key-less MCP servers** in [`scripts/webui-config.json`](https://github.com/PrismML-Eng/Bonsai-demo/blob/main/scripts/webui-config.json)
- The [`scripts/start_openwebui.sh`](https://github.com/PrismML-Eng/Bonsai-demo/blob/main/scripts/start_openwebui.sh) script exports these as `TOOL_SERVER_CONNECTIONS` at lines 19-22
- Users can **toggle servers per-chat** via the MCP selector in the Open WebUI interface
- Token costs (~2,600 for Hugging Face, ~400 for DeepWiki) are incurred **once per conversation** only when enabled
- Global defaults can be modified by editing the JSON configuration and restarting the service

## Frequently Asked Questions

### Do I need API keys to use the Hugging Face and DeepWiki MCP servers?

No. Both servers are configured with `auth_type:"none"` and empty `key` fields in [`scripts/start_openwebui.sh`](https://github.com/PrismML-Eng/Bonsai-demo/blob/main/scripts/start_openwebui.sh). These are public, key-less services that work out-of-the-box without any environment variables or authentication tokens.

### How much do the MCP tools cost in terms of tokens?

When enabled for a chat, the Hugging Face MCP server adds approximately **2,600 tokens** to the system prompt, while DeepWiki adds approximately **400 tokens**. These costs are incurred **once per conversation** when you toggle the server on, not per individual tool call or request.

### Can I disable the MCP servers by default but allow users to opt-in per chat?

Yes. Edit [`scripts/webui-config.json`](https://github.com/PrismML-Eng/Bonsai-demo/blob/main/scripts/webui-config.json) and set `"enabled":false` for either or both servers. They will remain available in the MCP selector dropdown, but users must explicitly toggle them on for each conversation. The `enabled` flag in the configuration only controls the default state, not availability.

### Where can I find more information about the MCP tool specifications?

The [`TOOLS.md`](https://github.com/PrismML-Eng/Bonsai-demo/blob/main/TOOLS.md) file in the Bonsai-demo repository contains user-facing documentation describing the MCP servers, per-chat opt-in mechanics, and token costs. For programmatic configuration details, refer to [`AGENTS.md`](https://github.com/PrismML-Eng/Bonsai-demo/blob/main/AGENTS.md) and examine the [`scripts/start_openwebui.sh`](https://github.com/PrismML-Eng/Bonsai-demo/blob/main/scripts/start_openwebui.sh) implementation around lines 19-22 and 90.