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