GitHub Code Search MCP Server
Provides tools for searching code across all of GitHub and reading file contents from any repository, with filters for repository, language, filename, path, and line ranges.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
GitHub Code Search MCP Server
基于官方 MCP Python SDK 的 GitHub 代码搜索服务器,可通过任何 MCP 客户端(Claude Code、Claude Desktop 等)搜索全 GitHub 的代码、读取和下载任意仓库文件。
功能
Tool | 说明 |
| 全 GitHub 代码搜索:关键词 + 任意仓库/语言/文件名/路径过滤,返回文件路径和匹配源码片段 |
| 按名称搜索仓库,返回 owner/name、描述、语言、star 数 |
| 获取仓库元信息(默认分支、可见性、star 数等),兼作仓库存在性检查 |
| 获取仓库文件树,支持按子目录、深度和条目数过滤 |
| 读取任意仓库任意文件:支持分支/标签/commit 指定、按行范围读取(任意一行代码) |
| 下载任意仓库文件到本地: |
Related MCP server: github-mcp-tool
快速开始(Docker Compose)
cp .env.example .env
# 编辑 .env,填入你的 GITHUB_TOKEN
make up
# 验证(状态应为 healthy)
docker compose ps构建需要 host 网络(pip 走宿主机代理),而 Compose v5 的 bake 要求显式
--allow=network.host,且无法在 compose 文件中持久化。因此统一用make up构建并启动;等价的手动命令为:docker buildx bake -f docker-compose.yml --allow=network.host docker compose up -d --no-build
其他 Makefile 目标:make down 停止并删除容器,make logs 跟踪日志。
接入 AI 工具
MCP 服务器使用 Streamable HTTP 传输协议。任何支持 MCP 的客户端通过以下地址接入:
http://localhost:8000/mcp示例(Claude Code):
# 全局生效,所有项目可用
claude mcp add --scope user --transport http github-mcp http://localhost:8000/mcp
# 仅当前项目生效
claude mcp add --transport http github-mcp http://localhost:8000/mcp可用工具
工具 | 用途 |
| 全 GitHub 代码搜索, |
| 按名称搜索仓库,用于定位正确的 owner/name(如组织名拼写不确定时纠错) |
| 获取仓库元信息,仓库不存在时给出相似仓库候选 |
| 获取仓库文件树, |
| 读取任意仓库任意文件, |
| 下载文件到 |
环境变量
变量 | 必填 | 说明 |
| 是 | GitHub 访问令牌(只需只读权限),code search API 必须认证 |
| 否 | 监听地址,默认 |
| 否 | 监听端口,默认 |
| 否 | 单次请求最大尝试次数,默认 |
| 否 | API 请求超时秒数,默认 |
| 否 |
|
| 否 | 代理。写在此 |
本地运行(非 Docker)
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
GITHUB_TOKEN=<你的 GitHub token> .venv/bin/python server.py说明
GitHub code search 只索引仓库的默认分支
read_code和download遇到超过 1 MiB 的文件时自动回退到raw.githubusercontent.comdownload按原始字节写入,支持二进制文件403/429 限流按
Retry-After/X-RateLimit-Reset等待,恢复时刻在进程内所有请求间共享compose 配置将容器
/tmp设为 tmpfs,并把/tmp/github-mcp绑定到宿主机同名目录,客户端可直接读取下载结果;若宿主/tmp本身是 tmpfs,下载文件会随宿主重启丢失容器以 root 运行,宿主上下载文件的属主为 root;需要当前用户可写时,可给服务加
user:或预先chown无
GITHUB_TOKEN时search_code返回 401 提示;读取和下载公开仓库不受影响(受未认证限流约束)
This server cannot be deployed
Maintenance
Related MCP Connectors
Access the GitHub API, enabling file operations, repository management, search functionality, and…
GitHub MCP — wraps the GitHub public REST API (no auth required for public endpoints)
Search and fetch AI agent skills, rules files and MCP servers indexed from GitHub.
Search GitHub, npm, PyPI, StackOverflow, ArXiv from one MCP — built for coding agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables GitHub API integration via MCP, allowing search, repository details, file contents, and issue management.811 npmISC
- FlicenseNot gradedqualityDmaintenanceEnables managing GitHub repositories, files, and user information through MCP, with support for creating, updating, and deleting repository contents, as well as fetching user profiles.1-
- AlicenseNot gradedqualityCmaintenanceEnables self-hosted, read-only remote interaction with GitHub repositories, allowing listing repositories, searching code, and inspecting commits, pull requests, issues, and diffs via authenticated MCP clients.204 npmMIT
- FlicenseNot gradedqualityCmaintenanceEnables read-only browsing and querying of GitHub repositories, including listing repos, reading files, fetching READMEs, searching code, and viewing commit history via MCP.-