MCPcopy Create free account
hub / github.com/codeaashu/claude-code / detectMcpb

Function detectMcpb

src/commands/plugin/ManagePlugins.tsx:827–855  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

825 return;
826 }
827 async function detectMcpb() {
828 // Check plugin manifest first
829 const mcpServersSpec = selectedPlugin!.plugin.manifest.mcpServers;
830 let hasMcpb = false;
831 if (mcpServersSpec) {
832 hasMcpb = typeof mcpServersSpec === 'string' && isMcpbSource(mcpServersSpec) || Array.isArray(mcpServersSpec) && mcpServersSpec.some(s_2 => typeof s_2 === 'string' && isMcpbSource(s_2));
833 }
834
835 // If not in manifest, read raw marketplace.json directly (bypassing schema validation)
836 // This works even with old cached marketplaces from before MCPB support
837 if (!hasMcpb) {
838 try {
839 const marketplaceDir = path.join(selectedPlugin!.plugin.path, '..');
840 const marketplaceJsonPath = path.join(marketplaceDir, '.claude-plugin', 'marketplace.json');
841 const content = await fs.readFile(marketplaceJsonPath, 'utf-8');
842 const marketplace_1 = jsonParse(content);
843 const entry_0 = marketplace_1.plugins?.find((p: {
844 name: string;
845 }) => p.name === selectedPlugin!.plugin.name);
846 if (entry_0?.mcpServers) {
847 const spec = entry_0.mcpServers;
848 hasMcpb = typeof spec === 'string' && isMcpbSource(spec) || Array.isArray(spec) && spec.some((s_3: unknown) => typeof s_3 === 'string' && isMcpbSource(s_3));
849 }
850 } catch (err) {
851 logForDebugging(`Failed to read raw marketplace.json: ${err}`);
852 }
853 }
854 setSelectedPluginHasMcpb(hasMcpb);
855 }
856 void detectMcpb();
857 }, [selectedPlugin]);
858

Callers 1

ManagePluginsFunction · 0.85

Calls 4

isMcpbSourceFunction · 0.85
jsonParseFunction · 0.85
logForDebuggingFunction · 0.85
readFileMethod · 0.80

Tested by

no test coverage detected