1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GitHub MCPサーバーのreadonlyが便利

1
Last updated at Posted at 2026-02-28

Claude CodeなどでGitHub MCPサーバー(リモートサーバー)を利用する際に、各ToolsetのURLとreadonlyを活用すると意図しない書き込み操作を防ぐ仕組みがつくれて便利です。

readonlyのAPI URL

RemoteのGitHub MCPサーバーにはreadonly用のAPI URLが用意されており、MCPの各ツールを読み取りアクセスが可能なツールのみに制限できます。
(URL以外にもX-MCP-Readonlyリクエストヘッダーでも設定できます)

またGitHub MCPはactions, issues, pull_requests, reposなど複数のToolsetごとにAPI URLが用意されており、それぞれのreadonlyリンクも取得できます。

Remote MCP Toolsets

image.png

使うことでの利点

これを活用することで、次のような利点があると考えています。

  • 意図しない操作を防止したい
    • IssueやPRは書き込みアクセスもほしいが、ActionsはCIが落ちているかだけをみたいので書き込みアクセスを付与するのは過剰になる
    • OrganizationやProjectなどを勝手に書き換えられたくない
    • 勝手にDiscussionで返信をさせたくない
  • 許可設定に追加しやすい
    • Toolsetを絞って読み取り専用のMCPを設定しておくことで、承認をせずにAIが自由に呼び出せるようにしやすい
    • (Claude Codeの例: permissions.allow

設定例

以下はClaude Codeでの設定例です。

{
  "mcpServers": {
    "github_readonly": {
      "type": "http",
      "url": "https://api.githubcopilot.com/mcp/readonly",
      "headers": {
        "Authorization": "Bearer <TOKEN>",
        "X-MCP-Toolsets": "actions,dependabot,discussions"
      }
    },
    "github": {
      "type": "http",
      "url": "https://api.githubcopilot.com/mcp/",
      "headers": {
        "Authorization": "Bearer <TOKEN>",
        "X-MCP-Toolsets": "issues,pull_requests,repos"
      }
    }
  }
}

このようにreadonly用とwrite用を分けておくことで、普段はreadonlyで安全に情報取得しつつ、必要なときだけwrite用のツールを使うという運用ができます。

最後に

MCPサーバーをなるべく安全に使う方法を模索中です。
もし、他にも良さそうな方法があればコメントいただけると幸いです。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?