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

Function probeEndpoint

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

Source from the content-addressed store, hash-verified

776 const httpClientLayer = options?.httpClientLayer ?? ctx.httpClientLayer;
777
778 const probeEndpoint = (input: string | McpProbeEndpointInput) =>
779 Effect.gen(function* () {
780 const endpoint = typeof input === "string" ? input : input.endpoint;
781 const trimmed = endpoint.trim();
782 if (!trimmed) {
783 return yield* new McpConnectionError({
784 transport: "remote",
785 message: "Endpoint URL is required",
786 });
787 }
788
789 const name = yield* Effect.try({
790 try: () => new URL(trimmed).hostname,
791 catch: () => "mcp",
792 }).pipe(Effect.orElseSucceed(() => "mcp"));
793 const slug = deriveMcpNamespace({ endpoint: trimmed });
794
795 const probeHeaders = typeof input === "string" ? undefined : input.headers;
796 const probeQueryParams = typeof input === "string" ? undefined : input.queryParams;
797
798 const connector = createMcpConnector({
799 transport: "remote",
800 endpoint: trimmed,
801 headers: probeHeaders,
802 queryParams: probeQueryParams,
803 httpClientLayer,
804 });
805
806 const result = yield* discoverTools(connector).pipe(
807 Effect.map((m) => ({ ok: true as const, manifest: m })),
808 Effect.catch(() => Effect.succeed({ ok: false as const, manifest: null })),
809 Effect.withSpan("mcp.plugin.discover_tools"),
810 );
811
812 if (result.ok && result.manifest) {
813 return {
814 connected: true,
815 requiresAuthentication: false,
816 requiresOAuth: false,
817 supportsDynamicRegistration: false,
818 name: result.manifest.server?.name ?? name,
819 slug,
820 toolCount: result.manifest.tools.length,
821 serverName: result.manifest.server?.name ?? null,
822 instructions: result.manifest.server?.instructions ?? null,
823 } satisfies McpProbeResult;
824 }
825
826 // Confirm the endpoint actually speaks MCP before classifying it as
827 // OAuth-protected (an OAuth-protected non-MCP service would
828 // otherwise be misclassified).
829 const shape = yield* probeMcpEndpointShape(trimmed, {
830 httpClientLayer,
831 headers: probeHeaders,
832 queryParams: probeQueryParams,
833 });
834
835 // 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