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

# 将 ClickHouse MCP 服务器与 Jan.ai 搭配使用

> 本指南介绍如何为 Jan.ai 配置 ClickHouse MCP 服务器。

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>;
};

> 本指南介绍如何将 ClickHouse MCP 服务器与 [Jan.ai](https://jan.ai/docs) 搭配使用。

<Steps>
  <Step title="安装 Jan.ai" id="install-janai">
    Jan.ai 是一款开源的 ChatGPT 替代方案，可 100% 离线运行。
    你可以下载适用于 [Mac](https://jan.ai/docs/desktop/install/mac)、[Windows](https://jan.ai/docs/desktop/windows) 或 [Linux](https://jan.ai/docs/desktop/linux) 的 Jan.ai。

    它是一款原生应用，因此下载后即可启动。
  </Step>

  <Step title="将 LLM 添加到 Jan.ai" id="add-llm-to-janai">
    我们可以通过设置菜单启用模型。

    要启用 OpenAI，我们需要提供一个 API key，如下所示：

    <Image img="https://mintcdn.com/private-7c7dfe99-vortex-format/mc_CXbtYxT_GqYxL/images/use-cases/AI_ML/MCP/0_janai_openai.webp?fit=max&auto=format&n=mc_CXbtYxT_GqYxL&q=85&s=fe83f0485f0ea553894c5e85e00371de" alt="启用 OpenAI 模型" size="md" width="938" height="359" data-path="images/use-cases/AI_ML/MCP/0_janai_openai.webp" />
  </Step>

  <Step title="启用 MCP servers" id="enable-mcp-servers">
    在撰写本文时，`MCP servers` 是 Jan.ai 中的一项 Experimental 功能。
    我们可以通过打开 experimental features 来启用它们：

    <Image img="https://mintcdn.com/private-7c7dfe99-vortex-format/mc_CXbtYxT_GqYxL/images/use-cases/AI_ML/MCP/1_janai_mcp_servers.webp?fit=max&auto=format&n=mc_CXbtYxT_GqYxL&q=85&s=1654250722ffdaa13ecadaab798bfd25" alt="启用 MCP servers" size="md" width="1320" height="325" data-path="images/use-cases/AI_ML/MCP/1_janai_mcp_servers.webp" />

    打开该开关后，我们会在左侧菜单中看到 `MCP servers`。
  </Step>

  <Step title="配置 ClickHouse MCP 服务器" id="configure-clickhouse-mcp-server">
    如果我们点击 `MCP servers` 菜单，就会看到一个可连接的 MCP servers 列表：

    <Image img="https://mintcdn.com/private-7c7dfe99-vortex-format/mc_CXbtYxT_GqYxL/images/use-cases/AI_ML/MCP/2_janai_mcp_servers_list.webp?fit=max&auto=format&n=mc_CXbtYxT_GqYxL&q=85&s=6642bba8b849a39155da8387930a639e" alt="MCP servers 列表" size="md" width="1061" height="793" data-path="images/use-cases/AI_ML/MCP/2_janai_mcp_servers_list.webp" />

    这些服务器默认都是禁用的，但我们可以通过点击开关来启用它们。

    要安装 ClickHouse MCP 服务器，我们需要点击 `+` 图标，然后用以下内容填写表单：

    <Image img="https://mintcdn.com/private-7c7dfe99-vortex-format/mc_CXbtYxT_GqYxL/images/use-cases/AI_ML/MCP/3_janai_add_mcp_server.webp?fit=max&auto=format&n=mc_CXbtYxT_GqYxL&q=85&s=c08ee415f87b00bee1321888a40ed74f" alt="添加 MCP server" size="md" width="543" height="551" data-path="images/use-cases/AI_ML/MCP/3_janai_add_mcp_server.webp" />

    完成后，如果 ClickHouse Server 尚未开启，我们需要将其切换为开启状态：

    <Image img="https://mintcdn.com/private-7c7dfe99-vortex-format/mc_CXbtYxT_GqYxL/images/use-cases/AI_ML/MCP/4_janai_toggle.webp?fit=max&auto=format&n=mc_CXbtYxT_GqYxL&q=85&s=8366ec7549bea9a5d609b32d8a199709" alt="启用 MCP server" size="md" width="759" height="147" data-path="images/use-cases/AI_ML/MCP/4_janai_toggle.webp" />

    现在，ClickHouse MCP 服务器的工具将显示在聊天对话中：

    <Image img="https://mintcdn.com/private-7c7dfe99-vortex-format/mc_CXbtYxT_GqYxL/images/use-cases/AI_ML/MCP/5_jani_tools.webp?fit=max&auto=format&n=mc_CXbtYxT_GqYxL&q=85&s=8e1784b6818aef6d3b50bda82dbb0690" alt="ClickHouse MCP 服务器工具" size="md" width="625" height="367" data-path="images/use-cases/AI_ML/MCP/5_jani_tools.webp" />
  </Step>

  <Step title="使用 Jan.ai 与 ClickHouse MCP 服务器聊天" id="chat-to-clickhouse-mcp-server">
    现在可以开始围绕存储在 ClickHouse 中的数据展开对话了！
    让我们先提出一个问题：

    <Image img="https://mintcdn.com/private-7c7dfe99-vortex-format/mc_CXbtYxT_GqYxL/images/use-cases/AI_ML/MCP/6_janai_question.webp?fit=max&auto=format&n=mc_CXbtYxT_GqYxL&q=85&s=78922c15b369ed57c3161e6d30f98b9c" alt="问题" size="md" width="830" height="183" data-path="images/use-cases/AI_ML/MCP/6_janai_question.webp" />

    Jan.ai 在调用工具前会先请求确认：

    <Image img="https://mintcdn.com/private-7c7dfe99-vortex-format/mc_CXbtYxT_GqYxL/images/use-cases/AI_ML/MCP/7_janai_tool_confirmation.webp?fit=max&auto=format&n=mc_CXbtYxT_GqYxL&q=85&s=94dbd8e13ec8f7801c044fc9bfdf6e97" alt="工具确认" size="md" width="538" height="274" data-path="images/use-cases/AI_ML/MCP/7_janai_tool_confirmation.webp" />

    然后，它会显示已发起的工具调用列表：

    <Image img="https://mintcdn.com/private-7c7dfe99-vortex-format/mc_CXbtYxT_GqYxL/images/use-cases/AI_ML/MCP/8_janai_tools_called.webp?fit=max&auto=format&n=mc_CXbtYxT_GqYxL&q=85&s=fb80da0d9348a74b044f388dc8a22d56" alt="已调用的工具" size="md" width="1174" height="577" data-path="images/use-cases/AI_ML/MCP/8_janai_tools_called.webp" />

    如果我们点击某个工具调用，就可以看到该调用的详细信息：

    <Image img="https://mintcdn.com/private-7c7dfe99-vortex-format/mc_CXbtYxT_GqYxL/images/use-cases/AI_ML/MCP/9_janai_tools_called_expanded.webp?fit=max&auto=format&n=mc_CXbtYxT_GqYxL&q=85&s=2632ac5dfc7acbe10ed6e86bef99d7d9" alt="已展开的工具调用" size="md" width="1139" height="1418" data-path="images/use-cases/AI_ML/MCP/9_janai_tools_called_expanded.webp" />

    然后在下方，我们会看到结果：

    <Image img="https://mintcdn.com/private-7c7dfe99-vortex-format/mc_CXbtYxT_GqYxL/images/use-cases/AI_ML/MCP/10_janai_result.webp?fit=max&auto=format&n=mc_CXbtYxT_GqYxL&q=85&s=c78683641ffff968f3f067dc38b5a83b" alt="结果" size="md" width="1122" height="679" data-path="images/use-cases/AI_ML/MCP/10_janai_result.webp" />
  </Step>
</Steps>
