MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / probeEndpoint

Function probeEndpoint

packages/plugins/mcp/src/sdk/plugin.ts:835–968  ·  view source on GitHub ↗
(input: string | McpProbeEndpointInput)

Source from the content-addressed store, hash-verified

833 const httpClientLayer = options?.httpClientLayer ?? ctx.httpClientLayer;
834
835 const probeEndpoint = (input: string | McpProbeEndpointInput) =>
836 Effect.gen(function* () {
837 const endpoint = typeof input === "string" ? input : input.endpoint;
838 const trimmed = endpoint.trim();
839 if (!trimmed) {
840 return yield* new McpConnectionError({
841 transport: "remote",
842 message: "Endpoint URL is required",
843 });
844 }
845
846 const name = yield* Effect.try({
847 try: () => new URL(trimmed).hostname,
848 catch: () => "mcp",
849 }).pipe(Effect.orElseSucceed(() => "mcp"));
850 const slug = deriveMcpNamespace({ endpoint: trimmed });
851
852 const probeHeaders = typeof input === "string" ? undefined : input.headers;
853 const probeQueryParams = typeof input === "string" ? undefined : input.queryParams;
854
855 const connector = createMcpConnector({
856 transport: "remote",
857 endpoint: trimmed,
858 headers: probeHeaders,
859 queryParams: probeQueryParams,
860 httpClientLayer,
861 });
862
863 const result = yield* discoverTools(connector).pipe(
864 Effect.map((m) => ({ ok: true as const, manifest: m })),
865 Effect.catch(() => Effect.succeed({ ok: false as const, manifest: null })),
866 Effect.withSpan("mcp.plugin.discover_tools"),
867 );
868
869 if (result.ok && result.manifest) {
870 return {
871 connected: true,
872 requiresAuthentication: false,
873 requiresOAuth: false,
874 supportsDynamicRegistration: false,
875 name: result.manifest.server?.name ?? name,
876 slug,
877 toolCount: result.manifest.tools.length,
878 serverName: result.manifest.server?.name ?? null,
879 instructions: result.manifest.server?.instructions ?? null,
880 } satisfies McpProbeResult;
881 }
882
883 // Confirm the endpoint actually speaks MCP before classifying it as
884 // OAuth-protected (an OAuth-protected non-MCP service would
885 // otherwise be misclassified).
886 const shape = yield* probeMcpEndpointShape(trimmed, {
887 httpClientLayer,
888 headers: probeHeaders,
889 queryParams: probeQueryParams,
890 });
891
892 // A `not-mcp`/auth-required shape only proves the endpoint returned

Callers

nothing calls this directly

Calls 5

deriveMcpNamespaceFunction · 0.90
createMcpConnectorFunction · 0.90
discoverToolsFunction · 0.90
probeMcpEndpointShapeFunction · 0.90
userFacingProbeMessageFunction · 0.85

Tested by

no test coverage detected