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

Function probeEndpoint

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

Source from the content-addressed store, hash-verified

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