get_user_package
Retrieve a specific package for a user by providing the username, package type (e.g., npm, maven), and package name. Ideal for accessing user-specific package details on the MCP server.
Instructions
Get a package for a user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| package_name | Yes | The name of the package | |
| package_type | Yes | The type of package | |
| username | Yes | Username |
Implementation Reference
- src/operations/packages.ts:176-187 (handler)The core handler function that executes the tool logic by making a GitHub API request to retrieve a specific user package and parsing the response.export async function getUserPackage( github_pat: string, username: string, package_type: "npm" | "maven" | "rubygems" | "docker" | "nuget" | "container", package_name: string ): Promise<z.infer<typeof PackageSchema>> { const response = await githubRequest( github_pat, `https://api.github.com/users/${username}/packages/${package_type}/${package_name}` ); return PackageSchema.parse(response); }
- src/operations/packages.ts:79-83 (schema)Input schema (GetUserPackageSchema) used for validating tool arguments and referenced in tool registration.export const GetUserPackageSchema = z.object({ username: z.string().describe("Username"), package_type: z.enum(["npm", "maven", "rubygems", "docker", "nuget", "container"]).describe("The type of package"), package_name: z.string().describe("The name of the package"), });
- src/index.ts:296-299 (registration)Tool registration entry in the listTools handler, defining the tool name, description, and input schema.name: "get_user_package", description: "Get a package for a user", inputSchema: zodToJsonSchema(packages.GetUserPackageSchema), },
- src/index.ts:767-774 (handler)Dispatch handler in the main CallToolRequest switch case that validates arguments with _GetUserPackageSchema and invokes the getUserPackage function.case "get_user_package": { const args = packages._GetUserPackageSchema.parse(params.arguments); const { github_pat, username, package_type, package_name } = args; const result = await packages.getUserPackage(github_pat, username, package_type, package_name); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }
- src/operations/packages.ts:17-30 (schema)Output schema (PackageSchema) used to parse the GitHub API response in the handler.export const PackageSchema = z.object({ id: z.number(), name: z.string(), package_type: z.string(), owner: GitHubIssueAssigneeSchema.optional(), version_count: z.number().optional(), visibility: z.string(), url: z.string(), created_at: z.string(), updated_at: z.string(), html_url: z.string(), versions_url: z.string().optional(), repository_url: z.string().optional(), });