gh-search-mcp
This is a read-only MCP server for finding and reading public GitHub repositories and code.
Search public repositories by keyword and GitHub qualifiers, with sort/order, pagination, and 1–50 results per call.
Search code in public repositories (requires a GitHub token), with pagination and up to two matching text fragments per result.
Read a text file from a public repository, optionally at a branch/tag/SHA and with a line range (max 400 lines per call).
List a directory one level, or show a recursive repository tree (max 400 entries).
All tools are read-only; private code results are filtered, non-public repos are refused, and rate-limit errors say how long to wait.
Provides tools to search public GitHub repositories and code, and to read file contents, directory listings, or repository trees in public repositories.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@gh-search-mcp Find public Python MCP servers with 100+ stars and show me the top README."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
gh-mcp
A read-only MCP server, over stdio, that lets an agent search public GitHub repositories and code, and read what it finds. It exposes three read-only tools and nothing that can write.
search_repositories keyword + qualifiers → public repositories
search_code keyword + qualifiers → code in public repositories
get_file_contents owner/repo + path → a file, a directory listing, or a repository treeWhy
GitHub's own remote MCP server is the right tool if you want all of GitHub in your agent. If you only want "find public repos and code, then read them", it brings 40+ tools (creating repositories, pushing files, merging pull requests) into every conversation. This server is the narrow version:
Three read-only tools. All are annotated
readOnlyHint; there is no code path that writes to GitHub.Public only. Repository queries always carry
is:public, so GitHub filters them server-side. Code results that come from private repositories are dropped before the model sees them, andget_file_contentsrefuses any repository that is not public before it asks for content.Small output. Results are rendered as compact markdown instead of raw API JSON.
Async, standard stack. Built on the official Python SDK (
mcp) andhttpx.AsyncClient.
Related MCP server: slim-github-mcp
Install
Requires uv.
uv tool install git+https://github.com/raystyle/gh-mcp
gh-mcp --versionOr run it without installing:
uvx --from git+https://github.com/raystyle/gh-mcp gh-mcp --versionThe server itself takes no arguments and speaks MCP on stdin/stdout.
Token
The token is read from the environment when the server starts: GITHUB_PAT, or GITHUB_TOKEN as a fallback.
Tool | Without a token | With a token |
| Works (lower GitHub rate limits) | Works |
| Refused with an explanatory error | Works |
| Works (lower GitHub rate limits) | Works |
GitHub requires authentication for code search, which is why that tool cannot run anonymously. The token decides what is reachable: a token limited to public repositories never sees private matches, while a broader token's private matches are removed by this server.
Use with an MCP client
Claude Code:
claude mcp add-json gh-search '{"command":"gh-mcp","env":{"GITHUB_PAT":"<your token>"}}'Any client that takes a stdio server command:
{
"mcpServers": {
"gh-search": {
"command": "gh-mcp",
"env": { "GITHUB_PAT": "<your token>" }
}
}
}If the token is already in the server process's environment, the env block can be omitted.
Tools
search_repositories
Search public repositories. query takes GitHub's repository search syntax, for example mcp server stars:>100 language:python, topic:openwrt, or plain words.
Parameter | Type | Default | Notes |
| string | — | Required, at most 256 characters |
| string |
|
|
| string |
| Only used when |
| int | 20 | 1–50 |
| int | 1 | 1-based |
search_code
Search code in public repositories. query takes GitHub's code search syntax, for example O_NOFOLLOW language:python or create_connected_server_and_client_remote_streams repo:modelcontextprotocol/python-sdk. Up to two matching text fragments are returned per result.
Parameter | Type | Default | Notes |
| string | — | Required, at most 256 characters |
| int | 20 | 1–50 |
| int | 1 | 1-based |
The search tools return markdown: a header with the result window and total, one entry per result, and a note when more pages exist or when private matches were hidden.
get_file_contents
Read a text file, list a directory, or show a repository tree in a public repository. What you get depends on path:
| With | Result |
a file | — | The file's lines, at most 400 per call |
a directory |
| The entries directly inside it |
a directory, or empty for root |
| The whole subtree, as an indented tree |
Parameter | Type | Default | Notes |
| string | — | Required |
| string | — | Required |
| string |
| Empty means the repository root |
| string or null |
| Branch, tag or commit SHA; the default branch when omitted |
| bool |
| Show a directory's whole subtree instead of one level |
| int | 1 | First line to return; ignored for directories |
| int or null |
| Last line to return; ignored for directories |
Large files come back in windows: the header says which lines are shown and which start_line continues. Binary files and files over 1 MB (GitHub's limit for this endpoint) are refused with a message that says so. A recursive tree shows at most 400 entries; narrow it with path.
Limits
GitHub rate limits search separately from the rest of the API: 30 requests per minute for repository search and 10 per minute for code search with a token, and 10 per minute without one. The file and tree endpoints use GitHub's general limit instead: 5,000 requests per hour with a token and 60 per hour without one. When a limit is hit, the tool returns an error that says how long to wait. Each search call is one GitHub request; each get_file_contents call is two (a visibility check, then the content), because the content endpoint does not say whether a repository is private.
Development
uv sync --group dev
uv run pytest
uv run python -m gh_mcp # run the server from the working treeThe tests use an in-memory fake of the GitHub API and need no network or token. src/gh_mcp/github.py is the API client, render.py turns results into markdown, and server.py wires them to MCP.
License
MIT
Available Tools
3 toolsget_file_contentsARead-onlyIdempotent
Read a text file, list a directory, or show a repository's tree, in a public GitHub repository. Use it after a search to open what you found.
Inputs: repo (required), owner (required), ref, path, +3 more.
search_codeARead-onlyIdempotent
Search code in public GitHub repositories. Results from private repositories are never returned.
Inputs: query (required), page, limit.
search_repositoriesBRead-onlyIdempotent
Search public GitHub repositories by keyword and qualifiers. Results are always restricted to public repositories.
Inputs: query (required), page, sort, limit, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
The three tools target clearly distinct operations: repository search, code search, and file/directory retrieval. There is no realistic way to confuse search_repositories with search_code, and get_file_contents is unambiguously the read/open step.
All names follow a consistent snake_case verb_noun pattern (search_repositories, search_code, get_file_contents). Verb choice is semantically accurate and uniform across the set.
Three tools is lean but each has a clear role in a search-then-read workflow. It sits at the thin end of the appropriate range, with no redundant tools.
The search-and-read loop is closed, but GitHub search spans issues, commits, users, and topics — none of which are exposed — and there is no way to fetch repository-level metadata (description, stars, default branch). Agents can work around this only by inferring from raw file listings.
Maintenance
Related MCP Connectors
Access the GitHub API, enabling file operations, repository management, search functionality, and…
Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository.
Operate GitHub from your AI assistant: repos, PRs, issues, Actions. Previews and read-only mode.
GitHub, npm, PyPI, Stack Overflow, arXiv and OpenAlex paper search as agent tools.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides read-only access to company GitHub repositories, enabling code search, file retrieval, documentation search, and repo browsing via natural language.-
- AlicenseNot gradedqualityDmaintenanceEnables local models to query GitHub read-only through nine compact tools that return small, capped results, such as repositories, issues, pull requests, commits, code search, and file contents.2MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to search repositories, inspect files and code, list issues and commits, check releases, and look up GitHub user profiles through the GitHub public REST API without authentication.162 npmMIT
- AlicenseAqualityDmaintenanceConnects LLMs and AI agents directly to GitHub repositories, enabling repository inspection, file and tree exploration, code search, commit history, issues, pull requests, and releases for both public and private repos.13MIT