/**
 * MCP detector — parses the agent's canonical MCP config in the version home
 * and returns server names. Mirrors versions.ts:432-443.
 */
import * as fs from 'fs';
import { capableAgents } from '../../capabilities.js';
import { getMcpConfigPathForHome, parseMcpConfig } from '../../agents.js';
import { lazyAgentMap } from '../writers/lazy-map.js';
function buildMcpDetector(agent) {
    return {
        kind: 'mcp',
        agent,
        list({ versionHome }) {
            const p = getMcpConfigPathForHome(agent, versionHome);
            if (!fs.existsSync(p))
                return [];
            try {
                return Object.keys(parseMcpConfig(agent, p));
            }
            catch {
                return [];
            }
        },
    };
}
export const mcpDetectors = lazyAgentMap(() => {
    const m = {};
    for (const agent of capableAgents('mcp'))
        m[agent] = buildMcpDetector(agent);
    return m;
});
