Claude Code で GitHub公式MCPサーバーを追加する (mcp add時、ツール名が長いとClaude Codeでエラーに)
参考リンク
結論
実は、インストール方法を書くことよりも、以下の注意喚起が目的でこの記事を書いています 笑
-
claude mcp add
で github-mcp-serverをmcpに設定するときには、ツール名を github としてください - 以下のように、ツール名を github-mcp-serverのような長いツール名で登録すると、Claude Codeからgithubのmcpを使おうとしたときに、
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"tools.16.custom.name: String should have at most 64 characters"}}
のエラーになりますclaude mcp add github-mcp-server -e GITHUB_PERSONAL_ACCESS_TOKEN=<<GitHubのPAT>> -s user -- /home/ryuuri/repos/github-mcp-server/cmd/github-mcp-server/github-mcp-server stdio
- (https://github.com/github/github-mcp-server/issues/431 を参照)
- 私は、github-local というツール名にして同じエラーが出ました
前提のインストール(go言語)
GitHub公式のMCPサーバーは、ビルドするのにgo言語が必要です。
go言語がインストールされていない場合は、まずgo言語からインストールします。
https://go.dev/dl/ で、最新のパッケージを確認してください
1.現在(2025/5/31)の最新は、1.24.3 です。
2. 自分のOSにあったパッケージをダウンロードします
私の環境は、Ubuntu 24.04 ですので、以下のコマンドで、go1.24.3.linux-amd64.tar.gz をダウンロードしました。
wgetが入っていない場合は、パッケージマネージャでインストールして置く必要があります
(ubuntu 24.04だと、sudo apt install wget
)
cd
mkdir -p download
cd download/
wget https://go.dev/dl/go1.24.3.linux-amd64.tar.gz
3. ダウンロードしたパッケージを展開します
cd ..
mkdir -p install
cd install/
tar xvzf ../download/go1.24.3.linux-amd64.tar.gz
4. バージョン確認します。
ryuuri@AI-agent-Server:~/install$ ~/install/go/bin/go version
go version go1.24.3 linux/amd64
どうも、GOPATH のデフォルトが
ryuuri@AI-agent-Server:~$ ~/go/bin/go version
warning: both GOPATH and GOROOT are the same directory (/home/ryuuri/go); see https://go.dev/wiki/InstallTroubleshooting
go version go1.24.3 linux/amd64
上記のトラブルシューティングを見ると、インストール場所をどっか別の場所に移動するか、ちゃんとGOPATH設定しろ、と書かれているので、とりあえずインストール場所を移動しました。
GitHub公式のMCPサーバーをビルドする
わざわざ docker 立てるより、goでビルドした方が楽じゃね?という考えで、goでビルドします。
cd
mkdir -p repos
cd repos
git clone https://github.com/github/github-mcp-server
cd github-mcp-server/cmd/github-mcp-server
~/install/go/bin/go build -o github-mcp-server
これで、~/repos/github-mcp-server/cmd/github-mcp-server/github-mcp-server
が作成されます。
Claude Code への登録
登録
これがちょっと、分かりずらかったのですが、claude mcp
のコマンド群で、登録するmcpを管理できます。
claude mcp add github -e GITHUB_PERSONAL_ACCESS_TOKEN=<<GitHubのPAT>> -s user -- /home/ryuuri/repos/github-mcp-server/cmd/github-mcp-server/github-mcp-server stdio``
ここでは、ツール名を github とするようにしてください。ツール名を github-mcp-serverのような長いツール名で登録すると、Claude Codeからgithubのmcpを使おうとしたときに、API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"tools.16.custom.name: String should have at most 64 characters"}}
のエラーになります
(claude mcp add 自体は成功します)
私は、github-local というツール名にして、このエラーが出ました。
確認
ryuuri@AI-agent-Server:~/claude_work$ claude mcp list
github: /home/ryuuri/repos/github-mcp-server/cmd/github-mcp-server/github-mcp-server stdio
Claude Code で使ってみる
claude で Claude Code を起動
claude
プロンプトの窓で、 /mcp を実行
/mcp
以下のように、ステータスが表示されます
> /mcp
⎿ MCP Server Status
~ github: connected
続けて、実際に使ってみます。
githubのmcpを使用して、https://github.com/github/github-mcp-server にアクセスして、LICENSE の中身を表示してください
以下のように、githubのmcpのget_file_contentsを使用して、LICENSE を取ってきて、表示してくれます。
● github:get_file_contents (MCP)(owner: "github", repo: "github-mcp-server", path: "LICENSE")…
⎿ {
"type": "file",
… +9 lines (ctrl+r to expand)
"download_url": "https://raw.githubusercontent.com/github/github-mcp-server/main/LICENSE"
}
● MIT License
Copyright (c) 2025 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Discussion