// {{ display_name }} MCP server — generated by mcpify. Do not hand-edit.

/**
 * Joins a configured base URL with an operation path and query params,
 * normalizing slashes so callers never have to think about trailing/leading
 * separators.
 */
export function buildApiUrl(
  baseUrl: string,
  path: string,
  query?: Record<string, string | number | boolean | undefined>,
): string {
  const base = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;
  const url = new URL(path.replace(/^\//, ''), base);
  for (const [key, value] of Object.entries(query ?? {})) {
    if (value !== undefined) url.searchParams.set(key, String(value));
  }
  return url.toString();
}
