Skip to main content
Glama
Ninh-Duong

MCP Branch Render Document

by Ninh-Duong

自動PRブランチコンテキストレンダラー(Branch Render Context MCP)

Node.js TypeScript MCP Protocol

Branch Render Context は、ベースブランチまたはチェックアウトブランチを基準とした完全なGitプルリクエスト/ターゲットブランチのコンテキストを自動的に解析・レンダリングするために設計された、専門的なModel Context Protocol(MCP)サーバー兼CLIツールです。ブランチ切り替えゼロ、作業ツリーの分離、自動 .gitignore 管理、柔軟なストレージクリーンアップオプションを備え、キャッシュされた増分MarkdownおよびJSONドキュメントをAIエージェントに直接配信します。


🎯 主な特長とアーキテクチャ

  1. ブランチ切り替えなしのターゲットブランチ解決:

    • 現在の作業ツリーが maindevelop にあり、feature/user-auth のようなターゲットブランチを指定すると、ツールは自動的に以下を決定します:

      • baseBranch: main(現在のチェックアウトまたは設定済みデフォルトから)

      • targetBranch: feature/user-auth

      • 比較: main..feature/user-auth

  2. 作業ツリーへの影響ゼロ:

    • 開発者の作業ツリーは完全にそのまま維持されます。git checkoutgit switch などのコマンドは決して実行されません。

  3. 独立したコミット&参照解決:

    • ターゲットブランチのコミットは、現在のHEADに依存せず、ローカル参照またはリモート追跡参照(origin/<branch>)から直接解決されます。

  4. クリーンな作業ツリー分離:

    • 現在のチェックアウトブランチにおける未コミットのダーティな変更が、ターゲットブランチのレンダリング済みPRコンテキストを汚染することはありません。

  5. Gitライクな階層ストレージと自動 .gitignore:

    • ドキュメントを構造化パスに永続化: .branch-render-context/repositories/<repo-id>/branches/<branch-path>/document.json

    • 他のユーザールールを変更することなく、.branch-render-context/.gitignore に自動的かつ冪等に追加します。

  6. 組み込みのシークレット編集とトークン最適化:

    • 認証情報、.env ファイル、.pem 証明書、APIトークンを検出してマスクします。

    • LLMコンテキストウィンドウ向けに最適化された、コンパクトでトークン効率の高いMarkdownサマリーを生成します。

  7. きめ細かなクリーンアップと並行処理ロック:

    • 安全なマルチプロセスロック(.storage.lock.branch.lock)。

    • 3つの異なるクリーンアップスコープをサポート: 単一ブランチ、リポジトリ全体、ストレージ完全消去。


Related MCP server: organisation.md

🛠️ CLIガイド

1. ターゲットブランチコンテキストのレンダリング/更新

# Analyze target branch relative to the currently checked-out base branch
npm run branch-render:refresh -- --branch feature/user-auth

# Specify explicit base branch and force a full rebuild
npm run branch-render:refresh -- --branch feature/user-auth --base develop --force

出力例:

=================================================================
Target branch:   feature/user-auth
Checkout branch: main
Base branch:     main
Comparison:      main..feature/user-auth
Target commit:   8f3b2a1c
Base commit:     1e4d9c7b
Strategy:        full
─────────────────────────────────────────────────────────────────
Metrics:
- Commits:        3
- Changed files:  4
- Insertions:     +142
- Deletions:      -18
- Worktree dirty: ignored (clean isolation)
─────────────────────────────────────────────────────────────────
Document path:
.branch-render-context/repositories/r_9a2b4c1d/branches/feature/user-auth/document.json
=================================================================

2. 対話型ターミナルウィザード

npm run branch-render:start

ウィザードは現在のチェックアウトブランチを検出し、既存のレンダリング済みコンテキストを表示し、レンダリングまたはクリアのオプションを案内します。

3. 鮮度ステータスの確認

npm run branch-render:status -- --branch feature/user-auth

4. 登録済みコンテキストの一覧表示

npm run branch-render:list

5. コンテキスト&ストレージのクリーンアップ

# Scope 1: Clear context for a specific branch
npm run branch-render:clear -- --branch feature/user-auth

# Scope 2: Clear all branch contexts in the current repository
npm run branch-render:clear -- --all

# Scope 3: Completely clear ENTIRE storage (all repositories, catalog, config, indexes)
npm run branch-render:clear -- --all-storage --yes

🤖 MCPサーバー統合

AIエディタまたはクライアント(Claude Desktop、Cursor、Cline、Roo Code)でMCPサーバーを設定します:

{
  "mcpServers": {
    "branch-render-context": {
      "command": "node",
      "args": ["<path-to-mcp-branch-render-document>/dist/index.js"]
    }
  }
}

利用可能なMCPツール

ツール名

パラメータ

説明

branch_context_start

repo_path?, target_branch?, base_ref?, storage_path?

セッションを初期化し、リポジトリを検出し、ブランチ状態を検査します。

branch_context_list

repo_path?, storage_path?

登録済みの全リポジトリとキャッシュされたブランチドキュメントを一覧表示します。

branch_context_status

repo_path?, branch?, base_ref?, storage_path?

レンダリングせずにターゲット参照とベース参照間のGit鮮度を評価します。

branch_context_get

repo_path?, branch?, freshness_mode?, storage_path?

指定された鮮度ポリシー(requiredautocheck_onlyallow_stale)を使用して document.json を取得します。

branch_context_refresh

repo_path?, branch?, base_ref?, force?, storage_path?

決定的な増分更新または完全再構築をトリガーします。

branch_context_clear

repo_path?, branch?, all?, storage_path?

リポジトリ内の単一ブランチまたは全ブランチのレンダリング済みコンテキストをクリアします。

branch_context_clear_storage

confirm: boolean, storage_path?

全リポジトリにわたるストレージ全体を消去します(confirm: true が必要)。


📄 レンダリング済みドキュメント構造

各レンダリング済みブランチドキュメントには、構造化JSONオブジェクト(document.json)とAIフレンドリーなMarkdown表現(document.md)の両方が含まれます:

  • リポジトリ&ブランチメタデータ: 一意のID、リモートURL、比較参照、コミットハッシュ。

  • コミット履歴: 作成者、日付、件名、コミット本文(シークレットフィルタリング付き)を含む全コミットのリスト。

  • ファイル変更&差分統計: 変更ステータス(addedmodifieddeletedrenamed)、パッチチャンク、挿入行数、削除行数を含む詳細なファイルリスト。

  • 鮮度&チェックポイント状態: 超高速な増分再評価に使用される保存済みコミットSHAとタイムスタンプ。


🧪 開発とテスト

# Run Vitest test suite
npm test

# Build TypeScript output
npm run build

📜 ライセンス

MITライセンス。AIエージェントワークフローと自動コーディングアシスタント向けに設計されています。

F
license - not found
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • Give your AI agent a persistent map of your project's structure, dependencies, and bugs.

  • Git-backed platform for skills, tools, and context for AI agents

  • Provide your AI coding tools with token-efficient access to up-to-date technical documentation for…

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Ninh-Duong/mcp-branch-render-document'

If you have feedback or need assistance with the MCP directory API, please join our Discord server