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
| Name | Required | Description | Default |
|---|---|---|---|
| q | Yes | ||
| order | No | ||
| page | No | ||
| per_page | No |
Implementation Reference
- operations/search.ts:35-37 (handler)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)); }
- operations/search.ts:4-9 (schema)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(), });
- operations/search.ts:31-31 (schema)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) }], }; }