list_org_packages
Retrieve and filter packages by type and visibility for a specific GitHub organization using mcp-github, with options for pagination and organization name input.
Instructions
List packages for an organization
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| org | Yes | Organization name | |
| package_type | Yes | The type of package to filter for | |
| page | No | Page number of the results | |
| per_page | No | Results per page (max 100, default 30) | |
| visibility | No | The visibility to filter for |
Implementation Reference
- src/operations/packages.ts:101-120 (handler)The core handler function that implements the list_org_packages tool by constructing the GitHub API URL, making the request, and parsing the response into PackageSchema array.export async function listOrgPackages( github_pat: string, org: string, options: { package_type: "npm" | "maven" | "rubygems" | "docker" | "nuget" | "container"; visibility?: "public" | "private" | "internal"; per_page?: number; page?: number; } = { package_type: "npm" } ): Promise<z.infer<typeof PackageSchema>[]> { const url = new URL(`https://api.github.com/orgs/${org}/packages`); if (options.package_type) url.searchParams.append("package_type", options.package_type); if (options.visibility) url.searchParams.append("visibility", options.visibility); 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:33-39 (schema)Input schema definition for the list_org_packages tool, used in tool registration.export const ListOrgPackagesSchema = z.object({ org: z.string().describe("Organization name"), package_type: z.enum(["npm", "maven", "rubygems", "docker", "nuget", "container"]).describe("The type of package to filter for"), visibility: z.enum(["public", "private", "internal"]).optional().describe("The visibility to filter for"), per_page: z.number().optional().describe("Results per page (max 100, default 30)"), page: z.number().optional().describe("Page number of the results"), });
- src/operations/packages.ts:41-43 (schema)Extended input schema including github_pat, used for parsing arguments in the dispatch handler.export const _ListOrgPackagesSchema = ListOrgPackagesSchema.extend({ github_pat: z.string().describe("GitHub Personal Access Token"), });
- src/index.ts:276-279 (registration)Tool registration in the ListTools response, defining name, description, and input schema.name: "list_org_packages", description: "List packages for an organization", inputSchema: zodToJsonSchema(packages.ListOrgPackagesSchema), },
- src/index.ts:731-738 (handler)Top-level dispatch handler in index.ts that parses arguments and delegates to the packages.listOrgPackages implementation.case "list_org_packages": { const args = packages._ListOrgPackagesSchema.parse(params.arguments); const { github_pat, org, ...options } = args; const result = await packages.listOrgPackages(github_pat, org, options); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }