( config: McpServerConfig, )
| 559 | * Returns undefined for stdio/sdk servers or if URL parsing fails. |
| 560 | */ |
| 561 | export function getLoggingSafeMcpBaseUrl( |
| 562 | config: McpServerConfig, |
| 563 | ): string | undefined { |
| 564 | if (!('url' in config) || typeof config.url !== 'string') { |
| 565 | return undefined |
| 566 | } |
| 567 | |
| 568 | try { |
| 569 | const url = new URL(config.url) |
| 570 | url.search = '' |
| 571 | return url.toString().replace(/\/$/, '') |
| 572 | } catch { |
| 573 | return undefined |
| 574 | } |
| 575 | } |
| 576 |
no test coverage detected