
export const EXA_TOOLS = ["web_search_exa", "web_fetch_exa", "web_search_advanced_exa"];
const EXA_MCP_URL = `https://mcp.exa.ai/mcp?tools=${EXA_TOOLS.join(",")}`;

export function createMcpConfig(env: Record<string, string | undefined>) {
	const hasExaApiKey = Boolean(env.EXA_API_KEY?.trim());
	return {
		settings: {
			disableProxyTool: true,
			scriptMode: false,
		},
		mcpServers: {
			exa: {
				url: EXA_MCP_URL,
				...(hasExaApiKey ? { headers: { "x-api-key": "$env:EXA_API_KEY" } } : {}),
				protocolVersion: "auto" as const,
				lifecycle: "eager" as const,
				directTools: EXA_TOOLS,
				includeTools: EXA_TOOLS,
				toolPrefix: "none" as const,
				approveTools: false,
				exposeResources: false,
			},
			codegraph: {
				command: "codegraph",
				args: ["serve", "--mcp"],
				lifecycle: "keep-alive" as const,
				directTools: ["codegraph_explore"],
				includeTools: ["codegraph_explore"],
				toolPrefix: "none" as const,
				approveTools: false,
				exposeResources: false,
			},
		},
	};
}
