Skip to content

feat(mcp): כלי docs_get_section — סקשן בודד מתיעוד RST במקום קובץ שלם - #3198

Merged
amirbiron merged 3 commits into
mainfrom
feat/mcp-docs-get-section
Jul 26, 2026
Merged

feat(mcp): כלי docs_get_section — סקשן בודד מתיעוד RST במקום קובץ שלם#3198
amirbiron merged 3 commits into
mainfrom
feat/mcp-docs-get-section

Conversation

@amirbiron

Copy link
Copy Markdown
Owner

✨ תיאור קצר

כלי MCP חדש ציבורי codekeeper_docs_get_section שמחזיר סקשן בודד מקבצי ה-RST של התיעוד במקום קובץ שלם. במקום למשוך את environment-variables.rst (77KB / 2242 שורות) כדי לקרוא ערך אחד — מקבלים את הסקשן הרלוונטי + ניווט (עץ כותרות, breadcrumb, תת-סקשנים, שכנים). עיינתי ב-CodeBot Docs לפני המימוש.

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

  • קוד (Backend / שרת MCP)
  • בוט טלגרם
  • מסד נתונים/מיגרציות
  • תיעוד (docs/)
  • DevOps/CI/CD

פירוט:

  • services/rst_parser.py (מודול עצמאי, טהור): זיהוי כותרות דינמי פר-קובץ (לא קשיח ====1), תמיכה ב-underline ו-overline+underline, עמידות ל-literal/code blocks — שורת ===/--- בתוך Development:: או .. code-block:: אינה כותרת. התאמה סלחנית לעברית (רווחים/מקפים/case). מחזיר עץ כותרות, מועמדים לכותרת כפולה, והצעות ל-not-found.
  • mcp_server/docs_handlers.py: בונה מעל RepoBackend.get_file הקיים (reuse מלא של ברירת-ref, מדיניות סודות, ו-sync_in_progress). slug resolution (environment-variablesdocs/environment-variables.rst) ו-offset/max_chars לדפדוף בסקשנים גדולים.
  • mcp_server/server.py: רישום public (opt-in — הכלי לא קורא require_admin ואינו ב-_ADMIN_TOOLS), עם תיאור שמסביר מפורשות מתי להשתמש בו במקום get_repo_file.
  • ריפו ברירת מחדל CodeBot דרך env var חדש MCP_DOCS_REPO (ניתן לעקוף פר-קריאה ב-repo).

עקרון-על: לעולם לא רק "לא נמצא" — בלי section מחזיר TOC; section חסר מחזיר TOC + הצעות; כותרת כפולה מחזירה מועמדים עם breadcrumb.

🧪 בדיקות

  • Unit — 69 טסטים ירוקים (test_rst_parser, test_mcp_docs_handlers, test_mcp_server_build ועוד), על RST אמיתי מהריפו: הטבלה המרכזית נחתכת עם next_offset תקין, Development:: לא נחשב כותרת, כפול→מועמדים, לא-קיים→TOC, slug ⇄ נתיב מלא, ו-public לא ב-_ADMIN_TOOLS.
  • Integration
  • Manual — py_compile נקי; RST lint (docutils) ללא בעיות מבנה.

🧪 בדיקות נדרשות ב‑PR

  • 🔍 Code Quality & Security
  • Unit Tests (3.11)
  • Unit Tests (3.12)

📝 סוג שינוי

  • feat: פיצ'ר חדש (כלי MCP ציבורי)

✅ צ'קליסט

  • הקוד עוקב אחרי הסגנון
  • בדיקות רצות ועוברות
  • תיעוד עודכן — docs/mcp-server.rst, mcp_server/README.md, FEATURE_MCP_CLAUDE_INTEGRATION.md
  • נוסף env var → עודכן docs/environment-variables.rst וגם services/config_inspector_service.py
  • אין סודות/מפתחות בקוד
  • אין מחיקות מסוכנות
  • הודעת הקומיט תואמת Conventional Commits

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

כלי קריאה-בלבד, ציבורי (כל משתמש מאומת, לא admin — התיעוד ציבורי ממילא). נשען על אותו mirror של כלי הריפו הקיימים; אם CodeKeeper לא ב-mirror, מוחזר not_found ברור. אין מיגרציות DB, אין שינוי בכלים קיימים. הכלי נרשם רק כש-repo_backend פעיל.

🔗 קישורים

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

git revert של הקומיט. אין schema/מיגרציה; קבצים חדשים (rst_parser, docs_handlers) עצמאיים — ביטול בטוח ומיידי.


