MCPcopy
hub / github.com/upstash/context7 / uninstallMcp

Function uninstallMcp

packages/cli/src/commands/remove.ts:326–352  ·  view source on GitHub ↗
(agentName: SetupAgent, scope: Scope)

Source from the content-addressed store, hash-verified

324}
325
326async 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
354async function uninstallRule(agentName: SetupAgent, scope: Scope): Promise<CleanupStatus> {
355 const agent = getAgent(agentName);

Callers 1

uninstallAgentFunction · 0.85

Calls 6

getAgentFunction · 0.85
resolveMcpPathFunction · 0.85
removeTomlServerFunction · 0.85
readJsonConfigFunction · 0.85
removeServerEntryFunction · 0.85
writeJsonConfigFunction · 0.85

Tested by

no test coverage detected