search-users
Find GitHub users by search query with options to sort by followers, repositories, or join date, and paginate results for efficient user discovery.
Instructions
Search for users on GitHub
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| order | No | ||
| page | No | ||
| per_page | No | ||
| q | Yes | ||
| sort | No |
Implementation Reference
- src/tools/search.ts:106-133 (handler)The core handler function that executes the search-users tool. It validates input using SearchUsersSchema, calls the GitHub search.users API via Octokit, formats the results, and handles errors with tryCatchAsync.export async function searchUsers(args: unknown): Promise<any> { const { q, sort, order, page, per_page } = SearchUsersSchema.parse(args); const github = getGitHubApi(); return tryCatchAsync(async () => { const { data } = await github.getOctokit().search.users({ q, sort: sort as any, order, page, per_page, }); return { total_count: data.total_count, incomplete_results: data.incomplete_results, items: data.items.map((user) => ({ login: user.login, id: user.id, avatar_url: user.avatar_url, html_url: user.html_url, type: user.type, site_admin: user.site_admin, score: user.score, })), }; }, 'Failed to search users'); }
- src/utils/validation.ts:212-218 (schema)Zod schema used for runtime input validation of the search-users tool parameters.export const SearchUsersSchema = z.object({ q: z.string().min(1, 'Search query is required'), sort: z.enum(['followers', 'repositories', 'joined']).optional(), order: z.enum(['asc', 'desc']).optional(), page: z.number().min(1).optional(), per_page: z.number().min(1).max(100).optional(), });
- src/server.ts:1094-1124 (registration)Tool registration in the MCP server's listTools handler, defining the tool's metadata and input schema for MCP clients.{ name: 'search-users', description: 'Search for users on GitHub', inputSchema: { type: 'object', properties: { q: { type: 'string', }, order: { type: 'string', enum: ['asc', 'desc'], }, page: { type: 'number', minimum: 1, }, per_page: { type: 'number', minimum: 1, maximum: 100, }, sort: { type: 'string', enum: ['followers', 'repositories', 'joined'], }, }, required: ['q'], additionalProperties: false, }, },
- src/server.ts:1261-1263 (registration)Dispatch case in the callToolRequest handler that routes execution to the searchUsers function.case 'search-users': result = await searchUsers(parsedArgs); break;