(input: string | McpProbeEndpointInput)
| 721 | const httpClientLayer = options?.httpClientLayer ?? ctx.httpClientLayer; |
| 722 | |
| 723 | const probeEndpoint = (input: string | McpProbeEndpointInput) => |
| 724 | Effect.gen(function* () { |
| 725 | const endpoint = typeof input === "string" ? input : input.endpoint; |
| 726 | const trimmed = endpoint.trim(); |
| 727 | if (!trimmed) { |
| 728 | return yield* new McpConnectionError({ |
| 729 | transport: "remote", |
| 730 | message: "Endpoint URL is required", |
| 731 | }); |
| 732 | } |
| 733 | |
| 734 | const name = yield* Effect.try({ |
| 735 | try: () => new URL(trimmed).hostname, |
| 736 | catch: () => "mcp", |
| 737 | }).pipe(Effect.orElseSucceed(() => "mcp")); |
| 738 | const slug = deriveMcpNamespace({ endpoint: trimmed }); |
| 739 | |
| 740 | const probeHeaders = typeof input === "string" ? undefined : input.headers; |
| 741 | const probeQueryParams = typeof input === "string" ? undefined : input.queryParams; |
| 742 | |
| 743 | const connector = createMcpConnector({ |
| 744 | transport: "remote", |
| 745 | endpoint: trimmed, |
| 746 | headers: probeHeaders, |
| 747 | queryParams: probeQueryParams, |
| 748 | httpClientLayer, |
| 749 | }); |
| 750 | |
| 751 | const result = yield* discoverTools(connector).pipe( |
| 752 | Effect.map((m) => ({ ok: true as const, manifest: m })), |
| 753 | Effect.catch(() => Effect.succeed({ ok: false as const, manifest: null })), |
| 754 | Effect.withSpan("mcp.plugin.discover_tools"), |
| 755 | ); |
| 756 | |
| 757 | if (result.ok && result.manifest) { |
| 758 | return { |
| 759 | connected: true, |
| 760 | requiresAuthentication: false, |
| 761 | requiresOAuth: false, |
| 762 | supportsDynamicRegistration: false, |
| 763 | name: result.manifest.server?.name ?? name, |
| 764 | slug, |
| 765 | toolCount: result.manifest.tools.length, |
| 766 | serverName: result.manifest.server?.name ?? null, |
| 767 | instructions: result.manifest.server?.instructions ?? null, |
| 768 | } satisfies McpProbeResult; |
| 769 | } |
| 770 | |
| 771 | // Confirm the endpoint actually speaks MCP before classifying it as |
| 772 | // OAuth-protected (an OAuth-protected non-MCP service would |
| 773 | // otherwise be misclassified). |
| 774 | const shape = yield* probeMcpEndpointShape(trimmed, { |
| 775 | httpClientLayer, |
| 776 | headers: probeHeaders, |
| 777 | queryParams: probeQueryParams, |
| 778 | }); |
| 779 | |
| 780 | // A `not-mcp`/auth-required shape only proves the endpoint returned |
nothing calls this directly
no test coverage detected