气锁🔒
集成MCP的安全、内部部署的AI聊天平台
一个完整的、自托管的AI聊天界面,使用模型上下文协议将公司的LLM连接到内部工具(Confluence、GitLab、Jira、数据库等)。一切都在你的防火墙后面。
📖 目录
- 生产设置 - 测试设置(ARM64)
______________________________________________________________________
概述
气锁 是您安全的内部人工智能助手,它将您公司的LLM与内部工具和文档连接起来。它基于LibreChat构建,集成了模型上下文协议(MCP),将您的所有数据都保存在防火墙后面,同时提供了一个强大的类似ChatGPT的界面。
这有什么作用
- 🔒 100%本地:所有数据都保留在您的网络中
- 💬 聊天界面:通过LibreChat(端口3080)实现美丽的自托管用户界面
- 🤖 你的法学硕士:适用于任何兼容OpenAI的模型(Qwen、Gemma等)
- 🔌 MCP集成:通过模型上下文协议连接到内部工具
- 汇流(搜索文档、检索页面) - GitLab(仓库、问题、MR) - Jira(门票、项目) - PostgreSQL(查询数据库) - Slack(搜索消息) - 谷歌云端硬盘(访问文件) - 还有更多。..
- 🐳 基于Docker:易于部署,网络隔离
- 🔐 安全:基于环境的凭据,无外部API调用
运作原理
- 用户在聊天界面提问
- 启用MCP工具(Confluence、GitLab、Jira等)
- MCP服务器查询您的内部系统
- 贵公司的LLM使用内部数据生成响应
- 用户从公司资源中获得完整上下文的答案
所有通信都发生在您的基础设施内。零数据离开您的网络。
______________________________________________________________________
特性
核心功能
✅ 自托管聊天界面
- LibreChat网络用户界面(端口3080)
- 用户身份验证和管理
- 对话历史
- 多型号支持
✅ 汇流集成
- 搜索Confluence文档
- 检索特定页面
- 列出可用空间
- 可选只读模式
✅ 公司LLM支持
- 适用于任何与OpenAI兼容的API
- 多种型号配置
- 自定义端点
✅ 完全隐私
- 所有服务均在本地运行
- 没有外部API调用
- 通过.env进行凭据管理
- Docker网络隔离
测试功能
✅ ARM64测试环境
- Apple Silicon Mac的轻量级设置
- 自定义模拟LLM(Node.js/Express)
- 剧作家E2E测试
- 快速启动(30秒)
- 低资源使用率(2GB RAM)
✅ 完整测试套件
- Playwright浏览器自动化
- 汇流测试数据设置
- 多种测试模式(带头、调试、UI)
- 自动清理脚本
- CI/CD就绪
______________________________________________________________________
先决条件
生产环境
- 已安装Docker和Docker Compose
- 访问贵公司的LLM端点(兼容OpenAI)
- 具有API访问权限的Confluence实例
- Confluence API令牌
- macOS、Linux或Windows与WSL2
用于测试(ARM64)
- Docker&Docker编写
- Node.js 18+和npm
- Playwright(通过npm安装)
- 苹果Silicon Mac(或x86用于完整的Confluence测试)
______________________________________________________________________
快速开始
生产设置
1.克隆和配置
# Clone the repository
git clone https://github.com/bcamarneiro/airlocked.git
cd airlocked
# Copy environment template
cp .env.example .env
# Edit with your credentials
nano .env2.更新凭据
编辑 .env:
# MongoDB
MONGO_USERNAME=admin
MONGO_PASSWORD=your-secure-password
# Your Company's LLM
COMPANY_LLM_URL=http://your-company-llm:8000/v1
COMPANY_LLM_API_KEY=your-api-key
# Confluence
CONFLUENCE_URL=https://confluence.your-company.com
CONFLUENCE_USERNAME=your.email@company.com
CONFLUENCE_API_TOKEN=your-confluence-api-token
CONFLUENCE_SSL_VERIFY=true3.配置可用型号
编辑 librechat.yaml:
endpoints:
custom:
- name: "Company LLM"
models:
default:
- "qwen" # Add your available models
- "gemma"
- "your-model"4.启动服务
# Start all services
docker-compose up -d
# Check status
docker-compose ps
# View logs
docker-compose logs -f5.访问librechat
打开http://localhost:3080在浏览器中:
- 注册一个新账户
- 登录
- 从下拉菜单中启用Confluence工具
- 开始聊天!
查询示例:
- “搜索Confluence以查找API文档”
- “Confluence有哪些可用空间?”
- “从Confluence获取入门页面”
测试设置(ARM64)
非常适合在Apple Silicon Mac上进行本地开发。
1.构建和启动
# Build custom mock LLM
docker-compose -f docker-compose.arm64.yml build
# Start all services
docker-compose -f docker-compose.arm64.yml up -d
# Wait 30 seconds for services to initialize2.安装测试依赖项
# Install Node.js dependencies
npm install
# Install Playwright browsers
npm run playwright:install3.运行测试
# Run all tests (headless)
./run-tests-arm64.sh
# Run with visible browser
./run-tests-arm64.sh --headed
# Interactive UI mode
./run-tests-arm64.sh --ui
# Debug mode
./run-tests-arm64.sh --debug4.访问服务
- Librechat: http://localhost:3080
- 模拟LLM API: http://localhost:8000(内部)
______________________________________________________________________
配置
环境变量
MongoDB:
MONGO_USERNAME=admin
MONGO_PASSWORD=your-password公司法学硕士:
COMPANY_LLM_URL=http://your-llm-endpoint:8000/v1
COMPANY_LLM_API_KEY=your-api-key汇流:
CONFLUENCE_URL=https://confluence.your-company.com
CONFLUENCE_USERNAME=your.email@company.com
CONFLUENCE_API_TOKEN=your-api-token
CONFLUENCE_SSL_VERIFY=trueLibreChat配置
编辑 librechat.yaml 自定义:
可用模型:
models:
default:
- "qwen"
- "gemma"
- "your-model"
fetch: false # Set to true to auto-fetch from endpointMCP工具:
mcpServers:
confluence:
enabledTools:
- confluence_search
- confluence_get_page
- confluence_get_spaces只读模式 (可选):
env:
READ_ONLY_MODE: "true"生成Confluence API令牌
汇流云:
- 首选https://id.atlassian.com/manage-profile/security/api-tokens
- 点击“创建API令牌”
- 复制令牌
汇流服务器/数据中心:
- 前往汇流处→ 设置→ 个人访问令牌
- 创建新令牌
- 复制令牌
______________________________________________________________________
测试
ARM64测试(苹果硅)
本地开发的轻量级环境:
# Start environment
docker-compose -f docker-compose.arm64.yml up -d
# Run tests
./run-tests-arm64.sh
# Stop environment
docker-compose -f docker-compose.arm64.yml down测试内容:
- ✅ LibreChat用户界面加载
- ✅ 用户注册/登录
- ✅ 聊天界面功能
- ✅ 消息发送/接收
- ✅ 模拟LLM响应
资源使用:
- 内存:2GB
- 磁盘:500MB
- 启动时间:30秒
完整测试(x86/CI/CD)
使用本地Confluence实例完成测试:
# Start environment
docker-compose -f docker-compose.test.yml up -d
# Wait 3-5 minutes for Confluence to initialize
# Setup Confluence (first time)
# 1. Open http://localhost:8090
# 2. Complete setup wizard
# 3. Generate API token
# 4. Configure .env.test
# Run tests
./run-tests.sh
# Stop environment
docker-compose -f docker-compose.test.yml down测试内容:
- ✅ ARM64测试中的所有内容
- ✅ 汇流MCP集成
- ✅ 汇流搜索
- ✅ 页面检索
- ✅ 空间列表
- ✅ 错误处理
资源使用:
- 内存:6GB
- 磁盘:10GB
- 启动时间:3-5分钟
测试模式
# Normal (headless)
./run-tests-arm64.sh
# Headed (show browser)
./run-tests-arm64.sh --headed
# UI mode (interactive)
./run-tests-arm64.sh --ui
# Debug mode
./run-tests-arm64.sh --debug测试结果
# View HTML report
npm run test:report
# Results location:
# - test-results/html/index.html
# - test-results/results.json清理测试环境
# Quick cleanup
./cleanup-test-env.sh
# Force cleanup (no prompts)
./cleanup-test-env.sh --force
# Manual cleanup
docker-compose -f docker-compose.arm64.yml down -v
docker-compose -f docker-compose.test.yml down -v______________________________________________________________________
添加更多MCP服务器
系统支持多个MCP服务器。以下是如何添加更多内容:
可用的MCP服务器
- GitLab -访问GitLab存储库、问题、MR
- GitHub -访问GitHub仓库、问题、PR
- Jira -管理Jira门票和项目
- PostgreSQL -查询数据库
- Slack -搜索Slack消息
- Google 云端硬盘 -访问驱动器文件
- 记忆 -持久对话记忆
示例:添加GitLab
编辑 librechat.yaml:
mcpServers:
gitlab:
command: npx
args:
- "-y"
- "@modelcontextprotocol/server-gitlab"
env:
GITLAB_PERSONAL_ACCESS_TOKEN: "${GITLAB_API_TOKEN}"
GITLAB_API_URL: "https://gitlab.your-company.com/api/v4"
description: "Access GitLab repositories and issues"
chatMenu: true添加到 .env:
GITLAB_API_TOKEN=your-gitlab-token示例:添加Jira
mcpServers:
jira:
command: docker
args:
- run
- --rm
- -i
- --network
- host
- -e
- JIRA_URL
- -e
- JIRA_USERNAME
- -e
- JIRA_API_TOKEN
- ghcr.io/sooperset/mcp-atlassian:latest
env:
JIRA_URL: "${JIRA_URL}"
JIRA_USERNAME: "${JIRA_USERNAME}"
JIRA_API_TOKEN: "${JIRA_API_TOKEN}"
description: "Manage Jira tickets and projects"
chatMenu: true添加到 .env:
JIRA_URL=https://jira.your-company.com
JIRA_USERNAME=your.email@company.com
JIRA_API_TOKEN=your-jira-token示例:添加内存
mcpServers:
memory:
command: npx
args:
- "-y"
- "@modelcontextprotocol/server-memory"
description: "Persistent memory across conversations"
chatMenu: true______________________________________________________________________
故障排除
常见问题
服务无法启动
# Check logs
docker-compose logs
# Specific service
docker-compose logs librechat
docker-compose logs mongodb
# Restart services
docker-compose restartLibreChat无法连接到LLM
检查:
COMPANY_LLM_URL是正确的.env- LLM端点可以从Docker容器访问
- API密钥有效
测试:
# Test from host
curl http://your-llm-endpoint:8000/v1/models
# Test from container
docker exec librechat curl http://host.docker.internal:8000/v1/models汇流MCP不工作
检查:
CONFLUENCE_API_TOKEN设置正确- Confluence URL可访问
- 用户有权访问Confluence
测试:
# Test API token
curl -u username:api-token https://confluence.your-company.com/rest/api/space调试:
# Check LibreChat logs for MCP errors
docker-compose logs librechat | grep -i mcp
docker-compose logs librechat | grep -i confluence数据库连接问题
# Check MongoDB is running
docker-compose ps mongodb
# Check MongoDB logs
docker-compose logs mongodb
# Verify credentials match in docker-compose.yml and .env端口已在使用中
# Find what's using port 3080
lsof -i :3080
# Kill the process
kill -9
# Or change port in docker-compose.yml
ports:
- "3081:3080" # Use 3081 insteadARM64特定问题
模拟LLM未响应
# Check if running
docker logs test-mock-llm-arm64
# Restart
docker-compose -f docker-compose.arm64.yml restart mock-llmLibreChat正在重新启动
# Check logs for errors
docker logs test-librechat-arm64
# Common issue: JWT secrets (already configured)测试失败
# View detailed report
npm run test:report
# Run in debug mode
./run-tests-arm64.sh --debug
# Run with visible browser
./run-tests-arm64.sh --headed
# Check service logs
docker-compose -f docker-compose.arm64.yml logs______________________________________________________________________
建筑
生产架构
┌─────────────────┐
│ Browser │
│ (localhost: │
│ 3080) │
└────────┬────────┘
│
▼
┌─────────────────────────────┐
│ LibreChat │
│ - Web UI │
│ - User Auth │
│ - Conversation Management │
└──────┬──────────────┬───────┘
│ │
▼ ▼
┌────────────┐ ┌──────────────────┐
│ MongoDB │ │ Company LLM │
│ │ │ (Your Endpoint) │
└────────────┘ └──────────────────┘
│ │
│ ▼
│ ┌─────────────────┐
│ │ MCP Servers │
│ │ - Confluence │
│ │ - GitLab │
└────────│ - Jira │
│ - etc. │
└─────────────────┘ARM64测试架构
┌──────────────────┐
│ Playwright │
│ (Browser Tests) │
└────────┬─────────┘
│
▼
┌─────────────────┐
│ LibreChat │
│ (Port 3080) │
└───┬─────────┬───┘
│ │
▼ ▼
┌────────┐ ┌──────────────┐
│MongoDB │ │ Mock LLM │
│ │ │ (Node.js) │
│ │ │ (Port 8000) │
└────────┘ └──────────────┘组件
Librechat:
- Docker镜像:
ghcr.io/danny-avila/librechat:latest - 端口:3080
- 配置:
librechat.yaml - 环境:
.env
MongoDB:
- Docker镜像:
mongo:latest - 端口:27017(内部)
- 数据:存储在Docker卷中
公司法学硕士:
- 您的OpenAI兼容端点
- 通过环境变量配置
- 支持多种型号
MCP服务器:
- 以Docker容器或npx命令运行
- 通过stdio或HTTP进行通信
- 为LibreChat提供工具
模拟法学硕士(测试):
- 自定义Node.js/Express服务器
- 兼容OpenAI API
- ARM64原生
- 轻量级(\<100MB)
______________________________________________________________________
清理
生产清理
# Stop services
docker-compose down
# Stop and remove volumes (deletes all data!)
docker-compose down -v
# Remove images
docker-compose down --rmi all -v测试环境清理
# Automated cleanup
./cleanup-test-env.sh
# Force cleanup (no prompts)
./cleanup-test-env.sh --force
# Manual ARM64 cleanup
docker-compose -f docker-compose.arm64.yml down -v
# Manual full test cleanup
docker-compose -f docker-compose.test.yml down -v清洁Docker系统
# Remove unused containers
docker container prune
# Remove unused volumes
docker volume prune
# Remove unused images
docker image prune
# Remove everything unused
docker system prune -a --volumes______________________________________________________________________
文件结构
airlocked/
├── docker-compose.yml # Production environment
├── docker-compose.arm64.yml # ARM64 test environment
├── docker-compose.test.yml # Full test environment (x86)
├── librechat.yaml # LibreChat production config
├── librechat.arm64.yaml # ARM64 config
├── librechat.test.yaml # Test config
├── .env.example # Environment template
├── .env.test.example # Test environment template
│
├── mock-services/ # Custom mock LLM (ARM64)
│ ├── mock-llm.js # OpenAI-compatible API
│ ├── Dockerfile # Container definition
│ └── package.json # Dependencies
│
├── scripts/ # Utility scripts
│ └── setup-test-data.js # Confluence test data setup
│
├── tests/e2e/ # E2E test suites
│ ├── global.setup.js # x86 setup
│ ├── global.setup.arm64.js # ARM64 setup
│ ├── 01-librechat-basic.spec.js # ARM64 tests
│ ├── 01-librechat-registration.spec.js # UI tests
│ └── 02-confluence-mcp-integration.spec.js # MCP tests
│
├── run-tests-arm64.sh # ARM64 test runner
├── run-tests.sh # Full test runner
├── cleanup-test-env.sh # Cleanup automation
├── setup-git.sh # Git configuration
│
├── package.json # Test dependencies
├── playwright.config.js # Playwright config (x86)
├── playwright.arm64.config.js # Playwright config (ARM64)
│
└── README.md # This file______________________________________________________________________
常见问题解答
我可以在OpenAI/Claude/etc上使用这个吗?
对!只需在中配置端点 librechat.yamlLibreChat支持许多开箱即用的提供商。
我需要Confluence吗?
否。Confluence MCP服务器是可选的。您可以在没有LibreChat的情况下使用它,也可以添加其他MCP服务器。
我可以在Windows上运行这个吗?
是的,使用WSL2(Linux的Windows子系统)和Docker Desktop。
如何添加更多用户?
用户可以在以下网址自行注册http://localhost:3080.要禁用注册,请设置 ALLOW_REGISTRATION=false 在docker-compose.yml中。
这个生产准备好了吗?
是的,但请考虑:
- 使用强密码
- 启用HTTPS(添加反向代理,如nginx)
- MongoDB数据的定期备份
- 监控和日志记录
- 安全强化
我可以部署到云端吗?
对!部署到任何支持Docker的云提供商(AWS、GCP、Azure、DigitalOcean等)。确保:
- 使用托管数据库(或备份MongoDB)
- 启用HTTPS
- 配置防火墙
- 使用机密管理
如何更新?
# Pull latest images
docker-compose pull
# Restart services
docker-compose up -d数据存储在哪里?
- 对话:MongoDB Docker卷
- 用户数据:MongoDB Docker卷
- 上传的文件:
librechat_data体积 - 日志:
librechat_logs体积
______________________________________________________________________
资源
- Librechat:https://www.librechat.ai/
- Librechat文档:https://www.librechat.ai/docs
- 模型上下文协议: https://modelcontextprotocol.io/
- MCP服务器: https://github.com/modelcontextprotocol/servers
- Atlassian MCP: https://github.com/sooperset/mcp-atlassian
______________________________________________________________________
许可证
此配置按原样提供。LibreChat和其他组件有自己的许可证。
______________________________________________________________________
贡献
请随时提交问题或请求改进配置和测试设置。
______________________________________________________________________
准备好开始了吗?
# Production
cp .env.example .env
# Edit .env with your credentials
docker-compose up -d
open http://localhost:3080
# Testing (ARM64)
docker-compose -f docker-compose.arm64.yml build
docker-compose -f docker-compose.arm64.yml up -d
./run-tests-arm64.sh --headed🎉 通过Confluence集成享受您的自托管人工智能聊天!
