Aurai Advisor (上级顾问 MCP)
Aurai Advisor MCP
让本地 AI(Claude Code)在遇到复杂编程问题时,向远程大模型继续请教的 MCP 服务。
工作原理: 本地 AI 通过 sync_context 上传代码文件 → consult_aurai 提交问题 → 远程顾问返回分析 + 可执行步骤 → 本地 AI 用 report_progress 汇报进展 → 循环直到解决。
关键约束: 远程顾问无法直接访问你的文件系统。它只能看到你通过 sync_context 上传的文件内容和 consult_aurai 描述的信息。
安装
1. 环境要求
Python 3.10+
Claude Code(或其他支持 MCP stdio 的客户端)
2. 下载并安装依赖
git clone https://github.com/LZMW/mcp-aurai-server.git
cd mcp-aurai-server
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # macOS / Linux
pip install -e .3. 在 Claude Code 中注册
claude mcp add --scope user --transport stdio aurai-advisor \
--env AURAI_API_KEY="你的API密钥" \
--env AURAI_BASE_URL="https://你的API地址/v1" \
--env AURAI_MODEL="模型名称" \
-- "完整路径\venv\Scripts\python.exe" "-m" "mcp_aurai.server"Windows 实际示例:
claude mcp add --scope user --transport stdio aurai-advisor \
--env AURAI_API_KEY="sk-xxxxxxxxxxxxxxxx" \
--env AURAI_BASE_URL="https://api.openai.com/v1" \
--env AURAI_MODEL="gpt-4o" \
-- "D:\mcp-aurai-server\venv\Scripts\python.exe" "-m" "mcp_aurai.server"--scope user 表示在所有项目中可用。
4. 验证
claude mcp list看到 aurai-advisor: ✓ Connected 即成功。
5. 卸载
claude mcp remove "aurai-advisor" -s userRelated MCP server: session-coord-mcp
配置参数
所有参数通过环境变量设置,在 claude mcp add 时用 --env 传入。
必填
环境变量 | 说明 | 示例 |
| API 密钥 |
|
| OpenAI 兼容接口地址 |
|
| 模型名称 |
|
AI 调用控制
环境变量 | 默认值 | 范围 | 说明 |
|
| 0.0–2.0 | 生成温度。越低越确定,越高越随机 |
|
| ≥1 | 远程顾问单次回复的最大输出长度(tokens) |
|
| ≥1 | 模型上下文窗口大小(tokens)。输入 + 输出的总上限 |
|
| ≥1 | 单个文件超过此值会自动拆分成多段发送 |
|
| 1–200 | 单个问题最多对话轮数。50 轮内解决 → 自动清空历史;超限 → 清空历史并返回 |
上下文预算 & Token 监控:
环境变量 | 默认值 | 范围 | 说明 |
|
| 0.5–1.0 | 上下文高水位线。输入 tokens 超过此比例时返回预警并主动压缩历史 |
每次 consult_aurai / report_progress 响应中均包含 token_usage 字段,实时展示输入 tokens、使用率、是否触发预警。当超过高水位线时,会主动压缩历史为输出腾空间。本地 AI 可根据 warning=true 提示调用 sync_context(operation='clear') 清空历史。
上下文预算分配策略: 优先保证 AURAI_MAX_TOKENS 的输出预算。输入过大时裁剪历史消息,不压缩输出。仅当基础消息(系统提示词 + 当前问题)本身就超过窗口时才缩减输出。
对话历史
环境变量 | 默认值 | 范围 | 说明 |
|
| 1–200 | 每个会话在本地最多保留多少条历史记录 |
|
| 1–50 | 每次发送给远程顾问时附带最近多少轮原始对话(摘要不受此限制) |
|
| bool | 是否将历史保存到磁盘。关闭后重启 Claude Code 历史丢失 |
|
| — | 历史文件存储路径 |
|
| 1–120s | 跨进程文件锁等待超时 |
|
| bool | 是否启用历史摘要。仅在接近 max_history(80%)时触发,保留 60% 原始记录 |
历史机制说明:
AURAI_MAX_HISTORY(50 条)是本地存储上限——现代 200K 上下文下纯对话远填不满,真正的瓶颈是sync_context上传的大文件摘要不再按固定条数触发,而是在接近 max_history 时(40/50 条)才启动
Token 水位线预警(
AURAI_CONTEXT_HIGH_WATERMARK)是实时防线,在每次请求前检查不同
session_id的历史互相隔离
进程管理
环境变量 | 默认值 | 范围 | 说明 |
|
| 0–86400 | 空闲多久后自动退出。 |
|
| 1–3600 | 空闲检查间隔 |
推荐设置 AURAI_STDIO_IDLE_TIMEOUT_SECONDS=0,避免 Claude Code 还在运行但 MCP 因空闲被误杀。空闲退出前会检查父进程是否存活,但如果不在意残留进程,直接禁用最省心。
其他
环境变量 | 默认值 | 说明 |
|
| 日志级别: |
使用指南
MCP 注册后,Claude Code 中自动出现 4 个工具:
典型调用流程
1. sync_context(operation='sync', files=['src/bug.py'], project_info={...})
↑ 让顾问看到你的代码
2. consult_aurai(problem_type='runtime_error', error_message='...')
↑ 提交问题,获取分析
3. 如返回 status='need_info' → 搜集顾问反问的信息 → 再次 consult_aurai(answers_to_questions='...')
↑ 多轮对齐
4. 如返回 status='success' → 按 action_items 执行修改
5. report_progress(actions_taken='改了X', result='success')
↑ 汇报进展,获取下一步指导
6. 重复 4-5,直到 resolved=true工具速查
工具 | 用途 |
| 上传文件和项目背景。 |
| 提交问题。支持多轮:收到反问→搜集信息→ |
| 按顾问指导执行后汇报结果,获取下一步 |
| 查看会话状态(历史条数、模型、空闲时间) |
会话隔离
不同任务传不同的 session_id,避免上下文串扰:
consult_aurai(session_id='bug-123', ...) # 修 Bug A
consult_aurai(session_id='feature-456', ...) # 写功能 B常见问题
上级顾问收不到我上传的代码?
检查 sync_context 返回的 uploaded_files 和 skipped_files。二进制文件(图片、压缩包)会被自动跳过。代码文件(.py/.js/.ts 等)会自动转换为文本发送。
不同问题互相干扰?
给不同问题传不同的 session_id。或设置 is_new_question=true 清空当前会话历史。
Claude Code 提示 MCP 连不上?
检查
claude mcp list确认状态查看
AURAI_STDIO_IDLE_TIMEOUT_SECONDS,推荐设为0禁用空闲退出查看日志:
AURAI_LOG_LEVEL=DEBUG可看到详细日志(输出到 stderr)
历史文件变得很大?
历史摘要在自动工作。旧记录被压缩为纪要而非删除,可设置 AURAI_ENABLE_HISTORY_SUMMARY=false 完全禁用摘要(不推荐)。
怎么切换模型?
claude mcp remove "aurai-advisor" -s user
claude mcp add --scope user --transport stdio aurai-advisor \
--env AURAI_API_KEY="sk-..." \
--env AURAI_BASE_URL="https://api.openai.com/v1" \
--env AURAI_MODEL="新模型名称" \
-- "D:\mcp-aurai-server\venv\Scripts\python.exe" "-m" "mcp_aurai.server"Available Tools
4 toolsconsult_auraiA
请求上级AI的指导(支持交互对齐机制与多轮对话)
这是核心工具,当本地AI遇到编程问题时调用此工具获取上级AI的指导建议。
🔗 相关工具
sync_context:需要上传文档或代码时使用
📄 上传文章、说明文档(.md/.txt)
💻 上传代码文件(避免内容被截断) ⭐ 重要
将
.py/.js/.json等代码文件复制为.txt后上传
report_progress:执行上级 AI 建议后,使用此工具报告进度并获取下一步指导
get_status:查看当前对话状态、迭代次数、配置信息
💡 重要提示:避免内容被截断
如果 code_snippet 或 context 内容过长,请使用 sync_context 上传文件:
# 步骤 1:将代码文件复制为 .txt
shutil.copy('script.py', 'script.txt')
# 步骤 2:上传文件
sync_context(operation='incremental', files=['script.txt'])
# 步骤 3:告诉上级顾问文件已上传
consult_aurai(
error_message='请审查已上传的 script.txt 文件'
)优势:
✅ 避免代码在
context或answers_to_questions字段中被截断✅ 利用文件读取机制,完整传递内容
✅ 支持任意大小的代码文件
[重要] 何时开始新对话?
系统会自动检测,但你也可以手动控制:
自动清空:当上一次对话返回
resolved=true时,系统会自动清空历史手动清空:如果你要讨论一个完全不同的新问题,设置
is_new_question=true
何时设置 is_new_question=true?
[OK] 切换到完全不相关的项目/文件
[OK] 之前的问题已解决,现在遇到全新的问题
[OK] 发现上下文混乱,想重新开始
不要在同一个问题的多轮对话中使用
交互协议
1. 多轮对齐机制
不要期待一次成功:上级顾问可能会认为信息不足,返回反问问题
仔细阅读
questions_to_answer中的每个问题主动搜集信息(读取文件、检查日志、运行命令)
再次调用 此工具,将答案填入
answers_to_questions参数
2. 首次调用
必须提供:
problem_type:问题类型(runtime_error/syntax_error/design_issue/other)error_message:清晰描述问题或错误context:相关上下文(代码片段、环境信息、已尝试的方案)code_snippet:相关代码(如果有)
3. 后续调用(当返回 status="need_info" 时)
必须提供:
answers_to_questions:对上级顾问反问的详细回答保持其他参数不变(除非有新信息)
4. 诚实原则
禁止瞎编:如果不知道答案,诚实说明"未找到相关信息"
禁止臆测:不要在没有证据的情况下假设解决方案
提供具体证据(文件路径、日志内容、错误堆栈)
响应格式
信息不足时 (status="need_info")
{
"status": "need_info",
"questions_to_answer": ["问题1", "问题2"],
"instruction": "请搜集信息并再次调用"
}提供指导时 (status="success")
{
"status": "success",
"analysis": "问题分析",
"guidance": "解决建议",
"action_items": ["步骤1", "步骤2"],
"resolved": false // 是否已完全解决
}问题解决后
当 resolved=true 时,对话历史会自动清空,下次查询将开始新对话。
[自动] 新对话检测
系统会自动检测新问题:
如果上一次对话的
resolved=true,下次调用consult_aurai时会自动清空历史保证每个独立问题都有干净的上下文,避免干扰
[重要] 明确标注新问题(可选参数)
如果你想强制开始一个新对话,可以设置 is_new_question=true:
效果:立即清空所有之前的对话历史
后果:上级AI将无法看到之前的任何上下文
使用场景:
之前的对话已完全无关
想重新开始讨论一个全新的问题
发现上下文混乱,想重置
示例:
# 第一次咨询(问题A)
consult_aurai(problem_type="runtime_error", error_message="...")
# 继续讨论问题A...
consult_aurai(answers_to_questions="...")
# 切换到问题B(标注为新问题,清空历史)
consult_aurai(
problem_type="design_issue",
error_message="...",
is_new_question=True # [注意] 会清空之前关于问题A的所有对话
)Inputs: problem_type (required), error_message (required), code_snippet, context, +3 more. Returns: object
get_statusB
获取当前状态
返回当前对话状态、迭代次数、配置信息等。
返回内容:conversation_history_count(对话历史数量)、max_iterations(最大迭代次数)、max_history(最大历史条数)、provider(AI提供商)、model(模型名称)
Inputs: no named parameters. Returns: object
report_progressA
报告执行进度,请求下一步指导
在执行了上级AI的建议后,调用此工具报告结果,获取下一步指导。
使用场景:执行上级 AI 建议后,报告执行结果并获取后续指导 参数:actions_taken(已执行的行动)、result(success/failed/partial)、new_error(新错误)、feedback(反馈)
Inputs: actions_taken (required), result (required), new_error, feedback. Returns: object
sync_contextA
同步代码上下文(支持上传 .md 和 .txt 文件,避免内容被截断)
在第一次调用或上下文发生重大变化时使用,让上级AI了解当前项目的整体情况。
🎯 典型使用场景
场景 1:上传文章供上级顾问评审
sync_context(
operation='full_sync',
files=['文章.md'],
project_info={
'task': 'article_review',
'target_platform': 'GLM Coding 知识库'
}
)
consult_aurai(
problem_type='other',
error_message='请评审以下投稿文章...',
context={'请查看已上传的文章文件': '已通过 sync_context 上传'}
)场景 2:上传代码文件(避免内容被截断)⭐ 重要
# 问题:代码太长,在 context 字段中可能被截断
# 解决:将代码转换为 .txt 文件后上传
import shutil
# 步骤 1:将代码文件复制为 .txt
shutil.copy('src/main.py', 'src/main.txt')
# 步骤 2:上传文件
sync_context(
operation='incremental',
files=['src/main.txt'],
project_info={
'description': '需要调试的代码',
'language': 'Python'
}
)
# 步骤 3:告诉上级顾问文件已上传
consult_aurai(
problem_type='runtime_error',
error_message='请审查已上传的 src/main.txt 文件,帮我找出bug',
context={
'file_location': '已通过 sync_context 上传',
'expected_behavior': '应该输出...',
'actual_behavior': '实际输出...'
}
)优势:
✅ 避免代码在
context或answers_to_questions字段中被截断✅ 利用 sync_context 的文件读取机制,完整传递内容
✅ 上级顾问可以完整读取代码文件
场景 3:项目首次初始化
sync_context(
operation='full_sync',
files=['README.md', 'docs/说明文档.md'],
project_info={
'project_name': 'My Project',
'tech_stack': 'Python + FastAPI'
}
)[注意] 文件上传限制
files 参数只支持 .txt 和 .md 文件!
[OK] 支持:
README.md,docs.txt,notes.md等文本和Markdown文件不支持:
.py,.js,.json,.yaml等代码文件
使用场景
full_sync: 完整同步,适合首次调用或项目重大变更
incremental: 增量同步,适合添加新文件或更新
clear: 清空对话历史
Token优化
当 project_info 中的单个字段超过 800 tokens 时,会自动:
缓存到临时文件
在对话历史中记录文件路径
发送给上级AI时仍会读取完整内容
参数说明
operation: 操作类型(full_sync/incremental/clear)files: 文件路径列表,只能是 .txt 或 .md 文件project_info: 项目信息字典,可包含任意字段
Inputs: operation (required), files, project_info. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a distinct, non-overlapping purpose: consult_aurai for core advice, sync_context for file uploads, report_progress for progress updates, and get_status for status checks. The descriptions clearly differentiate their roles, with no ambiguity in when to use each tool.
All tool names follow a consistent snake_case pattern with clear verb_noun structures: consult_aurai, sync_context, report_progress, get_status. This uniformity makes the set predictable and easy to understand for an agent.
With 4 tools, this server is well-scoped for its purpose of providing AI-guided problem-solving. Each tool serves a specific function in the workflow (consult, sync, report, status), and there are no extraneous or missing tools for the domain.
The tool set fully covers the intended workflow: initiating consultations (consult_aurai), providing context (sync_context), reporting progress (report_progress), and checking status (get_status). There are no gaps; agents can handle the entire lifecycle from problem submission to resolution.
Maintenance
Related MCP Connectors
MCP server for AI dialogue using various LLM models via AceDataCloud
An MCP server that gives your AI access to the source code and docs of all public github repos
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Driflyte MCP server which lets AI assistants query topic-specific knowledge from web and GitHub.
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceAn MCP server that orchestrates AI coding assistants (Claude Code CLI and Gemini CLI) to perform complex programming tasks autonomously, allowing remote control of your local development environment from anywhere.140MIT
- AlicenseNot gradedqualityDmaintenanceA local-first MCP server for coordinating parallel AI coding sessions with tools like Claude Code and Codex in a single repository.2MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol (MCP) server that turns multiple AI coding agents into a coordinated team that chats, debates, remembers, audits security, and works in parallel on the same project.MIT
- FlicenseNot gradedqualityBmaintenanceA local MCP server that connects AI coding agents like Claude, Codex, and Gemini, enabling task routing, cross-model debates, and token-efficient context sharing without external APIs.19-