Skip to main content
Glama

GitHub search code

github_search_code
Read-only

Search file contents in a GitHub repository (GitHub code search). Returns matching file paths with text-match fragments around each hit. Searches the repository's default branch only and requires the repository to be indexed by GitHub; when the search is rejected or comes back empty, fall back to github_list_repository_files and github_read_file. 'repo' also accepts the combined 'owner/name' form.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "repo": "<repo>",
      "query": "<query>"
    },
    "name": "github_search_code"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathNoRestrict matches to files under this path prefix (GitHub path: qualifier).
repoYesRepository name. Also accepts the combined 'owner/name' form.
ownerNoRepository owner (organisation or user). May be omitted when the repository name is unambiguous in this organisation, or embedded in 'repo' as 'owner/name'.
queryYesCode search terms (GitHub code-search syntax; bare words match file contents). The repo:/path: qualifiers are added by the tool from the 'repo' and 'path' parameters; any you supply here are stripped.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.9/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only declare readOnlyHint=true, so the description must carry the rest, and it does: default-branch-only scope, the GitHub indexing dependency, the failure mode (rejected/empty), and what the response looks like. It does not mention result caps, truncation, or pagination, which are the main remaining behavioral unknowns for a search endpoint.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three dense sentences, front-loaded with purpose and return shape, then constraints, then fallback routing. The trailing 'owner/name' sentence is redundant with the schema, but otherwise every clause earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description compensates by explaining the return payload, and it covers the indexing prerequisite and branch scope that would otherwise cause silent surprises. Missing only result-volume/pagination expectations for an agent deciding whether one call is enough.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, and the description's only parameter note — that 'repo' accepts 'owner/name' — is a verbatim restatement of the schema, as is the query-qualifier handling. No new meaning is added beyond the structured fields, so the baseline of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Search file contents in a GitHub repository') and even sketches the return shape (matching file paths with text-match fragments). It distinguishes itself from its immediate fallbacks github_list_repository_files and github_read_file, though it does not contrast with content-search siblings such as workspace_search_code or code_context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a clear operational condition for switching tools: if the search is rejected or empty, fall back to github_list_repository_files and github_read_file. It also discloses the prerequisites (default branch only, repo must be indexed). It stops short of saying when to prefer this over workspace_search_code for local code.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.