Generated by Claude Code

כלי MCP חדש (public) שמחזיר סקשן בודד מקבצי ה-RST של אתר התיעוד, במקום למשוך
קובץ שלם (environment-variables.rst הוא 77KB / 2242 שורות). מחזיר גם ניווט —
עץ כותרות, breadcrumb, תת-סקשנים ושכנים — כדי שמודל שלא רואה את הקובץ לא יישאר
בלי כלום.

- services/rst_parser.py (מודול עצמאי): זיהוי כותרות דינמי פר-קובץ (underline
  ו-overline), עמידות ל-literal/code blocks (שורת === בתוך Development:: אינה
  כותרת), התאמה סלחנית לעברית, TOC, מועמדים לכפולות, והצעות ל-not-found.
- mcp_server/docs_handlers.py: בונה מעל RepoBackend.get_file הקיים (reuse מלא של
  ref/policy/sync_in_progress), עם slug resolution ו-offset/max_chars לדפדוף.
- server.py: רישום public (opt-in — בלי require_admin, לא ב-_ADMIN_TOOLS),
  תיאור שמסביר מתי להשתמש בו במקום get_repo_file.
- ריפו ברירת מחדל CodeBot דרך MCP_DOCS_REPO (env var חדש) — תועד ב-rst
  וב-config_inspector.

עקרון-על: לעולם לא רק "לא נמצא" — בלי section מחזיר TOC, section חסר מחזיר
TOC+הצעות, כותרת כפולה מחזירה מועמדים עם breadcrumb.

טסטים על RST אמיתי מהריפו (69 ירוקים): טבלה גדולה נחתכת עם offset תקין, literal
block לא נחשב כותרת, כפול→מועמדים, לא-קיים→TOC, slug ⇄ נתיב מלא, ו-public לא
ב-_ADMIN_TOOLS.

