MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / loadClaudeCodePluginMcpServers

Function loadClaudeCodePluginMcpServers

src/integrations/claude-plugins.ts:245–261  ·  view source on GitHub ↗
(cwd: string)

Source from the content-addressed store, hash-verified

243
244/** Discover MCP servers declared by Claude Code plugins (plugin.json mcpServers + .mcp.json). */
245export async function loadClaudeCodePluginMcpServers(cwd: string): Promise<Record<string, MCPServerConfig>> {
246 if (disabled()) return {};
247 const out: Record<string, MCPServerConfig> = {};
248 let plugins: Array<{ name: string; path: string }> = [];
249 try { plugins = await relevantPluginPaths(cwd); } catch { return {}; }
250 for (const p of plugins) {
251 const manifest = await readJsonIfExists(path.join(p.path, '.claude-plugin', 'plugin.json'));
252 const dotMcp = await readJsonIfExists(path.join(p.path, '.mcp.json'));
253 const servers = { ...(manifest?.mcpServers ?? {}), ...(dotMcp?.mcpServers ?? {}) };
254 for (const [name, raw] of Object.entries(servers)) {
255 if (!raw || typeof raw !== 'object') continue;
256 // Namespace by plugin to avoid collisions, mirroring Claude Code conventions.
257 out[`${p.name}:${name}`] = substitutePluginRoot(raw as MCPServerConfig, p.path);
258 }
259 }
260 return out;
261}
262
263const SUPPORTED_HOOK_EVENTS: HookEvent[] = ['PreToolUse', 'PostToolUse', 'SessionStart', 'SessionEnd', 'PreCompact'];
264

Callers 1

mergeClaudeCodePluginMcpFunction · 0.85

Calls 4

disabledFunction · 0.85
relevantPluginPathsFunction · 0.85
readJsonIfExistsFunction · 0.85
substitutePluginRootFunction · 0.85

Tested by

no test coverage detected