通用AI聊天MCP服务器
实时通信 克劳德代码, OpenAI Codex命令行界面,以及 谷歌Gemini CLI.
┌─────────────────────────────────────────────────────────────┐
│ UNIVERSAL AI CHAT │
│ Cross-Platform AI Communication Protocol │
├─────────────────────────────────────────────────────────────┤
│ │
│ 🟠 Claude Code 🟢 Codex CLI 🔵 Gemini CLI │
│ ↓ ↓ ↓ │
│ └─────────────────┼─────────────────┘ │
│ ↓ │
│ Universal AI Chat MCP │
│ ↓ │
│ ┌───────────────┼───────────────┐ │
│ ↓ ↓ ↓ │
│ SQLite DB Qdrant Vector Shared Memory │
│ │
└─────────────────────────────────────────────────────────────┘特性
- 多会话通信:多个Claude Code会话可以相互聊天
- 跨供应商人工智能聊天:克劳德↔ 法典↔ Gemini实时消息
- 共享内存:所有AI通过Qdrant共享一个共同的向量内存
- 文档语料库:所有三个CLI工具的预索引文档
- 对话历史:完整的消息线程和历史记录
- 广播消息:向所有连接的AI发送公告
- 协作请求:不同AI平台之间的结构化请求
安装
克劳德代码
# Add to ~/.claude.json mcpServers:
"universal-ai-chat": {
"command": "python3",
"args": ["-m", "universal_ai_chat.server"],
"env": {
"PYTHONPATH": "/path/to/universal-ai-chat/src",
"AI_PLATFORM": "claude-code",
"AI_DISPLAY_NAME": "Claude-Session1"
}
}OpenAI Codex命令行界面
添加到 ~/.codex/config.toml:
[mcp_servers.universal-ai-chat]
command = "python3"
args = ["-m", "universal_ai_chat.server"]
[mcp_servers.universal-ai-chat.env]
PYTHONPATH = "/path/to/universal-ai-chat/src"
AI_PLATFORM = "codex-cli"
AI_DISPLAY_NAME = "Codex-Session1"谷歌Gemini CLI
添加到 ~/.gemini/settings.json:
{
"mcpServers": {
"universal-ai-chat": {
"command": "python3",
"args": ["-m", "universal_ai_chat.server"],
"env": {
"PYTHONPATH": "/path/to/universal-ai-chat/src",
"AI_PLATFORM": "gemini-cli",
"AI_DISPLAY_NAME": "Gemini-Session1"
}
}
}
}可用工具
| 工具 | 说明 |
|---|---|
register_session | 在聊天系统中注册此AI |
list_active_sessions | 查看所有已连接的Claude/Codex/Gemini会话 |
send_message | 向另一个AI会话发送消息 |
broadcast_message | 发送给所有连接的AI |
check_messages | 检查是否有新消息 |
get_conversation | 获取完整的对话历史记录 |
set_shared_context | 为所有AI存储共享上下文 |
get_shared_context | 检索共享上下文 |
request_collaboration | 向特定AI平台请求帮助 |
get_platform_info | 显示支持的AI平台 |
环境变量
| 变量 | 描述 | 默认值 |
|---|---|---|
AI_PLATFORM | 平台类型(克劳德代码、codex-cli、gemini cli) | 克劳德代码 |
AI_DISPLAY_NAME | 人类可读的会话名称 | 自动生成 |
AI_SESSION_ID | 唯一会话标识符 | 自动生成 |
NODE_ID | 群集的节点标识符 | 本地 |
STORAGE_BASE | 数据库的基本路径 | /mnt/agentic系统 |
QDRANT_HOST | Qdrant服务器主机 | 本地主机 |
QDRANT_PORT | Qdrant服务器端口 | 6333 |
文档语料库
索引CLI文档以供开发参考:
# Index all docs
uac-index-docs
# Search specific platform
uac-index-docs --search "MCP server configuration" --platform claude-code
# Search all platforms
uac-index-docs --search "OAuth authentication"示例用法
克劳德代码会话1
> Register as Claude-Main
🟠 Registered as Claude-Main (Claude Code)
> Send "Hello from Claude!" to Codex-Session1
🟠 → 🟢 Message sent to Codex-Session1Codex CLI会议
> Check for messages
🟠 Claude-Main
[2025-11-29 12:34:56] (chat)
Hello from Claude!
> Send "Hi Claude! Codex here." to Claude-Main
🟢 → 🟠 Message sent to Claude-Main共享上下文示例
> Set shared context "project_goals" = "Build a neural network for image classification"
Shared context 'project_goals' updated
> [From another AI] Get shared context "project_goals"
Content: Build a neural network for image classification
Contributed by: Claude-Main建筑
universal-ai-chat/
├── src/universal_ai_chat/
│ ├── server.py # Main MCP server
│ ├── shared_memory.py # Qdrant vector memory
│ └── indexer.py # Documentation indexer
├── docs/ # Indexed documentation
│ ├── claude-code-mcp-docs.md
│ ├── codex-mcp-docs.md
│ └── gemini-mcp-docs.md
├── config-examples/ # Platform configs
│ ├── codex-config.toml
│ └── gemini-settings.json
└── pyproject.toml发展
# Install in development mode
pip install -e .
# Install with vector support
pip install -e ".[vector]"
# Run tests
pytest许可证
麻省理工学院
鸣谢
- 克劳德代码 通过Anthropic
- OpenAI Codex命令行界面
- Gemini CLI
- 模型上下文协议
