get_dependencies
Retrieve npm dependencies for Reacticx components to plan installations and manage project requirements.
Instructions
Get the required npm dependencies for one or more Reacticx components. Useful for planning installations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| components | Yes | Array of component slugs to check dependencies for |
Implementation Reference
- src/index.ts:215-269 (handler)Main handler implementation for get_dependencies tool. Takes an array of component slugs, looks up each component using getComponentBySlug, collects all dependencies into a Set to avoid duplicates, and returns formatted output with per-component dependencies and a combined npm install command.server.tool( "get_dependencies", "Get the required npm dependencies for one or more Reacticx components. Useful for planning installations.", { components: z .array(z.string()) .describe( "Array of component slugs to check dependencies for" ), }, async ({ components }) => { const allDeps = new Set<string>(); const notFound: string[] = []; const found: { name: string; slug: string; deps: string[] }[] = []; for (const slug of components) { const info = getComponentBySlug(slug.toLowerCase().trim()); if (info) { found.push({ name: info.name, slug: info.slug, deps: info.dependencies, }); info.dependencies.forEach((d) => allDeps.add(d)); } else { notFound.push(slug); } } let output = `# Dependencies for ${found.length} component(s)\n\n`; if (found.length > 0) { for (const comp of found) { output += `- **${comp.name}** (\`${comp.slug}\`): ${comp.deps.length > 0 ? comp.deps.join(", ") : "no extra dependencies"}\n`; } output += `\n## Combined Install Command\n\n`; if (allDeps.size > 0) { output += `\`\`\`bash\nnpm install ${[...allDeps].join(" ")}\n\`\`\`\n`; } else { output += `No additional dependencies required.\n`; } output += `\n## Add Components\n\n\`\`\`bash\n${found.map((c) => `bunx --bun reacticx add ${c.slug}`).join("\n")}\n\`\`\`\n`; } if (notFound.length > 0) { output += `\n## Not Found\n\n${notFound.map((s) => `- "${s}"`).join("\n")}\n`; } return { content: [{ type: "text" as const, text: output }], }; } );
- src/index.ts:219-223 (schema)Input schema definition using zod for the get_dependencies tool. Validates that the input is an array of strings representing component slugs.components: z .array(z.string()) .describe( "Array of component slugs to check dependencies for" ),
- src/index.ts:215-224 (registration)Tool registration with the MCP server. Registers the get_dependencies tool with its name, description, and input schema.server.tool( "get_dependencies", "Get the required npm dependencies for one or more Reacticx components. Useful for planning installations.", { components: z .array(z.string()) .describe( "Array of component slugs to check dependencies for" ), },
- src/registry.ts:790-796 (helper)Helper function getComponentBySlug used by the get_dependencies handler to look up component information from the registry by slug.export function getComponentBySlug( slug: string ): ComponentInfo | undefined { return COMPONENT_REGISTRY.find( (c) => c.slug.toLowerCase() === slug.toLowerCase() ); }
- src/registry.ts:1-7 (schema)ComponentInfo interface definition that includes the dependencies array used by the get_dependencies tool to retrieve component dependency information.export interface ComponentInfo { name: string; slug: string; category: string; description: string; dependencies: string[]; }