Skip to content

docs: תכנון חיבור Claude.ai ל-CodeKeeper דרך MCP - #3176

Merged
amirbiron merged 1 commit into
mainfrom
claude/mcp-codekeeper-webapp-ldnzsg
Jul 19, 2026
Merged

docs: תכנון חיבור Claude.ai ל-CodeKeeper דרך MCP#3176
amirbiron merged 1 commit into
mainfrom
claude/mcp-codekeeper-webapp-ldnzsg

Conversation

@amirbiron

@amirbiron amirbiron commented Jul 19, 2026

Copy link
Copy Markdown
Owner

✨ תיאור קצר

הוספת מסמך תכנון מפורט לחיבור Claude.ai ל-CodeKeeper דרך Model Context Protocol (MCP). המסמך מתאר את הארכיטקטורה, אימות, כלים ומשאבים, ומפת דרכים לשלוש פאזות של מימוש — החל מ-MVP קריאה-בלבד עם Personal Access Token, דרך OAuth 2.1, וכלה בתמיכה בכתיבה.

📦 שינויים עיקריים

  • תיעוד (docs/)

פירוט:

  • הוספת FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md — מסמך תכנון מקיף בעברית המכסה:
    • תקציר מנהלים (What/Why)
    • רקע על שכבת הנתונים הקיימת ומודל הנתונים
    • דרישות Claude.ai לחיבור Custom Connector
    • ארכיטקטורה מוצעת (שירות MCP נפרד, ASGI)
    • כלים ומשאבים (Tools/Resources)
    • שתי פאזות אימות: PAT (פאזה 0) ו-OAuth 2.1 (פאזה 1)
    • פערים ב-API HTTP וכיצד גישת in-process פותרת אותם
    • שיקולי אבטחה ופרטיות
    • תשתית ופריסה ב-Render
    • מפת דרכים עם הערכת מאמץ
    • סיכונים ותוכנית Rollback
    • שאלות פתוחות להחלטה

🧪 בדיקות

לא נדרשות — זהו מסמך תכנון בלבד, ממתין לאישור כיוון לפני כתיבת קוד.

📝 סוג שינוי

  • docs: שינוי תיעוד בלבד

✅ צ'קליסט

  • תיעוד עודכן (מסמך תכנון חדש)
  • אין סודות/מפתחות בקוד
  • אין מחיקות מסוכנות
  • הודעת הקומיט תואמת Conventional Commits

🧩 השפעות/סיכונים

אין השפעה על קוד או פרודקשן — זהו מסמך תכנון בלבד. המסמך משמש כמקור אמת לדיון ואישור כיוון לפני תחילת המימוש.

🔗 קישורים

  • CodeBot – Project Docs
  • ראו גם: CLAUDE.md (מדיניות מחייבת)
  • ענף פיתוח: claude/mcp-codekeeper-webapp-ldnzsg

🧯 סיכון / החזרה לאחור (Rollback)

לא רלוונטי — מסמך תכנון בלבד. ניתן להסיר את הקובץ בקלות אם יוחלט לא להמשיך

https://claude.ai/code/session_01WNFuSyshwpRcxozVZEui5K

Summary by CodeRabbit

  • תיעוד
    • נוסף מסמך תכנון לאינטגרציה עתידית עם Claude.ai באמצעות Remote MCP.
    • המסמך מתאר גישה לקריאה וחיפוש של קטעי קוד, מודל הרשאות, אבטחה, פרטיות ופריסה.
    • מוגדרת מפת דרכים הכוללת MVP לקריאה בלבד ובהמשך תמיכה ב-OAuth 2.1.

מסמך תכנון לחיבור 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
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown

🧯 Dangerous deletes guard report

Policy: see .cursorrules — dangerous deletions are blocked unless wrapped safely.

Summary:

  • Flagged findings (blocking): 0
    0
  • Excluded matches (not blocking): 15
  • Total matches (all files): 129

Flagged findings (file:line:snippet):
(none)

