Skip to main content
Glama
gh-search-mcp
by raystyle

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 tree

Why

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, and get_file_contents refuses 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) and httpx.AsyncClient.

Related MCP server: slim-github-mcp

Install

Requires uv.

uv tool install git+https://github.com/raystyle/gh-mcp
gh-mcp --version

Or run it without installing:

uvx --from git+https://github.com/raystyle/gh-mcp gh-mcp --version

The 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

search_repositories

Works (lower GitHub rate limits)

Works

search_code

Refused with an explanatory error

Works

get_file_contents

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

query

string

—

Required, at most 256 characters

sort

string

best

best, stars, forks, help-wanted-issues, updated

order

string

desc

Only used when sort is not best

limit

int

20

1–50

page

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

query

string

—

Required, at most 256 characters

limit

int

20

1–50

page

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:

path points to

With recursive

Result

a file

—

The file's lines, at most 400 per call

a directory

false (default)

The entries directly inside it

a directory, or empty for root

true

The whole subtree, as an indented tree

Parameter

Type

Default

Notes

owner

string

—

Required

repo

string

—

Required

path

string

""

Empty means the repository root

ref

string or null

null

Branch, tag or commit SHA; the default branch when omitted

recursive

bool

false

Show a directory's whole subtree instead of one level

start_line

int

1

First line to return; ignored for directories

end_line

int or null

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 tree

The 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 tools
get_file_contentsA
Read-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_codeA
Read-onlyIdempotent

Search code in public GitHub repositories. Results from private repositories are never returned.

Inputs: query (required), page, limit.

search_repositoriesB
Read-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

    A3.8/5.0

    Scored across 3 tools

    Disambiguation5/5

    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.

    Naming Consistency5/5

    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.

    Tool Count4/5

    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.

    Completeness3/5

    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

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables 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.
      2
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables 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 npm
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Connects 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.
      13
      MIT