Claude/mcp codekeeper webapp ldnzsg - #3177
Conversation
מסמך תכנון לחיבור Claude.ai לקבצי המשתמש ב-CodeKeeper דרך שרת MCP מרוחק. - ממפה את הקיים: שכבת DB in-process (database/repository.py), אימות סשן (webapp/app.py:3204), וגשרי טוקנים קיימים (webapp_tokens/remember_tokens). - מציע ארכיטקטורה: שירות MCP נפרד (ASGI) שניגש ישירות ל-database, מסונן user_id. - אימות בשתי פאזות: PAT (MVP) → OAuth 2.1 מעל זהות טלגרם הקיימת. - כלים: list_files/search_code/get_file/list_versions (+ save_file בהמשך). - אבטחה: read-only כברירת מחדל, בידוד user_id מהטוקן, Smart Projection. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WNFuSyshwpRcxozVZEui5K
מימוש פאזה 0 מהתוכנית: שרת MCP מרוחק (Streamable HTTP) קריאה-בלבד שחושף את קבצי הקוד והאוספים של המשתמש ל-Claude Code/Desktop. - mcp_server/: חבילת FastMCP עם 7 כלים (list_files, search_code, get_file, list_versions, list_collections, get_collection, get_collection_items). ניגש ישירות ל-database.db + CollectionsManager, מסונן user_id, מכבד את חוק ה-Smart Projection (בלי code ברשימות/חיפוש). - אימות PAT: token_store.py מנהל טוקנים (hash בלבד) בקולקשן mcp_tokens; auth.py מאמת Bearer ומזריק user_id ל-request.state; ה-user_id נגזר תמיד מהטוקן, לעולם לא מקלט הלקוח. get_file בודק בעלות גם לפי file_id. - scripts/mcp_issue_token.py: הנפקת טוקן ל-CLI/בדיקות. - tests/test_mcp_*.py: 27 טסטים (fakes ידניים, בלי MongoDB אמיתי) — token store, בעלות/סריאליזציה, clamping, middleware, ורישום כלים. - requirements/base.txt: mcp==1.28.1 (תואם לפינים הקיימים). - מסמך התכנון עודכן לסטטוס "פאזה 0 מומשה" + README ל-mcp_server. פאזות הבאות (בתכנון): פקודת בוט /connect_claude, OAuth 2.1 ל-Claude.ai, כתיבה. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WNFuSyshwpRcxozVZEui5K
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reached
Next review available in: 26 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (10)
📝 WalkthroughWalkthroughנוסף שרת MCP מרוחק לקריאה בלבד עבור CodeKeeper, עם כלי שליפת קבצים ואוספים, אימות Personal Access Token, שכבת גישה ל-MongoDB, הפעלת ASGI, סקריפט הנפקת טוקנים, תיעוד ובדיקות יחידה ועשן. Changesאינטגרציית MCP עם Claude
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Claude
participant MCPServer
participant MCPTokenStore
participant ProductionBackend
participant MongoDB
Claude->>MCPServer: בקשת MCP עם Bearer token
MCPServer->>MCPTokenStore: אימות הטוקן
MCPTokenStore-->>MCPServer: user_id ו-scopes
MCPServer->>ProductionBackend: הפעלת כלי עם user_id
ProductionBackend->>MongoDB: שליפה מסוננת לפי המשתמש
MongoDB-->>ProductionBackend: מסמכי קבצים או אוספים
ProductionBackend-->>MCPServer: תוצאת JSON
MCPServer-->>Claude: תגובת כלי MCP
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🧯 Dangerous deletes guard reportPolicy: see .cursorrules — dangerous deletions are blocked unless wrapped safely. Summary:
Flagged findings (file:line:snippet): Excluded matches (by path pattern) |
⏱️ Performance report(No performance test durations collected. Mark tests with |
📖 Documentation PreviewThe documentation has been built successfully!
To view locally:
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (6)
mcp_server/app.py (1)
22-39: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueכפילות קוד – מציאת חיבור ל-MongoDB.
הפונקציה
_resolve_mongoממומשת פעמיים באופן זהה לחלוטין. מומלץ להעביר את הפונקציה למודול משותף (לדוגמה בקובץmcp_server/utils.pyאוmcp_server/backend.py) כדי לשמור על עקרונות DRY.
mcp_server/app.py#L22-L39: יש לייבא ולהשתמש בפונקציה מהמודול המשותף במקום להגדיר אותה מחדש.scripts/mcp_issue_token.py#L20-L34: יש לייבא ולהשתמש בפונקציה המשותפת במקום להגדיר אותה מחדש.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@mcp_server/app.py` around lines 22 - 39, Move the duplicated _resolve_mongo implementation into a shared module, preserving its current behavior, then import and use that shared function in mcp_server/app.py at lines 22-39 and scripts/mcp_issue_token.py at lines 20-34; remove the local definitions from both sites.FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md (2)
98-98: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueהוספת הגדרת שפה לבלוק הקוד.
כדאי להגדיר את סוג התוכן (למשל
text) בבלוק הקוד כדי למנוע אזהרות מסוג MD040 וכדי להבטיח תצוגה תקינה בכלים שונים.💡 הצעה לתיקון
-``` +```text ┌────────────┐ OAuth 2.1 (PKCE) ┌──────────────────────────┐🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md` at line 98, Specify the code block language as text for the ASCII diagram in the documentation, using the opening fence around the diagram to prevent MD040 warnings and preserve consistent rendering.Source: Linters/SAST tools
127-127: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueהוספת שורה ריקה לפני הטבלה.
רצוי להוסיף שורה ריקה לפני תחילת הטבלה כדי למנוע בעיות רינדור בפלטפורמות מסוימות (בהתאם לאזהרת Linter מסוג MD058).
💡 הצעה לתיקון
### 5.1 Tools + | כלי | קלט | פלט | נשען על |🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md` at line 127, Insert a blank line immediately before the Markdown table whose header begins with “| כלי | קלט | פלט | נשען על |” in FEATURE_MCP_CLAUDE_INTEGRATION.md, without changing the table content.Source: Linters/SAST tools
mcp_server/auth.py (1)
57-58: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winתיעוד שגיאות מערכת בתהליך האימות.
בליעת השגיאה לחלוטין מחזירה ללקוח שגיאת 401 גנרית, ועלולה להקשות מאוד על איתור תקלות בפרודקשן במקרה של בעיות חיבור למסד הנתונים. מומלץ לתעד (log) את השגיאה לפני שמגדירים את המשתמש כלא מאומת.
💡 הצעה לתיקון
- except Exception: + except Exception as e: + import logging + logging.warning("Token verification failed: %s", e) principal = None🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@mcp_server/auth.py` around lines 57 - 58, Update the exception handler in the authentication flow to log the caught exception before setting principal to None. Preserve the existing unauthenticated fallback while recording sufficient error details to diagnose production failures such as database connectivity issues.mcp_server/README.md (2)
17-18: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueהוסף שורה ריקה לפני תחילת הטבלה.
מומלץ להוסיף שורה ריקה לפני הטבלה (כאן ובשורה 90) כדי להבטיח שהיא תרונדר בצורה תקינה בכל הכלים למציאת תצוגת Markdown. כלי ה-linting (MD058) מתריע על חוסר בשורה כזו.
📝 הצעה לתיקון
### הכלים (Tools) + | כלי | תיאור |🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@mcp_server/README.md` around lines 17 - 18, Insert a blank line between the “### הכלים (Tools)” heading and the table beginning with “| כלי | תיאור |”, and apply the same Markdown spacing correction at the table near line 90.Source: Linters/SAST tools
81-81: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueהגדר שפה לבלוק הקוד.
כדאי להגדיר שפה (למשל
textאוbash) לבלוק הקוד על מנת לשפר את הקריאות ולמנוע אזהרות linting (MD040).📝 הצעה לתיקון
-``` +```text Start command: uvicorn mcp_server.app:app --host 0.0.0.0 --port $PORT🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@mcp_server/README.md` at line 81, Update the code block containing the Uvicorn start command in the README to specify an appropriate language identifier, such as text or bash, immediately after the opening fence, while preserving the command content.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@mcp_server/backend.py`:
- Around line 148-159: Update get_collection_items to ensure returned collection
items pass through _clean() before being exposed to the client, preserving the
existing pagination and folder filtering arguments. If the CollectionsManager
query already guarantees HEAVY_FIELDS_EXCLUDE_PROJECTION, verify and enforce
that projection there instead, ensuring heavy fields such as code cannot appear
in results.
---
Nitpick comments:
In `@FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md`:
- Line 98: Specify the code block language as text for the ASCII diagram in the
documentation, using the opening fence around the diagram to prevent MD040
warnings and preserve consistent rendering.
- Line 127: Insert a blank line immediately before the Markdown table whose
header begins with “| כלי | קלט | פלט | נשען על |” in
FEATURE_MCP_CLAUDE_INTEGRATION.md, without changing the table content.
In `@mcp_server/app.py`:
- Around line 22-39: Move the duplicated _resolve_mongo implementation into a
shared module, preserving its current behavior, then import and use that shared
function in mcp_server/app.py at lines 22-39 and scripts/mcp_issue_token.py at
lines 20-34; remove the local definitions from both sites.
In `@mcp_server/auth.py`:
- Around line 57-58: Update the exception handler in the authentication flow to
log the caught exception before setting principal to None. Preserve the existing
unauthenticated fallback while recording sufficient error details to diagnose
production failures such as database connectivity issues.
In `@mcp_server/README.md`:
- Around line 17-18: Insert a blank line between the “### הכלים (Tools)” heading
and the table beginning with “| כלי | תיאור |”, and apply the same Markdown
spacing correction at the table near line 90.
- Line 81: Update the code block containing the Uvicorn start command in the
README to specify an appropriate language identifier, such as text or bash,
immediately after the opening fence, while preserving the command content.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a0189f35-7799-4784-abf3-267777f6ceee
📒 Files selected for processing (16)
FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.mdmcp_server/README.mdmcp_server/__init__.pymcp_server/app.pymcp_server/auth.pymcp_server/backend.pymcp_server/handlers.pymcp_server/server.pymcp_server/token_store.pyrequirements/base.txtscripts/mcp_issue_token.pytests/test_mcp_auth_middleware.pytests/test_mcp_backend.pytests/test_mcp_handlers.pytests/test_mcp_server_build.pytests/test_mcp_token_store.py
… docs תיקוני סקירה (כל ההערות היו תקפות): - backend.get_collection_items: הגנת עומק — מסנן שדות כבדים (code/content) מפריטי אוסף לפני החזרה, כדי שלא ידלפו גם אם CollectionsManager ישתנה. - mcp_server/wiring.py: חילוץ resolve_mongo המשותף; הוסרו ההעתקים מ-app.py ומ-scripts/mcp_issue_token.py. - auth.py: לוג לחריגה שנבלעה ב-verify (בלי הטוקן) לצורך אבחון בפרודקשן. - Markdown: שפת code fence (text) לדיאגרמות ולבלוק ההרצה, ושורות ריקות לפני טבלאות (MD040/MD058) ב-README ובמסמך התכנון. - טסט חדש: מוודא שפריטי אוסף מסוננים משדות כבדים. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WNFuSyshwpRcxozVZEui5K
מוסיף פקודת בוט /connect_claude שמנפיקה למשתמש טוקן MCP אישי מתוך טלגרם (במקום להריץ סקריפט CLI), ומחזירה פקודת חיבור מוכנה ל-Claude Code. - main.py: connect_claude_command (מודול-לבל), רישום ב-setup_handlers, וכניסה ב-HELP_SECTIONS. אבטחה: מונפק בצ'אט פרטי בלבד (שלא ידלוף בקבוצה); fallback לטקסט אם פרסום HTML נכשל (לא לאבד את הטוקן). - files_facade.issue_mcp_token: עוטף את MCPTokenStore (import עצל) כדי לשמור את החיווט במקום אחד ולא לגעת ב-PyMongo גולמי מה-handler. - README + מסמך התכנון עודכנו: /connect_claude זמין, + ENV MCP_SERVER_URL. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WNFuSyshwpRcxozVZEui5K
תבנית Pull Request
✨ תיאור קצר
📦 שינויים עיקריים
פירוט נקודות (רשימת תבליטים):
🧪 בדיקות
🧪 בדיקות נדרשות ב‑PR
📝 סוג שינוי
דוגמאות Conventional Commits
✅ צ'קליסט
services/register_jobs.py(כולל Callback/Trigger להפעלה ידנית — למשלcallback_name/trigger_funcלפי המבנה) כדי שיופיעו בדשבורדdocs/environment-variables.rstוגםservices/config_inspector_service.pydocs/webapp/theming_and_css.rst+FEATURE_SUGGESTIONS/theme_matrix.md🧩 השפעות/סיכונים
🔗 קישורים
🧯 סיכון / החזרה לאחור (Rollback)
Summary by CodeRabbit
תכונות חדשות
תיעוד
בדיקות