内容
# Open WebUI MCP 服务器
> 将 Claude Code 和 Claude Desktop 连接到您的 Open WebUI 实例。
> 直接从 Claude 管理聊天记录、RAG 知识库、文件、函数和提示。
[](https://www.npmjs.com/package/openwebui-mcp-server)
[](LICENSE)
[](https://nodejs.org)
---
## 功能介绍
Open WebUI 是一个强大的自托管 AI 接口,但在此之前,您无法从 Claude 与其交互。此 MCP 服务器填补了这一空白。
连接后,Claude 可以搜索您的聊天记录,从您描述的文件中构建 RAG 知识库,创建自定义管道函数,并管理提示 - 所有这些都无需离开您的对话。
**适用人群:** Claude Code 用户、Claude Desktop 用户、AI 开发者和 Open WebUI 高级用户,他们希望 Claude 帮助管理其 AI 基础设施。
---
## 快速入门
### Claude Code(3 个命令)
```bash
# 1. 从 Open WebUI 获取您的 API 密钥:设置 → 账户 → API 密钥
# 2. 添加 MCP 服务器
claude mcp add openwebui \
-e OPENWEBUI_URL=http://localhost:3000 \
-e OPENWEBUI_API_KEY=sk-your-key-here \
-- npx -y openwebui-mcp-server
# 3. 验证连接
# 在 Claude Code 中运行:/mcp
```
### Claude Desktop
将以下内容粘贴到您的 `claude_desktop_config.json` 文件中:
```json
{
"mcpServers": {
"openwebui": {
"command": "npx",
"args": ["-y", "openwebui-mcp-server"],
"env": {
"OPENWEBUI_URL": "http://localhost:3000",
"OPENWEBUI_API_KEY": "your-api-key-here"
}
}
}
}
```
配置文件位置:
- **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
- **Linux:** `~/.config/Claude/claude_desktop_config.json`
---
## 可用工具(共 23 个)
### 聊天记录
| 工具 | 描述 |
|------|-------------|
| `openwebui_list_chats` | 列出最近的对话,分页显示 |
| `openwebui_search_chats` | 按关键词搜索聊天记录 |
| `openwebui_get_chat` | 获取完整的聊天记录,包括所有消息 |
| `openwebui_delete_chat` | 删除聊天记录(需要确认) |
| `openwebui_get_chat_tags` | 列出聊天记录中使用的所有标签 |
### 知识库(RAG)
| 工具 | 描述 |
|------|-------------|
| `openwebui_list_knowledge` | 列出所有知识库集合 |
| `openwebui_get_knowledge` | 获取集合详细信息和文件列表 |
| `openwebui_create_knowledge` | 创建新的知识库集合 |
| `openwebui_update_knowledge` | 更新知识库名称或描述 |
| `openwebui_add_file_to_knowledge` | 将上传的文件添加到知识库集合 |
| `openwebui_remove_file_from_knowledge` | 从知识库集合中删除文件 |
### 文件
| 工具 | 描述 |
|------|-------------|
| `openwebui_list_files` | 列出所有上传的文件 |
| `openwebui_upload_file` | 上传文件(base64 内容) |
| `openwebui_get_file_info` | 获取文件元数据 |
| `openwebui_delete_file` | 删除文件(需要确认) |
### 函数(管道、过滤器、操作)
| 工具 | 描述 |
|------|-------------|
| `openwebui_list_functions` | 按类型列出所有函数 |
| `openwebui_get_function` | 获取函数及其源代码 |
| `openwebui_create_function` | 创建新的 Python 函数 |
| `openwebui_update_function` | 更新函数代码或元数据 |
| `openwebui_delete_function` | 删除函数(需要确认) |
### 模型
| 工具 | 描述 |
|------|-------------|
| `openwebui_list_models` | 列出所有可用的模型 |
### 提示
| 工具 | 描述 |
|------|-------------|
| `openwebui_list_prompts` | 列出所有保存的提示 |
| `openwebui_create_prompt` | 创建新的保存提示 |
| `openwebui_update_prompt` | 更新提示标题或内容 |
| `openwebui_delete_prompt` | 删除提示(需要确认) |
### 系统
| 工具 | 描述 |
|------|-------------|
| `openwebui_get_status` | 检查健康状态、版本和配置 |
---
## 配置
| 变量 | 是否必需 | 描述 |
|----------|----------|-------------|
| `OPENWEBUI_URL` | 是 | 基本 URL(例如 `http://localhost:3000`) |
| `OPENWEBUI_API_KEY` | 是 | 来自设置 → 账户 → API 密钥的 Bearer 令牌 |
| `DEBUG` | 否 | 设置为 `openwebui-mcp` 以将 HTTP 请求记录到 stderr |
---
## 示例
### 构建 RAG 知识库
```
"为事件响应文档创建一个名为 'Security Runbooks' 的知识库"
→ openwebui_create_knowledge(name: "Security Runbooks", ...)
知识库创建完成。ID:abc-123
"上传此运行手册并将其添加到 Security Runbooks"
→ openwebui_upload_file(filename: "incident-response.md", ...)
→ openwebui_add_file_to_knowledge(knowledge_id: "abc-123", file_id: "xyz-456")
文件已添加。现在可用于 RAG 检索。
```
### 搜索和查看对话
```
"在我的聊天记录中搜索有关 Kubernetes 网络的任何讨论"
→ openwebui_search_chats(query: "kubernetes networking")
找到 3 条聊天记录:[结果列表]
"显示上周关于 DNS 问题的完整对话"
→ openwebui_get_chat(id: "...")
[显示完整的对话]
```
### 创建可重用的提示
```
"创建一个提示 /standup,生成一个从 {{input}} 生成的 standup 更新"
→ openwebui_create_prompt(
command: "/standup",
title: "每日站会",
content: "根据这些笔记生成一个简洁的站会更新:{{input}}"
)
提示创建完成。在任何 Open WebUI 聊天记录中输入 /standup 即可使用。
```
### 安装自定义管道函数
```
"创建一个将所有响应翻译成法语的管道函数"
→ openwebui_create_function(
id: "french_translator",
name: "法语翻译器",
type: "filter",
content: "# Python 代码..."
)
函数创建完成。在设置 → 函数中启用它。
```
---
## 要求
- **Node.js** >= 18.0.0
- **Open WebUI** >= 0.3.0(任何自托管安装)
- **API 密钥** 来自 Open WebUI 设置 → 账户 → API 密钥
---
## 贡献
参见 [CONTRIBUTING.md](CONTRIBUTING.md) 获取指南。
问题和拉取请求欢迎 - 特别是针对新 Open WebUI 版本中添加的新 API 端点。
---
## 许可证
MIT - 参见 [LICENSE](LICENSE)
---
由 [Marc](https://github.com/marccyberleda) 构建 - 网络安全和自动化基础设施,来自 [CyberLeda](https://cyberleda.com)