Back to MCP directory
publicPublicdnsLocal runtime

plexmcp-oss

PlexMCP是一个用于管理和编排MCP(模型上下文协议)服务器的统一网关平台,提供企业级认证、多租户隔离和全面的审计日志功能。

article

README

CodeRabbit Review - abc1234

Date: 2025-12-29T14:30:22Z Files Reviewed: 8 Issues Found: 27

Summary

  • Critical: 2
  • High: 5
  • Medium: 12
  • Low: 8

Issues

1. SQL Injection Vulnerability (critical)

File: crates/api/src/auth.rs:45 Category: security

Description: User input not sanitized in database query

Suggested Fix: Use parameterized queries with sqlx::query!


### 内存库集成

#### 自动索引
PlexMCP嵌入监视器会自动对Markdown审查文件进行索引:
1. **文件监视器**:检测`.coderabbit/reviews/`目录下的新`.md`文件。
2. **分块器**:将审查内容拆分为语义部分。
3. **嵌入生成**:使用Ollama(nomic-embed-text)生成嵌入向量。
4. **FAISS存储**:对向量进行索引,支持相似性搜索。
5. **SQLite FTS5**:对文本进行索引,支持关键字搜索。
**域名**:`coderabbit-reviews`

#### 通过MCP工具进行搜索
Claude Code可以使用`find_code_quality_issues()` MCP工具搜索审查历史。
**返回结果**:
- 相关的过去代码审查
- 问题描述和解决方案
- 文件位置和行号
- 时间模式(重复问题)

### 使用案例

#### 1. 从过去的错误中学习
**查询**:"What SQL injection vulnerabilities have we had?"
**结果**:所有提及SQL注入的过去审查,显示:
- 问题发生的位置
- 问题的修复方法
- 预防策略

#### 2. 跟踪重复问题
**查询**:"Show me all unwrap() issues in the last month"
**结果**:对`.unwrap()`使用情况的时间模式分析,帮助识别:
- 存在重复问题的文件
- 需要培训的开发人员
- 需要重构的区域

#### 3. 安全审计跟踪
**查询**:"Critical security issues in authentication code"
**结果**:认证相关文件中安全发现的完整历史:
- 发现的问题
- 问题的修复时间
- 修复问题的提交者

#### 4. 新开发人员入职
**查询**:"Common code quality issues in this codebase"
**结果**:汇总的模式,显示:
- 项目特定的编码标准
- 应避免的常见陷阱
- 最佳实践示例

#### 5. 版本质量检查
**查询**:"Issues found since last release tag"
**结果**:当前版本周期中引入的所有质量问题:
- 严重程度分布
- 文件影响分析
- 回归检测

### 维护

#### 存储大小
**增长率**:每次提交约10 - 50 KB(根据变更集大小而异)
**估计年度存储量**:约10 - 50 MB(假设每年1000次提交)
**建议**:无限期保留(成本低,价值高)

#### 清理(如有需要)
**归档旧审查**:
```bash
# Archive reviews older than 1 year
find .coderabbit/reviews -name "*.json" -mtime +365 -exec gzip {} \;
find .coderabbit/reviews -name "*.md" -mtime +365 -exec gzip {} \;

删除非常旧的审查

# Delete reviews older than 2 years (CAUTION)
find .coderabbit/reviews -name "*.json" -mtime +730 -delete
find .coderabbit/reviews -name "*.md" -mtime +730 -delete

# Re-index embeddings after deletion
cd .embeddings && npm run reindex

损坏恢复

如果JSON文件损坏

  1. 审查记录仍存在于git历史中:
git log --all --full-history -- .coderabbit/reviews/
git show <commit-hash>:.coderabbit/reviews/<filename>
  1. 从提交中重新生成:
git checkout <commit-hash>
coderabbit --type committed --output json > recovered.json

Git集成

是否应提交审查记录?

- 审查记录应提交到git,原因如下:

  1. 版本历史:将审查记录与特定提交关联起来。
  2. 团队共享:所有团队成员可以访问相同的审查历史。
  3. CI/CD集成:GitHub Actions可以分析趋势。
  4. 备份:审查记录保存在git历史中。
  5. 可审计性:提供完整的质量跟踪。

.gitignore考虑事项

不要忽略 .coderabbit/reviews/ - 这些文件应提交。 当前的.gitignore

# Do NOT ignore CodeRabbit reviews
# !.coderabbit/

# Temporary review files (if any)
.coderabbit/*.tmp
.coderabbit/*.lock

大型仓库问题

如果审查存储变得太大(不太可能): 选项1:对JSON文件使用Git LFS

git lfs track ".coderabbit/reviews/*.json"

选项2:使用单独的审查仓库

# Create separate repo
git init coderabbit-reviews
git remote add reviews https://github.com/org/plexmcp-reviews

# Store reviews there instead

故障排除

没有生成审查记录

检查

# 1. Post-commit hook exists and is executable
ls -la .git/hooks/post-commit
chmod +x .git/hooks/post-commit

# 2. Scripts exist and are executable
ls -la scripts/store-coderabbit-review.sh
chmod +x scripts/store-coderabbit-review.sh

# 3. CodeRabbit authenticated
coderabbit auth status

手动触发

bash scripts/store-coderabbit-review.sh

审查记录无法搜索

检查

# 1. Markdown files exist
ls .coderabbit/reviews/*.md

# 2. Watcher is indexing them
cd .embeddings && npm run stats
# Should show coderabbit-reviews domain

# 3. Re-index if needed
npm run reindex

审查记录为空

原因:CodeRabbit执行失败(网络、认证、超时) 修复

# Check last commit review manually
coderabbit --type committed --output json

# If works, re-generate review
bash scripts/store-coderabbit-review.sh

最佳实践

1. 立即提交审查记录

审查记录与所审查的代码一起提交时最有价值。 工作流程

git add .
git commit -m "Implement feature X"
# Post-commit hook runs automatically, stores review

git add .coderabbit/reviews/
git commit -m "Add CodeRabbit review for feature X"
git push

替代方法:在同一提交中包含审查记录(需要自定义钩子)

2. 在主要版本发布前进行审查

在发布前,搜索未解决的问题:

// Via Claude Code
find_code_quality_issues({
  query: "critical high severity issues",
  severity: "critical"
})

3. 定期进行质量审计

每月审查模式:

# Generate summary report
cd .coderabbit/reviews
grep -h "^### " *.md | sort | uniq -c | sort -rn

4. 将审查记录链接到PR

在PR描述中引用审查文件:

## Code Quality

CodeRabbit review: `.coderabbit/reviews/2025-12-29-143022-abc1234.md`

**Issues found:** 5 (3 high, 2 medium)
**All resolved:**
help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client