view
Retrieve npm package details like versions and distribution tags directly from the registry to inspect dependencies and metadata.
Instructions
View package information from the registry
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| package | Yes | Package name (e.g. react, @scope/pkg) | |
| field | No | Specific field to view (e.g. versions, dist-tags) |
Implementation Reference
- src/index.ts:109-130 (handler)The implementation of the 'view' tool handler, which executes 'npm view' using the provided package name and optional field.
server.tool( "view", "View package information from the registry", { package: z.string().describe("Package name (e.g. react, @scope/pkg)"), field: z.string().optional().describe("Specific field to view (e.g. versions, dist-tags)"), }, async ({ package: pkg, field }) => { const args = ["view", pkg]; if (field) args.push(field); args.push("--json"); try { const { stdout } = await run(args); return { content: [{ type: "text", text: stdout }] }; } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.stderr || e.message}` }], isError: true, }; } }, );