(agentName: SetupAgent, scope: Scope)
| 324 | } |
| 325 | |
| 326 | async function uninstallMcp(agentName: SetupAgent, scope: Scope): Promise<CleanupStatus> { |
| 327 | const agent = getAgent(agentName); |
| 328 | if (scope === "project" && agent.mcp.projectPaths.length === 0) { |
| 329 | return { status: "not found", path: "" }; |
| 330 | } |
| 331 | const mcpCandidates = |
| 332 | scope === "global" |
| 333 | ? agent.mcp.globalPaths |
| 334 | : agent.mcp.projectPaths.map((path) => join(process.cwd(), path)); |
| 335 | const mcpPath = await resolveMcpPath(mcpCandidates); |
| 336 | |
| 337 | try { |
| 338 | if (mcpPath.endsWith(".toml")) { |
| 339 | const { removed } = await removeTomlServer(mcpPath, "context7"); |
| 340 | return { status: removed ? "removed" : "not found", path: mcpPath }; |
| 341 | } |
| 342 | |
| 343 | const existing = await readJsonConfig(mcpPath); |
| 344 | const { config, removed } = removeServerEntry(existing, agent.mcp.configKey, "context7"); |
| 345 | if (removed) { |
| 346 | await writeJsonConfig(mcpPath, config); |
| 347 | } |
| 348 | return { status: removed ? "removed" : "not found", path: mcpPath }; |
| 349 | } catch (err) { |
| 350 | return { status: `failed: ${err instanceof Error ? err.message : String(err)}`, path: mcpPath }; |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | async function uninstallRule(agentName: SetupAgent, scope: Scope): Promise<CleanupStatus> { |
| 355 | const agent = getAgent(agentName); |
no test coverage detected