Skip to main content
Glama

init

Initialize a new package.json file to set up Node.js projects by specifying directory path and optional package scope.

Instructions

Initialize a new package.json

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute path to the directory
scopeNoScope for the package (e.g. @myorg)

Implementation Reference

  • The 'init' tool is registered and implemented directly in src/index.ts. It calls the 'run' helper function with the 'init' command to initialize a package.json file.
    server.tool(
      "init",
      "Initialize a new package.json",
      {
        path: z.string().describe("Absolute path to the directory"),
        scope: z.string().optional().describe("Scope for the package (e.g. @myorg)"),
      },
      async ({ path, scope }) => {
        const args = ["init", "-y"];
        if (scope) args.push("--scope", scope);
        try {
          const { stdout } = await run(args, path);
          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