让 AI 能够咨询更高级的 AI 模型,以 MCP Server + CLI 双模式运行。
前置要求:Python 3.11+、uv
# 克隆项目
git clone <repo-url> ai_co_tools
cd ai_co_tools
# 安装依赖
uv sync将配置文件放到 ~/.ai_expert/config.yaml:
experts:
- name: "deepseek"
model: "deepseek-chat"
provider: "openai"
base_url: "https://api.deepseek.com/v1"
api_key_env: "DEEPSEEK_API_KEY" # 环境变量名 或 直接填入 API Key
description: "推理专家,擅长复杂算法和架构设计"
tags: ["算法", "架构", "推理"]
max_tokens: 8192
temperature: 0.7
- name: "gpt4o"
model: "gpt-4o"
provider: "openai"
base_url: "https://api.openai.com/v1"
api_key_env: "OPENAI_API_KEY"
description: "通用高级专家"
tags: ["代码", "知识", "通用"]
conversations_dir: "~/.ai_expert/conversations"
default_expert: "deepseek"
api_key_env支持两种写法:填环境变量名(如OPENAI_API_KEY)或直接填 API Key 值。
配置加载优先级:AI_EXPERT_CONFIG 环境变量 > ~/.ai_expert/config.yaml > 环境变量直连模式
claude mcp add ai-expert -- uv run --directory /path/to/ai_co_tools ai-expert serve重启 Claude Code 会话后生效。
ai-expert list-experts# 基本提问(默认启用 thinking 模式,隐藏推理过程)
ai-expert ask deepseek "如何设计分布式锁?"
# 附带上下文
ai-expert ask deepseek "这段代码有什么问题?" -c "def foo(): return 1/0"
# 显示推理过程
ai-expert ask deepseek "分析快排的时间复杂度" --verbose
# 关闭 thinking 模式
ai-expert ask deepseek "1+1=?" --no-thinking
# 指定 system prompt 和标题
ai-expert ask deepseek "设计一个缓存系统" -s "你是分布式系统架构师" -t "缓存设计"ai-expert continue <conversation_id> "追问:如果用 Redis 实现呢?"
ai-expert continue <conversation_id> "还有其他方案吗?" --verbose# 列出所有对话
ai-expert list-conversations
# 按专家过滤
ai-expert list-conversations --expert deepseek
# 查看完整对话
ai-expert get-conversation <conversation_id>
# 删除指定对话
ai-expert clear-conversation <conversation_id>
# 清除所有对话
ai-expert clear-conversationai-expert serve注册到 Claude Code 后,以下工具可供 AI 调用:
| 工具 | 参数 | 说明 |
|---|---|---|
list_experts |
无 | 列出所有可用专家 |
ask_expert |
expert_name, question, context_info?, system_prompt?, title?, thinking?, verbose? |
发起新咨询 |
continue_conversation |
conversation_id, message, thinking?, verbose? |
继续已有对话 |
list_conversations |
expert_name? |
列出历史对话 |
get_conversation |
conversation_id |
查看完整对话 |
clear_conversation |
conversation_id? |
删除对话(省略 ID 则清除全部) |
- 默认启用:所有咨询默认使用 thinking/推理模式
- 隐藏推理:默认只返回最终答案,设置
verbose=True显示推理过程 - 多轮不传递:thinking 内容不会存入对话历史,续对话时不会重复传递
| Provider | 适用模型 |
|---|---|
openai |
OpenAI、DeepSeek、及所有 OpenAI 兼容 API |
anthropic |
Claude 系列模型 |