list_repo_packages
Retrieve and filter packages for a GitHub repository by specifying owner, repo, and package type (e.g., npm, maven). Supports pagination for large results.
Instructions
List packages for a repository
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | Repository owner (username or organization) | |
| package_type | No | The type of package to filter for | |
| page | No | Page number of the results | |
| per_page | No | Results per page (max 100) | |
| repo | Yes | Repository name |
Implementation Reference
- src/operations/packages.ts:143-161 (handler)Main handler function that fetches and parses repository packages from GitHub APIexport async function listRepoPackages( github_pat: string, owner: string, repo: string, options: { package_type?: "npm" | "maven" | "rubygems" | "docker" | "nuget" | "container"; per_page?: number; page?: number; } = {} ): Promise<z.infer<typeof PackageSchema>[]> { const url = new URL(`https://api.github.com/repos/${owner}/${repo}/packages`); if (options.package_type) url.searchParams.append("package_type", options.package_type); if (options.per_page) url.searchParams.append("per_page", options.per_page.toString()); if (options.page) url.searchParams.append("page", options.page.toString()); const response = await githubRequest(github_pat, url.toString()); return z.array(PackageSchema).parse(response); }
- src/operations/packages.ts:57-67 (schema)Zod input schemas: public ListRepoPackagesSchema used for registration, internal _ListRepoPackagesSchema with github_pat for parsingexport const ListRepoPackagesSchema = z.object({ owner: z.string().describe("Repository owner (username or organization)"), repo: z.string().describe("Repository name"), package_type: z.enum(["npm", "maven", "rubygems", "docker", "nuget", "container"]).optional().describe("The type of package to filter for"), per_page: z.number().optional().describe("Results per page (max 100)"), page: z.number().optional().describe("Page number of the results"), }); export const _ListRepoPackagesSchema = ListRepoPackagesSchema.extend({ github_pat: z.string().describe("GitHub Personal Access Token"), });
- src/index.ts:286-289 (registration)Tool registration in the MCP server's listTools response, specifying name, description, and input schemaname: "list_repo_packages", description: "List packages for a repository", inputSchema: zodToJsonSchema(packages.ListRepoPackagesSchema), },
- src/index.ts:749-756 (handler)Dispatch handler in CallToolRequest that parses arguments and calls the packages.listRepoPackages functioncase "list_repo_packages": { const args = packages._ListRepoPackagesSchema.parse(params.arguments); const { github_pat, owner, repo, ...options } = args; const result = await packages.listRepoPackages(github_pat, owner, repo, options); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }