list-repositories
Retrieve and filter repositories by owner, type, or sort criteria using the GitHub Enterprise MCP Server. Manage access to public, private, or forked repositories efficiently with pagination support.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| isOrg | No | Whether it's an organization (true: organization, false: user) | |
| owner | Yes | User or organization name | |
| page | No | Page number | |
| perPage | No | Items per page | |
| sort | No | Sort criteria | full_name |
| type | No | Repository type filter | all |
Implementation Reference
- server/index.js:115-170 (handler)Main handler function that validates input, determines if organization or user, calls the appropriate RepositoryAPI method, formats repositories using formatRepository helper, and returns a formatted text response or error.}, async ({ owner, isOrg, type, sort, page, perPage }) => { try { // owner 매개변수 검증 if (!owner || typeof owner !== 'string' || owner.trim() === '') { return { content: [ { type: "text", text: "오류: 사용자 또는 조직 이름(owner)은 필수 항목입니다." } ], isError: true }; } let repositories; if (isOrg) { repositories = await context.repository.listOrganizationRepositories(owner, type, sort, page, perPage); } else { repositories = await context.repository.listRepositories(owner, type, sort, page, perPage); } // 저장소가 없는 경우 if (!repositories || repositories.length === 0) { return { content: [ { type: "text", text: `${isOrg ? '조직' : '사용자'} '${owner}'의 저장소를 찾을 수 없습니다.` } ] }; } // 저장소 정보 형식화 const formattedRepos = repositories.map(formatRepository); return { content: [ { type: "text", text: `${isOrg ? '조직' : '사용자'} '${owner}'의 저장소 목록 (${repositories.length}개):\n\n${JSON.stringify(formattedRepos, null, 2)}` } ] }; } catch (error) { console.error('저장소 목록 조회 오류:', error); return { content: [ { type: "text", text: `저장소 목록 조회 중 오류가 발생했습니다: ${error.message}` } ], isError: true }; } });
- server/index.js:109-114 (schema)Zod input schema defining parameters for the list-repositories tool: owner, isOrg, type, sort, page, perPage.owner: z.string().describe("사용자 또는 조직 이름"), isOrg: z.boolean().default(false).describe("조직인지 여부 (true: 조직, false: 사용자)"), type: z.enum(['all', 'owner', 'member', 'public', 'private', 'forks', 'sources']).default('all').describe("저장소 유형 필터"), sort: z.enum(['created', 'updated', 'pushed', 'full_name']).default('full_name').describe("정렬 기준"), page: z.number().default(1).describe("페이지 번호"), perPage: z.number().default(30).describe("페이지당 항목 수")
- server/index.js:108-170 (registration)Registration of the list-repositories tool on the MCP server, including schema and handler function.server.tool("list-repositories", { owner: z.string().describe("사용자 또는 조직 이름"), isOrg: z.boolean().default(false).describe("조직인지 여부 (true: 조직, false: 사용자)"), type: z.enum(['all', 'owner', 'member', 'public', 'private', 'forks', 'sources']).default('all').describe("저장소 유형 필터"), sort: z.enum(['created', 'updated', 'pushed', 'full_name']).default('full_name').describe("정렬 기준"), page: z.number().default(1).describe("페이지 번호"), perPage: z.number().default(30).describe("페이지당 항목 수") }, async ({ owner, isOrg, type, sort, page, perPage }) => { try { // owner 매개변수 검증 if (!owner || typeof owner !== 'string' || owner.trim() === '') { return { content: [ { type: "text", text: "오류: 사용자 또는 조직 이름(owner)은 필수 항목입니다." } ], isError: true }; } let repositories; if (isOrg) { repositories = await context.repository.listOrganizationRepositories(owner, type, sort, page, perPage); } else { repositories = await context.repository.listRepositories(owner, type, sort, page, perPage); } // 저장소가 없는 경우 if (!repositories || repositories.length === 0) { return { content: [ { type: "text", text: `${isOrg ? '조직' : '사용자'} '${owner}'의 저장소를 찾을 수 없습니다.` } ] }; } // 저장소 정보 형식화 const formattedRepos = repositories.map(formatRepository); return { content: [ { type: "text", text: `${isOrg ? '조직' : '사용자'} '${owner}'의 저장소 목록 (${repositories.length}개):\n\n${JSON.stringify(formattedRepos, null, 2)}` } ] }; } catch (error) { console.error('저장소 목록 조회 오류:', error); return { content: [ { type: "text", text: `저장소 목록 조회 중 오류가 발생했습니다: ${error.message}` } ], isError: true }; } });
- server/index.js:12-37 (helper)Helper function to format raw repository data into a user-friendly structure used in the handler response.function formatRepository(repo) { return { id: repo.id, name: repo.name, full_name: repo.full_name, private: repo.private, description: repo.description || '설명 없음', html_url: repo.html_url, created_at: repo.created_at, updated_at: repo.updated_at, pushed_at: repo.pushed_at, language: repo.language, default_branch: repo.default_branch, stargazers_count: repo.stargazers_count, forks_count: repo.forks_count, watchers_count: repo.watchers_count, open_issues_count: repo.open_issues_count, license: repo.license ? repo.license.name : null, owner: { login: repo.owner.login, id: repo.owner.id, avatar_url: repo.owner.avatar_url, html_url: repo.owner.html_url, type: repo.owner.type } };
- api/repos/repository.js:12-20 (helper)RepositoryAPI method to list user repositories via GitHub API /users/{owner}/reposasync listRepositories(owner, type = 'all', sort = 'full_name', page = 1, perPage = 30) { return this.client.get(`users/${owner}/repos`, { params: { type, sort, page, per_page: perPage } });
- api/repos/repository.js:25-33 (helper)RepositoryAPI method to list organization repositories via GitHub API /orgs/{org}/reposasync listOrganizationRepositories(org, type = 'all', sort = 'full_name', page = 1, perPage = 30) { return this.client.get(`orgs/${org}/repos`, { params: { type, sort, page, per_page: perPage } });