Skip to main content
Glama

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
NameRequiredDescriptionDefault
queryYesSearch query
limitNoMax results (default 20)

Implementation Reference

  • 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,
          };
        }
      },
    );

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/mikusnuz/npm-mcp'

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