Skip to main content
Glama

search_code

Search for code within GitHub repositories using specific queries, filters, and pagination for precise results.

Instructions

Search for code across GitHub repositories

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
orderNo
pageNo
per_pageNo
qYes

Implementation Reference

  • The main handler function for the 'search_code' tool, which calls the GitHub search code API using utility functions.
    export async function searchCode(params: z.infer<typeof SearchCodeSchema>) { return githubRequest(buildUrl("https://api.github.com/search/code", params)); }
  • Input schema definition (SearchOptions), which is aliased as SearchCodeSchema for the tool.
    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 the SearchOptions schema used in tool registration and validation.
    export const SearchCodeSchema = SearchOptions;
  • index.ts:138-142 (registration)
    Registration of the 'search_code' tool in the MCP server's tool list.
    { name: "search_code", description: "Search for code across GitHub repositories", inputSchema: zodToJsonSchema(search.SearchCodeSchema), },
  • Dispatch handler in the main CallToolRequestHandler that 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