list_user_packages
Retrieve and filter packages by type, visibility, and pagination for a specified user on the MCP GitHub server to manage and track software dependencies effectively.
Instructions
List packages for a user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| 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) | |
| username | Yes | Username | |
| visibility | No | The visibility to filter for |
Implementation Reference
- src/operations/packages.ts:122-141 (handler)Core handler function that executes the logic to list GitHub packages for a user by constructing the API URL, making the request, and parsing the response with Zod.export async function listUserPackages( github_pat: string, username: 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/users/${username}/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:45-51 (schema)Zod schema defining the input parameters for the list_user_packages tool, used in tool registration.export const ListUserPackagesSchema = z.object({ username: z.string().describe("Username"), package_type: z.enum(["npm", "maven", "rubygems", "docker", "nuget", "container"]).optional().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)"), page: z.number().optional().describe("Page number of the results"), });
- src/index.ts:280-284 (registration)Tool registration in the MCP server, defining name, description, and input schema.{ name: "list_user_packages", description: "List packages for a user", inputSchema: zodToJsonSchema(packages.ListUserPackagesSchema), },
- src/index.ts:740-747 (handler)Dispatch handler in the main switch case that parses arguments, calls the core handler, and formats the response.case "list_user_packages": { const args = packages._ListUserPackagesSchema.parse(params.arguments); const { github_pat, username, ...options } = args; const result = await packages.listUserPackages(github_pat, username, options); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }