Using ClickHouse MCP server with AnythingLLM

[Edit this page](https://github.com/ClickHouse/clickhouse-docs/blob/main/docs/use-cases/AI_ML/MCP/04_anythingllm.md)

> 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.

Install Docker

## Install Docker[​](#install-docker "Direct link to 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

  

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

Pull AnythingLLM Docker image

## Pull AnythingLLM Docker image[​](#pull-anythingllm-docker-image "Direct link to Pull AnythingLLM Docker image")

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

```
docker pull anythingllm/anythingllm
```

Setup storage location

## Setup storage location[​](#setup-storage-location "Direct link to Setup storage location")

Create a directory for storage and initialize the environment file:

```
export STORAGE_LOCATION=$PWD/anythingllm && \
mkdir -p $STORAGE_LOCATION && \
touch "$STORAGE_LOCATION/.env"
```

Configure MCP server config file

## Configure MCP server config file[​](#configure-mcp-server-config-file "Direct link to Configure MCP server config file")

Create the `plugins` directory:

```
mkdir -p "$STORAGE_LOCATION/plugins"
```

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

```
{
  "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](https://clickhouse.com/docs/getting-started/quick-start/cloud#connect-with-your-app)
of your own ClickHouse Cloud service.

Start the AnythingLLM Docker container

## Start the AnythingLLM Docker container[​](#start-anythingllm-docker-container "Direct link to Start the AnythingLLM Docker container")

Run the following command to start the AnythingLLM Docker container:

```
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.

Wait for MCP servers to start up

## Wait for MCP servers to start up[​](#wait-for-mcp-servers-to-start-up "Direct link to Wait for MCP servers to start up")

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

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

Chat with ClickHouse MCP server with AnythingLLM

## Chat with ClickHouse MCP server with AnythingLLM[​](#chat-with-clickhouse-mcp-server-with-anythingllm "Direct link to 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`.

- [Install Docker](#install-docker)- [Pull AnythingLLM Docker image](#pull-anythingllm-docker-image)- [Setup storage location](#setup-storage-location)- [Configure MCP server config file](#configure-mcp-server-config-file)- [Start the AnythingLLM Docker container](#start-anythingllm-docker-container)- [Wait for MCP servers to start up](#wait-for-mcp-servers-to-start-up)- [Chat with ClickHouse MCP server with AnythingLLM](#chat-with-clickhouse-mcp-server-with-anythingllm)

Was this page helpful?