//#region src/providers/mcp/util.ts
function getAuthHeaders(server) {
	if (!server.auth) return {};
	if (server.auth.type === "bearer" && server.auth.token) return { Authorization: `Bearer ${server.auth.token}` };
	if (server.auth.type === "api_key" && server.auth.api_key) return { "X-API-Key": server.auth.api_key };
	return {};
}

//#endregion
//#region src/providers/mcp/transform.ts
function transformMCPToolsToOpenAi(tools) {
	return tools.map((tool) => {
		const schema = tool.inputSchema;
		let properties = {};
		let required = void 0;
		let additionalProperties = void 0;
		if (schema && typeof schema === "object" && "properties" in schema) {
			properties = schema.properties ?? {};
			required = schema.required;
			if ("additionalProperties" in schema) additionalProperties = schema.additionalProperties;
		} else if (schema && typeof schema === "object") properties = {};
		else properties = {};
		return {
			type: "function",
			function: {
				name: tool.name,
				description: tool.description,
				parameters: {
					type: "object",
					properties,
					...required && required.length > 0 ? { required } : {},
					...additionalProperties !== void 0 ? { additionalProperties } : {}
				}
			}
		};
	});
}
function transformMCPToolsToAnthropic(tools) {
	return tools.map((tool) => {
		const { $schema: _$schema, ...cleanSchema } = tool.inputSchema;
		return {
			name: tool.name,
			description: tool.description,
			input_schema: {
				type: "object",
				...cleanSchema
			}
		};
	});
}
function transformMCPToolsToGoogle(tools) {
	return [{ functionDeclarations: tools.map((tool) => {
		const schema = tool.inputSchema;
		let parameters = {
			type: "OBJECT",
			properties: {}
		};
		if (schema && typeof schema === "object" && "properties" in schema) {
			const { $schema: _$schema, ...cleanSchema } = schema;
			parameters = {
				type: "OBJECT",
				...cleanSchema
			};
		} else parameters = {
			type: "OBJECT",
			properties: schema || {}
		};
		return {
			name: tool.name,
			description: tool.description,
			parameters
		};
	}) }];
}
function transformMCPConfigToClaudeCode(config) {
	const servers = config.servers?.map((server) => transformMCPServerConfigToClaudeCode(server)) ?? [];
	if (config.server) servers.push(transformMCPServerConfigToClaudeCode(config.server));
	return servers.reduce((acc, transformed) => {
		const [key, out] = transformed;
		acc[key] = out;
		return acc;
	}, {});
}
function transformMCPServerConfigToClaudeCode(config) {
	const key = config.name ?? config.url ?? config.command ?? "default";
	let out;
	if (config.url) out = {
		type: "http",
		url: config.url,
		headers: {
			...config.headers ?? {},
			...getAuthHeaders(config)
		}
	};
	else if (config.command && config.args) out = {
		type: "stdio",
		command: config.command,
		args: config.args
	};
	else if (config.path) out = {
		type: "stdio",
		command: config.path.endsWith(".py") ? process.platform === "win32" ? "python" : "python3" : process.execPath,
		args: [config.path]
	};
	else throw new Error("MCP configuration cannot be converted to Claude Agent SDK MCP server config");
	return [key, out];
}

//#endregion
export { getAuthHeaders as a, transformMCPToolsToOpenAi as i, transformMCPToolsToAnthropic as n, transformMCPToolsToGoogle as r, transformMCPConfigToClaudeCode as t };
//# sourceMappingURL=transform-DuWXqLDP.js.map