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

Function hasMcpConfig

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

Source from the content-addressed store, hash-verified

190}
191
192async function hasMcpConfig(agentName: SetupAgent, scope: Scope): Promise<boolean> {
193 const agent = getAgent(agentName);
194 // Agents with no project-level MCP (e.g. Antigravity) only have a global
195 // config — there's nothing to detect at project scope.
196 if (scope === "project" && agent.mcp.projectPaths.length === 0) return false;
197 const candidates =
198 scope === "global"
199 ? agent.mcp.globalPaths
200 : agent.mcp.projectPaths.map((path) => join(process.cwd(), path));
201 const mcpPath = await resolveMcpPath(candidates);
202
203 if (mcpPath.endsWith(".toml")) {
204 return readTomlServerExists(mcpPath, "context7");
205 }
206
207 let existing: Record<string, unknown>;
208 try {
209 existing = await readJsonConfig(mcpPath);
210 } catch (err) {
211 log.warn(
212 `Skipped ${mcpPath}: could not parse (${err instanceof Error ? err.message : String(err)})`
213 );
214 return false;
215 }
216 const section = existing[agent.mcp.configKey];
217 return (
218 !!section && typeof section === "object" && !Array.isArray(section) && "context7" in section
219 );
220}
221
222async function hasRule(agentName: SetupAgent, scope: Scope): Promise<boolean> {
223 const agent = getAgent(agentName);

Callers 2

detectAvailableModesFunction · 0.85
hasAnyContext7ArtifactsFunction · 0.85

Calls 4

getAgentFunction · 0.85
resolveMcpPathFunction · 0.85
readTomlServerExistsFunction · 0.85
readJsonConfigFunction · 0.85

Tested by

no test coverage detected