lookup_package
Find package metadata by PURL or GitHub URL to access ecosystem data across 40+ registries, including versions, dependencies, and security information.
Instructions
Find packages by PURL (pkg:npm/lodash) or GitHub URL. Use when given a package URL or repo link instead of ecosystem+name.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| purl | No | Package URL, e.g. pkg:npm/lodash, pkg:pypi/requests | |
| ecosystem | No | Package ecosystem | |
| name | No | Package name | |
| repository_url | No | GitHub/GitLab URL to find associated packages |
Implementation Reference
- index.js:47-73 (handler)Core handler function executing the lookup_package tool logic: handles PURL parsing, local DB lookup, fallback to API for package info.
async function lookupPackage(args) { if (args.purl) { const local = getPackageByPurl(args.purl); if (local) return { source: "local", ...local }; const parsed = parsePurl(args.purl); if (parsed) { return getPackage(parsed.ecosystem, parsed.name); } const results = await fetchAPI("/packages/lookup", { purl: args.purl }); return { source: "api", data: results }; } if (args.ecosystem && args.name) { return getPackage(args.ecosystem, args.name); } if (args.repository_url) { const results = await fetchAPI("/packages/lookup", { repository_url: args.repository_url, }); return { source: "api", data: results }; } throw invalidInput("Provide ecosystem+name, purl, or repository_url"); } - lib/tools.js:18-37 (schema)Input schema and metadata definition for the lookup_package tool.
{ name: "lookup_package", description: "Find packages by PURL (pkg:npm/lodash) or GitHub URL. Use when given a package URL or repo link instead of ecosystem+name.", inputSchema: { type: "object", properties: { purl: { type: "string", description: "Package URL, e.g. pkg:npm/lodash, pkg:pypi/requests", }, ecosystem: { type: "string", description: "Package ecosystem" }, name: { type: "string", description: "Package name" }, repository_url: { type: "string", description: "GitHub/GitLab URL to find associated packages", }, }, }, }, - index.js:85-94 (registration)Tool dispatch/registration in the main handleToolCall switch statement, invoking the handler and formatting output.
case "lookup_package": { const result = await lookupPackage(args); if (result.source === "local") { return formatPackage(result); } if (Array.isArray(result.data)) { return result.data.map(formatPackage).join("\n\n---\n\n"); } return formatPackage(result.data); } - index.js:35-45 (helper)Helper function used by lookup_package for fetching package data from local DB or API.
async function getPackage(ecosystem, name) { const local = getPackageFromDb(ecosystem, name); if (local) return { source: "local", ...local }; const registry = ecosystemToRegistry(ecosystem); if (!registry) throw invalidEcosystem(ecosystem); const encodedName = encodeURIComponent(name); const data = await fetchAPI(`/registries/${registry}/packages/${encodedName}`); return { source: "api", data }; }