> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-detect-table-modification.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Using ClickHouse MCP server with Open WebUI

> This guide explains how to set up Open WebUI with a ClickHouse MCP server using Docker.

export const Image = ({img, alt, size = "lg"}) => {
  const normalizedSize = ["sm", "md", "lg"].includes(size) ? size : "lg";
  return <div className={`ch-image-${normalizedSize}`}>
      <Frame>
        <img src={img} alt={alt} />
      </Frame>
    </div>;
};

> This guide explains how to set up [Open WebUI](https://github.com/open-webui/open-webui) with a ClickHouse MCP server
> and connect it to the ClickHouse example datasets.

<Steps>
  <Step title="Install uv" id="install-uv">
    You will need to install [uv](https://docs.astral.sh/uv/) to follow the instructions in this guide.
    If you don't want to use uv, you will need to update the MCP server config to use an alternative package manager.
  </Step>

  <Step title="Launch Open WebUI" id="launch-open-webui">
    To launch Open WebUI, you can run the following command:

    ```bash theme={null}
    uv run --with open-webui open-webui serve
    ```

    Navigate to [http://localhost:8080/](http://localhost:8080/) to see the UI.
  </Step>

  <Step title="Configure ClickHouse MCP server" id="configure-clickhouse-mcp-server">
    To setup the ClickHouse MCP server, we'll need to convert the MCP server to Open API endpoints.
    Let's first set environmental variables that will let us connect to the ClickHouse SQL Playground:

    ```bash theme={null}
    export CLICKHOUSE_HOST="sql-clickhouse.clickhouse.com"
    export CLICKHOUSE_USER="demo"
    export CLICKHOUSE_PASSWORD=""
    ```

    And, then, we can run `mcpo` to create the Open API endpoints:

    ```bash theme={null}
    uvx mcpo --port 8000 -- uv run --with mcp-clickhouse --python 3.10 mcp-clickhouse
    ```

    You can see a list of the endpoints created by navigating to [http://localhost:8000/docs](http://localhost:8000/docs)

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/pp61YI9DMmfgXVsV/images/use-cases/AI_ML/MCP/0_endpoints.webp?fit=max&auto=format&n=pp61YI9DMmfgXVsV&q=85&s=aa16a6c82ac5d5b989a980011a1c0de4" alt="Open API endpoints" size="md" width="1455" height="759" data-path="images/use-cases/AI_ML/MCP/0_endpoints.webp" />

    To use these endpoints with Open WebUI, we need to navigate to settings:

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/pp61YI9DMmfgXVsV/images/use-cases/AI_ML/MCP/1_settings.webp?fit=max&auto=format&n=pp61YI9DMmfgXVsV&q=85&s=27a96b58fbab21d72274e479ec8911a4" alt="Open WebUI settings" size="md" width="518" height="575" data-path="images/use-cases/AI_ML/MCP/1_settings.webp" />

    Click on `Tools`:

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/pp61YI9DMmfgXVsV/images/use-cases/AI_ML/MCP/2_tools_page.webp?fit=max&auto=format&n=pp61YI9DMmfgXVsV&q=85&s=2b3071c2901fb3daa0d61e9252e57a14" alt="Open WebUI tools" size="md" width="1829" height="1190" data-path="images/use-cases/AI_ML/MCP/2_tools_page.webp" />

    Add [http://localhost:8000](http://localhost:8000) as the tool URL:

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/pp61YI9DMmfgXVsV/images/use-cases/AI_ML/MCP/3_add_tool.webp?fit=max&auto=format&n=pp61YI9DMmfgXVsV&q=85&s=3fd5493b9ba5e58cb1d4005fae78efba" alt="Open WebUI tool" size="md" width="1838" height="1201" data-path="images/use-cases/AI_ML/MCP/3_add_tool.webp" />

    Once we've done this, we should see a `1` next to the tool icon on the chat bar:

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/pp61YI9DMmfgXVsV/images/use-cases/AI_ML/MCP/4_tools_available.webp?fit=max&auto=format&n=pp61YI9DMmfgXVsV&q=85&s=3dc06ad784894cb2a3b2b5f4937feaeb" alt="Open WebUI tools available" size="md" width="1495" height="229" data-path="images/use-cases/AI_ML/MCP/4_tools_available.webp" />

    If we click on the tool icon, we can then list the available tools:

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/pp61YI9DMmfgXVsV/images/use-cases/AI_ML/MCP/5_list_of_tools.webp?fit=max&auto=format&n=pp61YI9DMmfgXVsV&q=85&s=f2e6dd31561cba93b848f98007231d2d" alt="Open WebUI tool listing" size="md" width="1373" height="711" data-path="images/use-cases/AI_ML/MCP/5_list_of_tools.webp" />
  </Step>

  <Step title="Configure OpenAI" id="configure-openai">
    By default, Open WebUI works with Ollama models, but we can add OpenAI compatible endpoints as well.
    These are configured via the settings menu, but this time we need to click on the `Connections` tab:

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/pp61YI9DMmfgXVsV/images/use-cases/AI_ML/MCP/6_connections.webp?fit=max&auto=format&n=pp61YI9DMmfgXVsV&q=85&s=16f7771e6e98708d235c71b864a1e732" alt="Open WebUI connections" size="md" width="1824" height="1184" data-path="images/use-cases/AI_ML/MCP/6_connections.webp" />

    Let's add the endpoint and our OpenAI key:

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/pp61YI9DMmfgXVsV/images/use-cases/AI_ML/MCP/7_add_connection.webp?fit=max&auto=format&n=pp61YI9DMmfgXVsV&q=85&s=a0eb9a9abdd49e4c9d437deb0d0d0f9f" alt="Open WebUI - Add OpenAI as a connection" size="md" width="1821" height="1192" data-path="images/use-cases/AI_ML/MCP/7_add_connection.webp" />

    The OpenAI models will then be available on the top menu:

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/pp61YI9DMmfgXVsV/images/use-cases/AI_ML/MCP/8_openai_models_more.webp?fit=max&auto=format&n=pp61YI9DMmfgXVsV&q=85&s=500247a28f3bc62cc924de81c575d422" alt="Open WebUI - Models" size="md" width="1574" height="1248" data-path="images/use-cases/AI_ML/MCP/8_openai_models_more.webp" />
  </Step>

  <Step title="Chat to ClickHouse MCP server with Open WebUI" id="chat-to-clickhouse-mcp-server">
    We can then have a conversation and Open WebUI will call the MCP server if necessary:

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/pp61YI9DMmfgXVsV/images/use-cases/AI_ML/MCP/9_conversation.webp?fit=max&auto=format&n=pp61YI9DMmfgXVsV&q=85&s=3f86fc1b65c54dec828ba243ef7993c0" alt="Open WebUI - Chat with ClickHouse MCP server" size="md" width="2449" height="1839" data-path="images/use-cases/AI_ML/MCP/9_conversation.webp" />
  </Step>
</Steps>
