Skip to main content
Glama

list_user_packages

Retrieve and filter packages for a GitHub user by type and visibility to manage dependencies and access control.

Instructions

List packages for a user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesUsername
package_typeNoThe type of package to filter for
visibilityNoThe visibility to filter for
per_pageNoResults per page (max 100)
pageNoPage number of the results

Implementation Reference

  • The core handler function that executes the list_user_packages tool by constructing the GitHub API URL for user packages and fetching/parsing the response.
    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);
    }
  • Input schema definitions for the list_user_packages tool, including the public schema and the internal schema extended with github_pat.
    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"),
    });
    
    export const _ListUserPackagesSchema = ListUserPackagesSchema.extend({
      github_pat: z.string().describe("GitHub Personal Access Token"),
    });
  • src/index.ts:280-284 (registration)
    Tool registration in the MCP server's list of tools, defining name, description, and input schema.
    {
      name: "list_user_packages",
      description: "List packages for a user",
      inputSchema: zodToJsonSchema(packages.ListUserPackagesSchema),
    },
  • Dispatch handler in the main CallToolRequest handler that parses arguments and calls the listUserPackages function.
    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) }],
      };
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MissionSquad/mcp-github'

If you have feedback or need assistance with the MCP directory API, please join our Discord server