search
Search the npm registry for packages using queries to find relevant dependencies for Node.js projects.
Instructions
Search npm registry for packages
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query | |
| limit | No | Max results (default 20) |
Implementation Reference
- src/index.ts:133-153 (handler)The implementation of the 'search' tool, which runs 'npm search' with the provided query and optional limit.
server.tool( "search", "Search npm registry for packages", { query: z.string().describe("Search query"), limit: z.number().optional().describe("Max results (default 20)"), }, async ({ query, limit }) => { const args = ["search", query, "--json"]; if (limit) args.push("--limit", String(limit)); 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, }; } }, );