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

Function probeEndpoint

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

Source from the content-addressed store, hash-verified

938 const httpClientLayer = options?.httpClientLayer ?? ctx.httpClientLayer;
939
940 const probeEndpoint = (input: string | McpProbeEndpointInput) =>
941 Effect.gen(function* () {
942 const endpoint = typeof input === "string" ? input : input.endpoint;
943 const trimmed = endpoint.trim();
944 if (!trimmed) {
945 return yield* new McpConnectionError({
946 transport: "remote",
947 message: "Endpoint URL is required",
948 });
949 }
950
951 const name = yield* Effect.try({
952 try: () => new URL(trimmed).hostname,
953 catch: () => "mcp",
954 }).pipe(Effect.orElseSucceed(() => "mcp"));
955 const slug = deriveMcpNamespace({ endpoint: trimmed });
956
957 const probeHeaders = typeof input === "string" ? undefined : input.headers;
958 const probeQueryParams = typeof input === "string" ? undefined : input.queryParams;
959
960 const connector = createMcpConnector({
961 transport: "remote",
962 endpoint: trimmed,
963 headers: probeHeaders,
964 queryParams: probeQueryParams,
965 httpClientLayer,
966 });
967
968 const result = yield* discoverTools(connector).pipe(
969 Effect.map((m) => ({ ok: true as const, manifest: m })),
970 Effect.catch(() => Effect.succeed({ ok: false as const, manifest: null })),
971 Effect.withSpan("mcp.plugin.discover_tools"),
972 );
973
974 if (result.ok && result.manifest) {
975 return {
976 connected: true,
977 requiresAuthentication: false,
978 requiresOAuth: false,
979 supportsDynamicRegistration: false,
980 name: result.manifest.server?.name ?? name,
981 slug,
982 toolCount: result.manifest.tools.length,
983 serverName: result.manifest.server?.name ?? null,
984 instructions: result.manifest.server?.instructions ?? null,
985 } satisfies McpProbeResult;
986 }
987
988 // Confirm the endpoint actually speaks MCP before classifying it as
989 // OAuth-protected (an OAuth-protected non-MCP service would
990 // otherwise be misclassified).
991 const shape = yield* probeMcpEndpointShape(trimmed, {
992 httpClientLayer,
993 headers: probeHeaders,
994 queryParams: probeQueryParams,
995 });
996
997 // A `not-mcp`/auth-required shape only proves the endpoint returned

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected