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

# Using ClickHouse MCP server with AnythingLLM

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

export const Image = ({img, alt, size}) => {
  return <Frame>
      <img src={img} alt={alt} />
    </Frame>;
};

> This guide explains how to set up [AnythingLLM](https://anythingllm.com/) with a ClickHouse MCP server using Docker
> and connect it to the ClickHouse example datasets.

<Steps>
  <Step>
    <h2 id="install-docker">
      Install Docker
    </h2>

    You will need Docker to run LibreChat and the MCP server. To get Docker:

    1. Visit [docker.com](https://www.docker.com/products/docker-desktop)
    2. Download Docker desktop for your operating system
    3. Install Docker by following the instructions for your operating system
    4. Open Docker Desktop and ensure it is running

    <br />

    For more information, see the [Docker documentation](https://docs.docker.com/get-docker/).
  </Step>

  <Step>
    <h2 id="pull-anythingllm-docker-image">
      Pull AnythingLLM Docker image
    </h2>

    Run the following command to pull the AnythingLLM Docker image to your machine:

    ```bash theme={null}
    docker pull anythingllm/anythingllm
    ```
  </Step>

  <Step>
    <h2 id="setup-storage-location">
      Setup storage location
    </h2>

    Create a directory for storage and initialize the environment file:

    ```bash theme={null}
    export STORAGE_LOCATION=$PWD/anythingllm && \
    mkdir -p $STORAGE_LOCATION && \
    touch "$STORAGE_LOCATION/.env" 
    ```
  </Step>

  <Step>
    <h2 id="configure-mcp-server-config-file">
      Configure MCP server config file
    </h2>

    Create the `plugins` directory:

    ```bash theme={null}
    mkdir -p "$STORAGE_LOCATION/plugins"
    ```

    Create a file called `anythingllm_mcp_servers.json` in the `plugins` directory and add the following contents:

    ```json theme={null}
    {
      "mcpServers": {
        "mcp-clickhouse": {
          "command": "uv",
          "args": [
            "run",
            "--with",
            "mcp-clickhouse",
            "--python",
            "3.10",
            "mcp-clickhouse"
          ],
          "env": {
            "CLICKHOUSE_HOST": "sql-clickhouse.clickhouse.com",
            "CLICKHOUSE_USER": "demo",
            "CLICKHOUSE_PASSWORD": ""
          }
        }
      }
    }
    ```

    If you want to explore your own data, you can do so by
    using the [host, username and password](/get-started/setup/cloud#connect-with-your-app)
    of your own ClickHouse Cloud service.
  </Step>

  <Step>
    <h2 id="start-anythingllm-docker-container">
      Start the AnythingLLM Docker container
    </h2>

    Run the following command to start the AnythingLLM Docker container:

    ```bash theme={null}
    docker run -p 3001:3001 \
    --cap-add SYS_ADMIN \
    -v ${STORAGE_LOCATION}:/app/server/storage \
    -v ${STORAGE_LOCATION}/.env:/app/server/.env \
    -e STORAGE_DIR="/app/server/storage" \
    mintplexlabs/anythingllm
    ```

    Once that's started, navigate to `http://localhost:3001` in your browser.
    Select the model that you want to use and provide your API key.
  </Step>

  <Step>
    <h2 id="wait-for-mcp-servers-to-start-up">
      Wait for MCP servers to start up
    </h2>

    Click on the tool icon in the bottom left-hand side of the UI:

    <Image img="https://mintcdn.com/private-7c7dfe99-home-button/KSay_cT2LdltZH8Z/images/use-cases/AI_ML/MCP/alm_tool-icon.png?fit=max&auto=format&n=KSay_cT2LdltZH8Z&q=85&s=4ef2e0bd84efc16790fc045c63547116" alt="Tool icon" size="md" width="1025" height="617" data-path="images/use-cases/AI_ML/MCP/alm_tool-icon.png" />

    Click on `Agent Skills` and look under the `MCP servers` section.
    Wait until you see `Mcp ClickHouse` set to `On`

    <Image img="https://mintcdn.com/private-7c7dfe99-home-button/KSay_cT2LdltZH8Z/images/use-cases/AI_ML/MCP/allm_mcp-servers.png?fit=max&auto=format&n=KSay_cT2LdltZH8Z&q=85&s=12e91f5725d79f433e98fa2b03b9e720" alt="MCP servers ready" size="md" width="690" height="933" data-path="images/use-cases/AI_ML/MCP/allm_mcp-servers.png" />
  </Step>

  <Step>
    <h2 id="chat-with-clickhouse-mcp-server-with-anythingllm">
      Chat with ClickHouse MCP server with AnythingLLM
    </h2>

    We're now ready to start a chat.
    To make MCP servers available to a chat, you'll need to prefix the first message in the conversation with `@agent`.

    <Image img="https://mintcdn.com/private-7c7dfe99-home-button/KSay_cT2LdltZH8Z/images/use-cases/AI_ML/MCP/allm_conversation.png?fit=max&auto=format&n=KSay_cT2LdltZH8Z&q=85&s=e287b777fd358b10cccfe349c387505e" alt="Conversation" size="md" width="1290" height="1575" data-path="images/use-cases/AI_ML/MCP/allm_conversation.png" />
  </Step>
</Steps>
