Skip to main content
Glama

search_code

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

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 for code using the provided parameters.
    export async function searchCode(params: z.infer<typeof SearchCodeSchema>) { return githubRequest(buildUrl("https://api.github.com/search/code", params)); }
  • Zod schema defining the input parameters for the search_code tool (SearchOptions, exported and aliased as SearchCodeSchema).
    export const SearchOptions = z.object({ q: z.string(), order: z.enum(["asc", "desc"]).optional(), page: z.number().min(1).optional(), per_page: z.number().min(1).max(100).optional(), });
  • Alias for SearchOptions schema used in tool registration and parsing.
    export const SearchCodeSchema = SearchOptions;
  • index.ts:138-142 (registration)
    Tool declaration in the ListToolsResponse, registering the search_code tool with name, description, and input schema.
    { name: "search_code", description: "Search for code across GitHub repositories", inputSchema: zodToJsonSchema(search.SearchCodeSchema), },
  • index.ts:284-290 (registration)
    Dispatch handler in CallToolRequestHandler that parses arguments using SearchCodeSchema and invokes the searchCode function.
    case "search_code": { const args = search.SearchCodeSchema.parse(request.params.arguments); const results = await search.searchCode(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/PhialsBasement/mcp-github-server-plus'

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