(url: string)
| 91 | | { ok: false; result: PerformMcpServerResult } |
| 92 | |
| 93 | async function validateMcpServerUrl(url: string): Promise<ValidateMcpServerUrlResult> { |
| 94 | try { |
| 95 | validateMcpDomain(url) |
| 96 | const resolvedIP = await validateMcpServerSsrf(url) |
| 97 | return { ok: true, resolvedIP } |
| 98 | } catch (error) { |
| 99 | if (error instanceof McpDomainNotAllowedError || error instanceof McpSsrfError) { |
| 100 | return { ok: false, result: { success: false, error: error.message, errorCode: 'forbidden' } } |
| 101 | } |
| 102 | if (error instanceof McpDnsResolutionError) { |
| 103 | return { |
| 104 | ok: false, |
| 105 | result: { success: false, error: error.message, errorCode: 'bad_gateway' }, |
| 106 | } |
| 107 | } |
| 108 | throw error |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | export async function performCreateMcpServer( |
| 113 | params: PerformCreateMcpServerParams |
no test coverage detected