Skip to main content
Glama

search_code

Search for code across GitHub repositories to find specific functions, patterns, or implementations within projects.

Instructions

Search for code across GitHub repositories

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYes
orderNo
pageNo
per_pageNo

Implementation Reference

  • The core handler function that executes the GitHub API search/code endpoint using the provided parameters.
    export async function searchCode(github_pat: string, params: z.infer<typeof SearchCodeSchema>) { return githubRequest(github_pat, buildUrl("https://api.github.com/search/code", params)); }
  • Zod schema definitions for validating input parameters of the search_code tool. SearchCodeSchema aliases SearchOptions, and _SearchCodeSchema adds github_pat for internal use.
    export const SearchCodeSchema = SearchOptions; export const _SearchCodeSchema = SearchCodeSchema.extend({ github_pat: z.string().describe("GitHub Personal Access Token"), });
  • src/index.ts:144-147 (registration)
    Registration of the search_code tool in the listTools handler, including name, description, and input schema.
    name: "search_code", description: "Search for code across GitHub repositories", inputSchema: zodToJsonSchema(search.SearchCodeSchema), },
  • src/index.ts:455-462 (registration)
    Dispatch case in the callToolRequest handler that parses arguments and invokes the searchCode handler function.
    case "search_code": { const argsWithPat = search._SearchCodeSchema.parse(params.arguments); const { github_pat, ...args } = argsWithPat; const results = await search.searchCode(github_pat, args); return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }], }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MissionSquad/mcp-github'

If you have feedback or need assistance with the MCP directory API, please join our Discord server