Excluded matches (by path pattern)
./webapp/static/js/md_preview.bundle.js.map:4:  "sourcesContent": ["// Markdown-it plugin to render GitHub-style task lists; see\n//\n// https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments\n// https://github.com/blog/1825-t … [truncated]
./README.md:842:find . -name "__pycache__" -exec rm -rf {} +
./Dockerfile:42:    rm -rf /var/lib/apt/lists/*
./Dockerfile:121:    rm -rf /var/lib/apt/lists/*
./node_modules/mermaid/dist/mermaid.min.js:1524:`,"getStyles"),c1e=RQe});var h1e={};dr(h1e,{diagram:()=>NQe});var NQe,f1e=N(()=>{"use strict";$ge();a1e();l1e();u1e();NQe={parser:Fge,db:n1e,renderer:o1e,styles:c1e}});var m1e,g1e=N(()=>{"use  … [truncated]
./node_modules/mermaid/dist/mermaid.min.js.map:4:  "sourcesContent": ["/**\n* Default values for dimensions\n*/\nconst defaultIconDimensions = Object.freeze({\n\tleft: 0,\n\ttop: 0,\n\twidth: 16,\n\theight: 16\n});\n/**\n* Default values fo … [truncated]
./node_modules/mermaid/dist/chunks/mermaid.core/chunk-KS23V3DP.mjs.map:4:  "sourcesContent": ["{\n  \"name\": \"mermaid\",\n  \"version\": \"11.12.0\",\n  \"description\": \"Markdown-ish syntax for generating flowcharts, mindmaps, sequence  … [truncated]
./node_modules/mermaid/dist/chunks/mermaid.esm/chunk-2M32CCKP.mjs.map:4:  "sourcesContent": ["{\n  \"name\": \"mermaid\",\n  \"version\": \"11.12.0\",\n  \"description\": \"Markdown-ish syntax for generating flowcharts, mindmaps, sequence d … [truncated]
./node_modules/mermaid/dist/chunks/mermaid.esm.min/chunk-4HFYJGYH.mjs.map:4:  "sourcesContent": ["{\n  \"name\": \"mermaid\",\n  \"version\": \"11.12.0\",\n  \"description\": \"Markdown-ish syntax for generating flowcharts, mindmaps, sequen … [truncated]
./node_modules/mermaid/dist/chunks/mermaid.esm.min/chunk-4HFYJGYH.mjs:1:var r={name:"mermaid",version:"11.12.0",description:"Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graph … [truncated]
./node_modules/mermaid/dist/mermaid.js.map:4:  "sourcesContent": ["/**\n* Default values for dimensions\n*/\nconst defaultIconDimensions = Object.freeze({\n\tleft: 0,\n\ttop: 0,\n\twidth: 16,\n\theight: 16\n});\n/**\n* Default values for tr … [truncated]
./node_modules/katex/src/fonts/Makefile:139:	rm -rf pfa ff otf ttf woff woff2
./node_modules/katex/package.json:153:    "build": "rimraf dist/ && mkdirp dist && cp README.md dist && rollup -c --failAfterWarnings && webpack && node update-sri.js package dist/README.md",
./docs/Makefile:24:	rm -rf $(BUILDDIR)
./docs/DOCUMENTATION_GUIDE.md:453:rm -rf _build

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

המסמך מתכנן אינטגרציה של Claude.ai עם CodeKeeper באמצעות Remote MCP, כולל שירות ASGI נפרד, כלי קריאה, אימות PAT ו-OAuth, בידוד משתמשים, אבטחה, פריסה ומפת דרכים.

Changes

אינטגרציית MCP עם Claude

Layer / File(s) Summary
רקע וארכיטקטורת השירות
FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md
מתוארים שכבת הנתונים הקיימת ושירות MCP נפרד מבוסס ASGI עם גישה ישירה למסד הנתונים וגזירת user_id מטוקן מאומת.
ממשק MCP ואימות
FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md
מוגדרים כלי MCP, Smart Projection, אימות PAT ו-OAuth 2.1, בידוד משתמשים ובקרות אבטחה.
תשתית, שלבים ו-Rollback
FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md
מוצעים שירות Render, מודולים ותלויות, שלבי יישום ובדיקות, מנגנוני Rollback ושאלות פתוחות.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Poem

ארנב קטן קפץ אל השרת,
עם Claude ביד ו-MCP במחברת.
טוקן נשמר, הקוד מבודד,
Read-only רוקד מצד לצד,
והדרך לפריסה כבר מסודרת.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed הכותרת קצרה, ברורה, ומתארת במדויק את השינוי המרכזי: מסמך תכנון לחיבור Claude.ai דרך MCP.
Description check ✅ Passed תיאור ה-PR מכסה את רוב חלקי התבנית: מה, למה, שינויים עיקריים, בדיקות, סיכונים, קישורים ו-Rollback.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/mcp-codekeeper-webapp-ldnzsg

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

⏱️ Performance report

(No performance test durations collected. Mark tests with @pytest.mark.performance.)

@codecov

codecov Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@amirbiron
amirbiron merged commit 63446b6 into main Jul 19, 2026
22 of 23 checks passed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🧹 Nitpick comments (2)
FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md (2)

194-198: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

יישרו את ה-roadmap עם ה-MCP surface שהוגדר.

בטבלת הכלים מוגדרים גם get_version_diff ו-list_collections, אך פאזה א׳ מונה רק ארבעה כלים. ציינו במפורש אילו כלים ומשאבים שייכים ל-MVP ואילו נדחים, ועדכנו בהתאם את הבדיקות וקריטריוני הקבלה.

🤖 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` around lines 194 -
198, Update the roadmap table’s phase א׳ entry to explicitly align with the
defined MCP surface, including whether get_version_diff and list_collections are
part of the MVP or deferred. Adjust the phase א׳ tests and acceptance criteria
to cover every tool and resource assigned to the MVP, and state the deferred
items in the appropriate later phase.

91-105: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

תקנו את אזהרות Markdown של המסמך.

הוסיפו שפת fenced block לתרשים (text) והוסיפו שורות ריקות לפני ואחרי טבלת הכלים, בהתאם לאזהרות MD040 ו-MD058.

Also applies to: 117-123

🤖 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` around lines 91 - 105,
Update the fenced diagram block in FEATURE_MCP_CLAUDE_INTEGRATION.md to declare
the text language, and add blank lines immediately before and after the tools
table in the affected sections. Ensure both the diagram and table formatting
satisfy Markdown rules MD040 and MD058.

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 `@FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md`:
- Around line 107-112: Update the MCP deployment configuration and documentation
to use a dedicated MongoDB user and read-only URI, separate from the webapp’s
MONGODB_URL. Reference the MCP-specific environment variable in its connection
setup, and document the required read-only database permissions and secret
configuration.
- Around line 26-39: עדכנו את תיאור בידוד המשתמשים סביב get_file_by_id כך שיציין
כי הפעולה אינה מסננת לפי user_id. חייבו את שרת ה-MCP לבצע בדיקת בעלות מפורשת מול
user_id שנגזר מהטוקן לפני החזרת מטא-דאטה או תוכן, או השתמשו ב-API חדש שמסנן לפי
משתמש; השאירו את שאר פעולות ה-DB המסוננות ללא שינוי.
- Around line 204-208: הרחיבו את סעיף Rollback כך שיכלול ביטול מפורש של OAuth
grants ו-access/refresh tokens באמצעות מנגנון revocation אחיד, או הסירו את הטענה
שהפעולה מנתקת “הכול” אם OAuth מנוהל בנפרד. עדכנו את תיאור מנגנון האחסון והביטול
כך שיכסה גם את mcp_tokens וגם את הרשאות OAuth.
- Around line 184-188: עדכנו את סעיף **ENV משותף** כך ששירות ה‑MCP לא יקבל את
`SECRET_KEY` או `WEBAPP_LOGIN_SECRET` של הוובאפ; הגדירו secret ייעודי ל‑MCP או
מנגנון handoff חד־פעמי חתום עבור האינטגרציה.
- Around line 124-126: עדכנו את תיאור החוזה של get_version_diff כך שישקף את שכבת
השירות: קבלו file_id, פתרו אותו ל-file_name, בצעו בדיקת בעלות, ואז הפעילו ישירות
את diff_service.compare_versions עם left ו-right האופציונליים. הסירו את התלות
המוצהרת ב-route של Flask והפנו במקום זאת לזרימת השירות הזו.
- Around line 78-82: הרחב את סעיף Discovery במסמך כך שיתאר את הזרימה המלאה:
תגובת 401 עם כותרת WWW-Authenticate הכוללת resource_metadata, שליפת Protected
Resource Metadata, ולאחר מכן גילוי Authorization Server Metadata. ציין
ש-/.well-known/oauth-protected-resource הוא fallback בלבד, וש-PRM ושרת ההרשאות
עשויים להימצא ב-host או בנתיב נפרדים, כולל סביב /mcp.
- Around line 155-161: עדכנו את תיאור זרימת OAuth 2.1 בשלב “פאזה 1 — OAuth 2.1”
כך ש־`/authorize` ידרוש ויאמת `state` נגד CSRF ויאפשר רק `redirect_uri` מתוך
allowlist קשיח. הגדירו authorization code חד־פעמי עם תפוגה קצרה, הקשור
ל־`client_id`, ל־`redirect_uri` ול־PKCE verifier, ותעדו את כתובת ה־callback של
Claude.
- Line 185: Update the Render web service example in the MCP integration
documentation so its startCommand runs Uvicorn bound to 0.0.0.0 and uses the
$PORT environment variable, rather than only specifying mcp_server.app:app.

---

Nitpick comments:
In `@FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md`:
- Around line 194-198: Update the roadmap table’s phase א׳ entry to explicitly
align with the defined MCP surface, including whether get_version_diff and
list_collections are part of the MVP or deferred. Adjust the phase א׳ tests and
acceptance criteria to cover every tool and resource assigned to the MVP, and
state the deferred items in the appropriate later phase.
- Around line 91-105: Update the fenced diagram block in
FEATURE_MCP_CLAUDE_INTEGRATION.md to declare the text language, and add blank
lines immediately before and after the tools table in the affected sections.
Ensure both the diagram and table formatting satisfy Markdown rules MD040 and
MD058.
🪄 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: ff8c42dd-dd52-4876-a1a4-bfef1dffbcf1

📥 Commits

Reviewing files that changed from the base of the PR and between f8c985f and 60f39df.

📒 Files selected for processing (1)
  • FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md

Comment on lines +26 to +39
from database import db # DatabaseManager singleton (database/__init__.py:11)

db.get_user_files(user_id, limit=50, skip=0) # רשימה, ללא שדות כבדים
db.get_latest_version(user_id, file_name) # תוכן מלא של קובץ
db.get_file_by_id(file_id) # תוכן מלא לפי _id
db.search_code(user_id, query, programming_language=None, tags=None, limit=20)
db.get_all_versions(user_id, file_name) # היסטוריית גרסאות
db.save_file(user_id, file_name, code, programming_language, extra_tags=None)
db.delete_file(user_id, file_name) # מחיקה רכה (recycle bin)
```

מקורות: `database/repository.py` (למשל `get_user_files:846`, `get_latest_version:781`, `search_code:925`, `save_file:682`, `save_code_snippet:201`), delegation ב‑`database/manager.py`.

**נקודה קריטית:** אין אימות בשכבת ה‑DB — כל שיטה מסוננת לפי `user_id` אבל **סומכת על הקורא** שיעביר `user_id` נכון. לכן שרת ה‑MCP חייב לגזור את `user_id` מהטוקן בלבד, ואף פעם לא מקלט של הלקוח.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

תקנו את תיאור בידוד המשתמשים בשכבת ה-DB.

get_file_by_id(file_id) אינו מקבל user_id, ולכן אינו מסנן לפי בעלות בעצמו. בפועל, webapp/app.py ו-services/diff_service.py שולפים לפי מזהה ואז מבצעים בדיקת בעלות מפורשת. יש לעדכן את המסמך ולחייב בדיקת בעלות לפני החזרת מטא-דאטה או תוכן, או להוסיף API מסונן לפי משתמש.

🤖 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` around lines 26 - 39,
עדכנו את תיאור בידוד המשתמשים סביב get_file_by_id כך שיציין כי הפעולה אינה מסננת
לפי user_id. חייבו את שרת ה-MCP לבצע בדיקת בעלות מפורשת מול user_id שנגזר מהטוקן
לפני החזרת מטא-דאטה או תוכן, או השתמשו ב-API חדש שמסנן לפי משתמש; השאירו את שאר
פעולות ה-DB המסוננות ללא שינוי.

Comment on lines +78 to +82
- **תעבורה:** Streamable HTTP (לא stdio — stdio זה רק Claude Desktop מקומי).
- **אימות:** **OAuth 2.1 + PKCE (S256)** — חובה. עם רישום לקוח דינמי (**DCR**, RFC 7591) או CIMD / credentials מוחזקים ע"י Anthropic.
- **Discovery:** Protected Resource Metadata (RFC 9728) ב‑`/.well-known/oauth-protected-resource`, ו‑Authorization Server Metadata ב‑`/.well-known/oauth-authorization-server`.
- **Refresh tokens:** רוטציה עבור public clients.
- **רשת:** טווח ה‑egress של Anthropic חייב להגיע לשרת.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

sed -n '68,92p' FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md

Repository: amirbiron/CodeBot

Length of output: 1426


🏁 Script executed:

python3 - <<'PY'
from pathlib import Path
p = Path('FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md')
for i, line in enumerate(p.read_text(encoding='utf-8').splitlines(), 1):
    if 70 <= i <= 90:
        print(f"{i}: {line}")
PY

Repository: amirbiron/CodeBot

Length of output: 1424


🌐 Web query:

Claude MCP authentication discovery 401 WWW-Authenticate Protected Resource Metadata path-aware /mcp host separate authorization server

💡 Result:

The Model Context Protocol (MCP) uses a standardized OAuth 2.1-based authentication discovery mechanism to establish trust between MCP clients and servers [1][2][3]. When a client attempts to access a protected resource without a valid token, the server initiates an authentication handshake using the HTTP 401 Unauthorized status code [4][5]. The core discovery process relies on the following components: 1. 401 WWW-Authenticate Challenge: The MCP server returns a 401 Unauthorized response that must include a WWW-Authenticate header [1][6]. This header includes a resource_metadata parameter, which is a URL pointing to the server's Protected Resource Metadata (PRM) document [4][5]. This method is the primary and most reliable discovery path, particularly for hosting environments that restrict access to the root /.well-known/ paths [7][3]. 2. Protected Resource Metadata (PRM): Following RFC 9728, the client fetches the PRM document from the URL provided in the WWW-Authenticate header [2]. This JSON document explicitly identifies the authorization server(s) the MCP server trusts [4][8]. 3. Authorization Server Discovery: Once the client has the authorization server's URL from the PRM, it performs standard OAuth 2.0/OIDC discovery by querying the authorization server's metadata endpoint (typically /.well-known/oauth-authorization-server or /.well-known/openid-configuration) [9][1][3]. 4. Fallback Mechanisms: If an MCP server does not provide the resource_metadata URL in the WWW-Authenticate header, MCP clients are required to fall back to probing standard well-known URIs (e.g., /.well-known/oauth-protected-resource) on the server's origin [9][6][8]. Path-Aware Considerations: The resource_metadata URL is flexible and does not need to be hosted at the MCP server's root [7]. This is designed to support platforms like serverless functions (e.g., Cloudflare Workers, Supabase Edge Functions) that may only route specific path prefixes rather than the standard /.well-known/* paths [7]. Configuration Guidance: Servers can include an optional scope parameter in the WWW-Authenticate header to signal the minimum required permissions to the client [4][6]. If omitted, clients typically fall back to the scopes advertised in the PRM's scopes_supported field [7][4]. Developers should ensure their servers correctly return this 401 handshake, as failures at this stage are a common cause of connectivity issues, often misdiagnosed as client or network errors [7][9][2].

Citations:


להוסיף גם את זרימת ה-discovery המלאה

Claude לא מסתמך רק על /.well-known/...: צריך לתאר את ה-401 עם WWW-Authenticate שמפנה ל-resource_metadata, את שלב ה-PRM, ואת גילוי Authorization Server metadata. /.well-known/oauth-protected-resource הוא fallback, וה-PRM/ה-Authorization Server יכולים להיות גם ב-host/נתיב נפרד (למשל סביב /mcp).

🤖 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` around lines 78 - 82,
הרחב את סעיף Discovery במסמך כך שיתאר את הזרימה המלאה: תגובת 401 עם כותרת
WWW-Authenticate הכוללת resource_metadata, שליפת Protected Resource Metadata,
ולאחר מכן גילוי Authorization Server Metadata. ציין
ש-/.well-known/oauth-protected-resource הוא fallback בלבד, וש-PRM ושרת ההרשאות
עשויים להימצא ב-host או בנתיב נפרדים, כולל סביב /mcp.

Comment on lines +107 to +112
**למה שירות נפרד ולא בתוך הוובאפ:**
- ה‑worker של הוובאפ יחיד ורגיש לזיכרון ב‑Render — לא רוצים להעמיס עליו SSE ארוך‑טווח.
- MCP נוח יותר כ‑ASGI (`uvicorn`), בעוד הוובאפ הוא WSGI.
- בידוד = פחות סיכון; אפשר לתת הרשאות קריאה בלבד ל‑DB בשלב א'.
- שיתוף פשוט: אותו `MONGODB_URL` ואותם סודות דרך ENV ב‑Render.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

הפרידו הרשאות MongoDB לשירות ה-MCP.

שיתוף MONGODB_URL עם הוובאפ אינו מאפשר בפועל הרשאת read-only בשלב א׳, משום שאותו חיבור יכול להגיע גם ל-save_file ולפעולות מחיקה. הגדירו משתמש MongoDB ו-URI ייעודיים עם הרשאות קריאה בלבד, ולא הסתמכו רק על כך שהכלים עצמם לא יפורסמו.

🤖 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` around lines 107 -
112, Update the MCP deployment configuration and documentation to use a
dedicated MongoDB user and read-only URI, separate from the webapp’s
MONGODB_URL. Reference the MCP-specific environment variable in its connection
setup, and document the required read-only database permissions and secret
configuration.

Comment on lines +124 to +126
| `get_file` | `file_name` \| `file_id`, `version?` | תוכן מלא + מטא‑דאטה | `get_latest_version` / `get_file_by_id` |
| `list_versions` | `file_name` | היסטוריית גרסאות | `get_all_versions` |
| `get_version_diff` | `file_id`, `left?`, `right?` | diff בין גרסאות | `webapp/app.py:3264` (compare) |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

יישרו את החוזה של get_version_diff עם שכבת השירות.

הכלי מקבל file_id, אך התלות המוצהרת היא route של Flask. בפועל, ה-route פותר file_id ל-file_name, בודק בעלות, ואז קורא ל-diff_service.compare_versions. במסמך צריך להגדיר במפורש את אותו חוזה בשירות ה-MCP, בלי תלות בקריאה ל-route של הוובאפ.

🤖 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` around lines 124 -
126, עדכנו את תיאור החוזה של get_version_diff כך שישקף את שכבת השירות: קבלו
file_id, פתרו אותו ל-file_name, בצעו בדיקת בעלות, ואז הפעילו ישירות את
diff_service.compare_versions עם left ו-right האופציונליים. הסירו את התלות
המוצהרת ב-route של Flask והפנו במקום זאת לזרימת השירות הזו.

Comment on lines +155 to +161
### פאזה 1 — OAuth 2.1 (מה שהופך אותו ל‑Connector של Claude.ai)
- מכיוון שהזהות כבר קיימת דרך טלגרם, מסך ה‑`/authorize` **משתמש בסשן הטלגרם הקיים**: אם המשתמש כבר מחובר לוובאפ — מציגים מסך אישור (consent) ומנפיקים authorization code; אם לא — שולחים אותו לזרימת ההתחברות הקיימת ואז חוזרים.
- להנפיק access token (קצר) + refresh token (עם רוטציה), קשורים ל‑`user_id` ול‑`scopes`.
- להגיש `/.well-known/oauth-protected-resource` ו‑`/.well-known/oauth-authorization-server`, ולתמוך ב‑DCR.
- מימוש מומלץ: `authlib` (יש כבר `google-auth-oauthlib` באקוסיסטם) או שכבת ה‑Auth המובנית של MCP Python SDK / FastMCP.

**חשוב:** access/refresh tokens נשמרים גם הם רק כ‑hash, וה‑`user_id` לעולם לא מגיע מהלקוח אלא מהטוקן שאומת.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the target file around the referenced lines and search for OAuth / PKCE / state mentions.
FILE="FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md"

printf '\n== File line count ==\n'
wc -l "$FILE"

printf '\n== Target excerpt ==\n'
sed -n '130,190p' "$FILE" | cat -n

printf '\n== Relevant terms in repo ==\n'
rg -n --hidden --glob '!**/.git/**' -e 'state|PKCE|redirect_uri|authorization code|oauth-protected-resource|oauth-authorization-server|DCR|callback URL|Claude' FEATURE_SUGGESTIONS docs . 2>/dev/null || true

Repository: amirbiron/CodeBot

Length of output: 50374


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md"

echo "== around target lines =="
sed -n '145,175p' "$FILE" | cat -n

echo
echo "== oauth-related mentions in the file =="
rg -n -C 2 'state|CSRF|PKCE|redirect_uri|authorization code|callback|OAuth 2\.1|DCR|\.well-known|consent|claude' "$FILE" || true

echo
echo "== nearby docs/notes with similar auth language =="
rg -n -C 2 'PKCE|state|redirect_uri|CSRF|authorization code' FEATURE_SUGGESTIONS || true

Repository: amirbiron/CodeBot

Length of output: 36926


הוסיפו קשירה מפורשת של זרימת /authorize ל־state ול־redirect_uri

אם המסך נשען על סשן טלגרם קיים, צריך לדרוש state נגד CSRF, allowlist קשיח ל־redirect_uri, קוד חד־פעמי עם תפוגה קצרה, וקשירה של הקוד ל־client_id, ל־redirect_uri ול־PKCE verifier. אחרת אישור של Claude יכול להיקשר לסשן או ללקוח אחר. לתעד גם את ה־callback URL של Claude.

🤖 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` around lines 155 -
161, עדכנו את תיאור זרימת OAuth 2.1 בשלב “פאזה 1 — OAuth 2.1” כך ש־`/authorize`
ידרוש ויאמת `state` נגד CSRF ויאפשר רק `redirect_uri` מתוך allowlist קשיח.
הגדירו authorization code חד־פעמי עם תפוגה קצרה, הקשור ל־`client_id`,
ל־`redirect_uri` ול־PKCE verifier, ותעדו את כתובת ה־callback של Claude.

Comment on lines +184 to +188
## 9. תשתית ופריסה
- **שירות Render חדש** (web, ASGI) — למשל `code-keeper-mcp`, `dockerfilePath`/`startCommand` = `uvicorn mcp_server.app:app`.
- **ENV משותף:** `MONGODB_URL`, `DATABASE_NAME`, `SECRET_KEY`/`WEBAPP_LOGIN_SECRET`, ו‑ENV ייעודי ל‑OAuth (issuer URL, טווח תוקף וכו').
- **תלויות חדשות** (בקובצי `requirements/`): `mcp` (MCP Python SDK / FastMCP), ובפאזה 1 גם `authlib`.
- **תיקייה חדשה** מוצעת: `mcp_server/` בשורש (או תת‑שירות תחת `services/`), עם `app.py`, `auth.py`, `tools.py`, `resources.py`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

אל תשתפו את SECRET_KEY של הוובאפ עם שירות MCP ציבורי.

הוובאפ משתמש בעוגיית סשן חתומה; חשיפת אותו secret לתהליך MCP חיצוני מגדילה את הנזק במקרה של פריצת השירות ועלולה לאפשר זיוף סשנים. העדיפו handoff חד-פעמי חתום או secret ייעודי, במקום להעביר את SECRET_KEY/WEBAPP_LOGIN_SECRET לשירות החדש.

🤖 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` around lines 184 -
188, עדכנו את סעיף **ENV משותף** כך ששירות ה‑MCP לא יקבל את `SECRET_KEY` או
`WEBAPP_LOGIN_SECRET` של הוובאפ; הגדירו secret ייעודי ל‑MCP או מנגנון handoff
חד־פעמי חתום עבור האינטגרציה.

---

## 9. תשתית ופריסה
- **שירות Render חדש** (web, ASGI) — למשל `code-keeper-mcp`, `dockerfilePath`/`startCommand` = `uvicorn mcp_server.app:app`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

git ls-files FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md
wc -l FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md
sed -n '165,200p' FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md

Repository: amirbiron/CodeBot

Length of output: 2542


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
import urllib.request, json, re
url = "https://render.com/docs/deploy-fastapi"
with urllib.request.urlopen(url, timeout=20) as r:
    text = r.read().decode('utf-8', errors='replace')
# print some relevant snippets
for pat in [
    r'0\.0\.0\.0',
    r'PORT',
    r'uvicorn .*--host 0\.0\.0\.0',
]:
    m = re.search(pat, text, re.I)
    print(f"PATTERN {pat!r}:", "FOUND" if m else "NOT FOUND")
# Print surrounding text for the first occurrence of PORT or 0.0.0.0
for key in ['0.0.0.0', 'PORT', 'uvicorn']:
    idx = text.lower().find(key.lower())
    if idx != -1:
        start = max(0, idx-200)
        end = min(len(text), idx+500)
        print(f"\n--- CONTEXT around {key} ---\n")
        print(text[start:end])
        break
PY

Repository: amirbiron/CodeBot

Length of output: 2749


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the current repository text for any alternative start commands or PORT guidance.
rg -n --hidden --glob '!**/.git/**' 'uvicorn mcp_server\.app:app|PORT|0\.0\.0\.0|Render' FEATURE_SUGGESTIONS

Repository: amirbiron/CodeBot

Length of output: 1916


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect nearby Render/deployment guidance and any existing start commands in the repo.
sed -n '1288,1315p' FEATURE_SUGGESTIONS/DOCUMENTATION_NEEDS.md
printf '\n---\n'
sed -n '1802,1822p' FEATURE_SUGGESTIONS/DOCUMENTATION_NEEDS.md
printf '\n---\n'
rg -n --hidden --glob '!**/.git/**' 'PORT|0\.0\.0\.0|uvicorn .*app:app|gunicorn|startCommand|dockerfilePath' scripts FEATURE_SUGGESTIONS

Repository: amirbiron/CodeBot

Length of output: 4067


🌐 Web query:

Render FastAPI deployment uvicorn host 0.0.0.0 PORT documentation

💡 Result:

To deploy a FastAPI application on Render, you must configure your web service to bind to the host 0.0.0.0 and the port provided by the Render environment variable PORT [1][2]. When configuring your Web Service in the Render Dashboard, use the following Start Command [3][4]: uvicorn main:app --host 0.0.0.0 --port $PORT Key details for this configuration: - Host 0.0.0.0: Render requires your application to bind to 0.0.0.0 to receive inbound HTTP requests from the public internet [1][2]. Binding to localhost or 127.0.0.1 will result in the service being unreachable [2]. - Port $PORT: Render automatically assigns a port to your service (the default is 10000) and provides it via the PORT environment variable [1][2]. Using $PORT in your start command ensures your application dynamically binds to the correct port allocated by Render [1][5]. If you are writing this directly in your Python code, you can handle the port dynamically as follows [2]: import os import uvicorn from fastapi import FastAPI app = FastAPI if name == "main": port = int(os.environ.get("PORT", 8000)) uvicorn.run(app, host="0.0.0.0", port=port) Ensure your build command is correctly set to install your dependencies, typically pip install -r requirements.txt [3][6].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '1288,1315p' FEATURE_SUGGESTIONS/DOCUMENTATION_NEEDS.md
printf '\n---\n'
sed -n '1802,1822p' FEATURE_SUGGESTIONS/DOCUMENTATION_NEEDS.md
printf '\n---\n'
rg -n --hidden --glob '!**/.git/**' 'PORT|0\.0\.0\.0|uvicorn .*app:app|gunicorn|startCommand|dockerfilePath' scripts FEATURE_SUGGESTIONS

Repository: amirbiron/CodeBot

Length of output: 4067


תקנו את פקודת ההפעלה ל‑Render

ב־Render שירות web צריך להאזין על 0.0.0.0 ועל $PORT; uvicorn mcp_server.app:app לבדו לא מספיק.

תיקון מוצע
-uvicorn mcp_server.app:app
+uvicorn mcp_server.app:app --host 0.0.0.0 --port $PORT
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- **שירות Render חדש** (web, ASGI) — למשל `code-keeper-mcp`, `dockerfilePath`/`startCommand` = `uvicorn mcp_server.app:app`.
- **שירות Render חדש** (web, ASGI) — למשל `code-keeper-mcp`, `dockerfilePath`/`startCommand` = `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 `@FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md` at line 185, Update
the Render web service example in the MCP integration documentation so its
startCommand runs Uvicorn bound to 0.0.0.0 and uses the $PORT environment
variable, rather than only specifying mcp_server.app:app.

Comment on lines +204 to +208
## 11. סיכונים ו‑Rollback
- **חשיפת נתונים אישיים** → מיטיגציה: read‑only כברירת מחדל, scopes, טוקנים ניתנים לביטול, בידוד `user_id` נבדק בטסטים.
- **עומס זיכרון** → שירות נפרד, לא בתוך worker הוובאפ.
- **מורכבות OAuth** → מתחילים מ‑PAT (פאזה 0) שמוכיח ערך בלי OAuth.
- **Rollback:** השירות נפרד — ביטול פריסה של `code-keeper-mcp` וביטול טוקנים (`mcp_tokens.revoked=true`) מנתק הכול בלי לגעת בבוט/וובאפ.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

הרחיבו את ה-Rollback כך שיבטל גם OAuth grants.

mcp_tokens.revoked=true מכסה את טוקני ה-PAT שהוגדרו בפאזה 0, אך המסמך מתאר access/refresh tokens של OAuth בלי לקבוע שהם נשמרים באותו מנגנון. הגדירו מנגנון revocation אחיד, או עדכנו את הטענה שפעולת rollback זו מנתקת “הכול”.

🤖 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` around lines 204 -
208, הרחיבו את סעיף Rollback כך שיכלול ביטול מפורש של OAuth grants
ו-access/refresh tokens באמצעות מנגנון revocation אחיד, או הסירו את הטענה
שהפעולה מנתקת “הכול” אם OAuth מנוהל בנפרד. עדכנו את תיאור מנגנון האחסון והביטול
כך שיכסה גם את mcp_tokens וגם את הרשאות OAuth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants