本项目实现了一个MCP服务器,通过Gemini API(拥有200万token的超大上下文窗口)访问各类技术文档。该服务器适用于任何客户端,但特别针对Roo/Cline环境设计。
相比直接浏览网页或使用搜索引擎,这种方法具有以下优势:
同时,该方法还克服了传统RAG系统的一些问题:
不过也存在一些限制:
can_x_be_done
:检查特定任务是否可以在给定技术中完成hints_for_problem
:获取解决特定问题的提示is_this_good_practice
:检查代码片段是否符合良好实践how_to_do_x
:获取特定任务的示例和替代方法--verbose
标志启用)要通过Smithery为Claude Desktop自动安装Gemini文档服务器:
npx -y @smithery/cli install @M-Gonzalo/cosa-sai --client claude
此MCP服务器将由客户端自动启动和管理。要启用它,您需要在设置文件中进行配置(例如~/.config/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json
)。客户端通常有一个打开设置文件的按钮。
以下是此服务器的配置:
{
"command": "bun",
"args": [
"--watch",
"path/to/repo/cosa-sai-mcp/src/index.ts",
"--verbose"
],
"env": {
"GEMINI_API_KEY": "<您的Gemini API密钥>"
},
"disabled": false,
"alwaysAllow": [
"can_x_be_done",
"hints_for_problem",
"is_this_good_practice",
"how_to_do_x"
],
"timeout": 60 // 以秒为单位
}

此MCP服务器需要一个文档知识库来回答问题。您必须手动获取这个知识库,可以通过下载公共仓库、抓取网站或其他方法。
可以选择执行一个可选的清理过程,从原始文档中清除样式和其他不必要内容。
以下是一些基本工具。鼓励使用更好的解决方案:
简单抓取器:
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent --directory-prefix=./local_copy --no-verbose --show-progress $1

快速粗糙的Markdown风格转换器:
#!/bin/bash
directory="${1:-.}" # 如果没有提供参数,则默认为当前目录
output_file="${2:-concatenated.md}" # 默认输出文件名
echo "将'$directory'中的文件合并到'$output_file'..."
# 如果输出文件存在,则清空它
truncate -s 0 "$output_file"
# 查找所有文件(不包括目录)并处理它们
find "$directory" -type f -name '*.html' | while IFS= read -r file; do
echo "=== ${file#./} ===" >> "$output_file"
cat "$file" \
| grep -v 'base64' \
| html2markdown >> "$output_file"
echo -e "\n" >> "$output_file"
done
echo "完成!输出保存到'$output_file'"

此服务器提供以下工具:
docs
,prompt
,x
,technology
success
,data
docs
,prompt
,problem
,context
,environment
success
,data
docs
,prompt
,snippet
,context
success
,data
docs
,prompt
,x
,technology
success
,data
欢迎贡献!请遵循以下指南:
本项目采用MIT许可证。
这是项目的非常早期版本,可能存在错误和限制。如果您发现问题,请报告,也可以提出改进建议或新功能需求。