anthropics/claude-code-action@v1 の builtin github tool の有効化の方法と紹介
組織で AI 自動開発の仕組みを作ろうとしており、その中で claude-code-action を使用しています。
組み込み GitHub MCP Server があるよーとドキュメントには書いてあるものの claude_args に --dangerously-skip-permissions を付与しても使えず、有効にする方法がよくわからなかったのでメモ。
Using Custom MCP Configuration
You can add custom MCP (Model Context Protocol) servers to extend Claude's capabilities using the --mcp-config flag in claude_args. These servers merge with the built-in GitHub MCP servers.
結論
allowedTools で明示的に許可しないと入らないものがあるので、使いたいものについて調べて claude_args: --allowedTools に書く。
- name: Run Claude Code Action
uses: anthropics/claude-code-action@v1
with:
claude_args: |
--allowedTools mcp__github_ci__get_ci_status
また mcp__github__* を記載すると、github 公式の mcp-server が有効になる。
- name: Run Claude Code Action
uses: anthropics/claude-code-action@v1
with:
claude_args: |
--allowedTools mcp__github__pull_request_read
理由
claude-code-actionの内部処理で allowedTools に応じて有効にするツールを切り替えているため。
組み込みサーバー一覧
せっかく調べたので記載しておきます。ツール一覧は実装の toolName と description をコピペしただけ。ツール単体で許可したい時は mcp__github_ci__get_ci_status のようにすれば良い。
github-actions-server.ts
mcp__github_ci__* が allowedTools にあると有効になる。
たぶん additional_permissions の記述とトークンに action の read 権限が必要。
- name: Run Claude Code Action
uses: anthropics/claude-code-action@v1
with:
claude_args: |
--allowedTools github_ci__get_ci_status
additional_permissions: |
actions: read
- get_ci_status: Get CI status summary for this PR
- get_workflow_run_details: Get job and step details for a workflow run
- download_job_log: Download job logs to disk
github-comment-server.ts
これは常に有効になる。実装上は !isAgentMode という条件があるものの、現状は常に agent モードになる。
- update_claude_comment: Update the Claude comment with progress and results (automatically handles both issue and PR comments)
github-file-ops-server.ts
actionの呼び出し時に use_commit_signing: true を渡していると有効になるぽい。
use_commit_signing の description 的に署名付きコミットをする時に使うぽい。まあ github actions のランナーに git と gh があるので false で困ることはなさそう。
- commit_files: Commit one or more files to a repository in a single commit (this will commit them atomically in the remote repository)
- delete_files: Delete one or more files from a repository in a single commit
github-inline-comment-server.ts
mcp__github_inline_comment__* が allowedTools にあると有効になる。
- create_inline_comment: Create an inline comment on a specific line or lines in a PR file
組み込みツールとしては最重要。これが無いと PR へインラインコメントをすることが難しい。
ランナー内に gh があるためよしなにやってくれそうだが、gh api ではなく gh graphql を使用する必要があることと、仕様が割と複雑なので gh コマンドでやるのはむずい。とりあえず有効にしておくことをおすすめします。
気になる人は以下の公式ドキュメントを参照。
ちなみに
いつも Claude Code を使っていると忘れがちだが WebSearch ツールはデフォルト無効なので allowedTools に入れておくと良い。
- name: Run Claude Code Action
uses: anthropics/claude-code-action@v1
with:
claude_args: |
--allowedTools WebSearch
ちなみに Claude Code は mcp__{mcpServerName} で指定した mcp サーバーの許可をすることができるが、この実装は mcp__github_comment__ のようになっているので、全ツールを許可している状態だと逆に使えないという問題が起こる。
mcp__github__* があると github 公式の mcp server が有効になるが、github 公式の方は mcp サーバーの起動時に使用可能なツールを制限することができるので、そっちでそもそも使えるツールの制御をして全部許可しとくのが楽。
ちなみに2
冒頭で触れた AI 自動開発の仕組みは、アドベントカレンダーで詳しく記載する予定なので、よければそちらもご覧ください。
追記
投稿後にインラインコメントについて書いている記事があったのに気づいた。もっと早く気づきたかった……。
Discussion