> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/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 = "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 [AnythingLLM](https://anythingllm.com/) with a ClickHouse MCP server using Docker
> and connect it to the ClickHouse example datasets.

<Steps>
  <Step title="Install Docker" id="install-docker">
    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 title="Pull AnythingLLM Docker image" id="pull-anythingllm-docker-image">
    Run the following command to pull the AnythingLLM Docker image to your machine:

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

  <Step title="Setup storage location" id="setup-storage-location">
    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 title="Configure MCP server config file" id="configure-mcp-server-config-file">
    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](/docs/get-started/setup/cloud#connect-with-your-app)
    of your own ClickHouse Cloud service.
  </Step>

  <Step title="Start the AnythingLLM Docker container" id="start-anythingllm-docker-container">
    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 title="Wait for MCP servers to start up" id="wait-for-mcp-servers-to-start-up">
    Click on the tool icon in the bottom left-hand side of the UI:

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

    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/F7iOqwDUBB9E2S65/images/use-cases/AI_ML/MCP/allm_mcp-servers.webp?fit=max&auto=format&n=F7iOqwDUBB9E2S65&q=85&s=c073f4fed5e6c7d35d65a63b077335a2" alt="MCP servers ready" size="md" width="690" height="933" data-path="images/use-cases/AI_ML/MCP/allm_mcp-servers.webp" />
  </Step>

  <Step title="Chat with ClickHouse MCP server with AnythingLLM" id="chat-with-clickhouse-mcp-server-with-anythingllm">
    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/F7iOqwDUBB9E2S65/images/use-cases/AI_ML/MCP/allm_conversation.webp?fit=max&auto=format&n=F7iOqwDUBB9E2S65&q=85&s=33c225adc816cbb72086d17a1dbfe3e8" alt="Conversation" size="md" width="1290" height="1575" data-path="images/use-cases/AI_ML/MCP/allm_conversation.webp" />
  </Step>
</Steps>