הפארסר עצמאי לשימוש חוזר עתידי (docs_search / docs_lookup_config).

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)
./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/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.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/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",
./node_modules/katex/src/fonts/Makefile:139:	rm -rf pfa ff otf ttf woff woff2
./Dockerfile:42:    rm -rf /var/lib/apt/lists/*
./Dockerfile:121:    rm -rf /var/lib/apt/lists/*
./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]
./docs/DOCUMENTATION_GUIDE.md:453:rm -rf _build
./docs/Makefile:24:	rm -rf $(BUILDDIR)
./README.md:842:find . -name "__pycache__" -exec rm -rf {} +

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@amirbiron, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 25 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e6aeede7-d36b-4cbb-b1ec-2bed8e032bc1

📥 Commits

Reviewing files that changed from the base of the PR and between 0c9ef7d and 7ace2cd.

📒 Files selected for processing (4)
  • docs/environment-variables.rst
  • mcp_server/docs_handlers.py
  • services/config_inspector_service.py
  • tests/test_mcp_docs_handlers.py
📝 Walkthrough

Walkthrough

נוסף כלי MCP ציבורי בשם codekeeper_docs_get_section לשליפת סקשנים מקובצי RST. המימוש כולל parser, TOC, ניווט, paging, טיפול בשגיאות, תצורת repo, רישום בשרת ותיעוד.

Changes

כלי תיעוד MCP

Layer / File(s) Summary
Parser והיררכיית RST
services/rst_parser.py, tests/test_rst_parser.py
נוסף parser לזיהוי כותרות, בניית היררכיה, חיפוש סלחני, TOC, גבולות טקסט, ניווט והצעות; נוספו בדיקות לבלוקים, כותרות כפולות ו-include.
Handler לשליפת סקשנים
mcp_server/docs_handlers.py, tests/test_mcp_docs_handlers.py, services/config_inspector_service.py
נוסף handler שמנרמל path ו-repo, קורא RST דרך RepoBackend, ומחזיר TOC או סקשן עם offset, max_chars, ניווט ושגיאות מובנות.
רישום ותיעוד הכלי
mcp_server/server.py, mcp_server/README.md, docs/mcp-server.rst, docs/environment-variables.rst, FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md, tests/test_mcp_server_build.py
הכלי נרשם כ-read-only ללא הגבלת admin, נוספה תצורת MCP_DOCS_REPO, ועודכנו התיעוד והבדיקות. עבודת הקידוד של Claude Code השתלבה כאן באופן מסודר.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant codekeeper_docs_get_section
  participant RepoBackend
  participant services_rst_parser
  Client->>codekeeper_docs_get_section: שליחת path ו-section
  codekeeper_docs_get_section->>RepoBackend: get_file
  RepoBackend-->>codekeeper_docs_get_section: תוכן קובץ RST
  codekeeper_docs_get_section->>services_rst_parser: parse_document
  services_rst_parser-->>codekeeper_docs_get_section: section, TOC וניווט
  codekeeper_docs_get_section-->>Client: תשובת TOC או section
Loading

Possibly related PRs

Poem

כותרת נפתחת, הסקשן נמצא,
breadcrumb מוביל בשביל בבטחה.
TOC ו־paging רוקדים בשורה,
Claude Code תכנת — ממש מלאכה נהדרה.
CodeKeeper forever 💫

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.48% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed הכותרת קצרה, ברורה ומתארת במדויק את הוספת כלי ה-MCP docs_get_section לסקשן יחיד מתוך RST.
Description check ✅ Passed התיאור ממלא כמעט את כל תבנית ה-PR עם What, שינויים, בדיקות, סוג שינוי, צ'קליסט, סיכונים וקישורים.
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 feat/mcp-docs-get-section

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

github-actions Bot commented Jul 26, 2026

Copy link
Copy Markdown

⏱️ Performance report

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

@github-actions

github-actions Bot commented Jul 26, 2026

Copy link
Copy Markdown

📖 Documentation Preview

The documentation has been built successfully!

To view locally:

  1. Download the artifacts
  2. Extract the zip file
  3. Open index.html in your browser

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.94118% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
services/rst_parser.py 93.97% 6 Missing and 4 partials ⚠️
mcp_server/docs_handlers.py 92.68% 3 Missing and 3 partials ⚠️
mcp_server/server.py 71.42% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@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: 1

🤖 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/docs_handlers.py`:
- Around line 29-45: הקשח את זרימת codekeeper_docs_get_section כך ש-repo יאומת
מול MCP_DOCS_REPO או allowlist ייעודי לפני העברתו ל-RepoBackend.get_file. עדכן
את _resolve_docs_path לנרמל נתיבים באמצעות posixpath ולדחות נתיבי traversal או
נתיבים שאינם תחת docs/. ודא שרק נתיב מנורמל המתחיל ב-docs/ מועבר
ל-backend.get_file, כולל עבור קלט המכיל slash.
🪄 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: e718e094-fe01-43e2-8cf0-9f5d4c2ac715

📥 Commits

Reviewing files that changed from the base of the PR and between 8b52548 and 0c9ef7d.

📒 Files selected for processing (11)
  • FEATURE_SUGGESTIONS/FEATURE_MCP_CLAUDE_INTEGRATION.md
  • docs/environment-variables.rst
  • docs/mcp-server.rst
  • mcp_server/README.md
  • mcp_server/docs_handlers.py
  • mcp_server/server.py
  • services/config_inspector_service.py
  • services/rst_parser.py
  • tests/test_mcp_docs_handlers.py
  • tests/test_mcp_server_build.py
  • tests/test_rst_parser.py

Comment thread mcp_server/docs_handlers.py Outdated
@amirbiron

Copy link
Copy Markdown
Owner Author

@claude is planning..

claude and others added 2 commits July 26, 2026 15:46
סבב review על הכלי הציבורי codekeeper_docs_get_section:
- IDOR: repo מפורש מאומת מול allowlist (MCP_DOCS_REPO כ-CSV) לפני קריאה ל-backend.
  בלי זה כל משתמש מאומת יכול לקרוא .rst מכל ריפו ב-mirror (עוקף את ה-admin-gate).
- Path: _resolve_docs_path מנרמל עם posixpath ודוחה traversal, נתיב מוחלט, וכל
  נתיב מחוץ ל-docs/ (כולל קלט עם slash כמו webapp/x) — הגנת שכבה מעל ה-backend.
- תיאור MCP_DOCS_REPO עודכן (rst + config_inspector) כגבול אבטחה (CSV allowlist).

טסטים: repo לא-מותר → repo_not_allowed (backend לא נקרא), נתיב מחוץ ל-docs/
ו-traversal → missing_path. 54 טסטים ירוקים.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WNFuSyshwpRcxozVZEui5K
@amirbiron

Copy link
Copy Markdown
Owner Author

@claude טנקס

@amirbiron
amirbiron merged commit c6b9168 into main Jul 26, 2026
26 checks passed
amirbiron pushed a commit that referenced this pull request Jul 26, 2026
… קונפליקטים לטובת תיקון הבאג של הסקילים)
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