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

Function buildConnectorInput

packages/plugins/mcp/src/sdk/plugin.ts:677–745  ·  view source on GitHub ↗
(
  config: McpIntegrationConfigType,
  values: Record<string, string | null>,
  templateSlug: string | null,
  allowStdio: boolean,
  httpClientLayer?: Layer.Layer<HttpClient.HttpClient>,
)

Source from the content-addressed store, hash-verified

675};
676
677const buildConnectorInput = (
678 config: McpIntegrationConfigType,
679 values: Record<string, string | null>,
680 templateSlug: string | null,
681 allowStdio: boolean,
682 httpClientLayer?: Layer.Layer<HttpClient.HttpClient>,
683): Effect.Effect<ConnectorInput, McpConnectionError> => {
684 if (config.transport === "stdio") {
685 if (!allowStdio) {
686 return Effect.fail(
687 new McpConnectionError({
688 transport: "stdio",
689 message:
690 "MCP stdio transport is disabled. Enable it by passing `dangerouslyAllowStdioMCP: true` to mcpPlugin() — only safe for trusted local contexts.",
691 }),
692 );
693 }
694 // Secret env lives on the connection: render the bound `stdio_env`
695 // method's vars from the connection's resolved values, layered over any
696 // static (non-credential / legacy-inline) env in the config. A var that
697 // resolved to nothing is skipped rather than injected as empty.
698 const method = selectAuthMethod(config, templateSlug);
699 const env: Record<string, string> = { ...(config.env ?? {}) };
700 if (method?.kind === "stdio_env") {
701 for (const variable of method.vars) {
702 const value = values[variable];
703 if (value != null) env[variable] = value;
704 }
705 }
706 return Effect.succeed({
707 transport: "stdio" as const,
708 command: config.command,
709 args: config.args,
710 env: Object.keys(env).length > 0 ? env : undefined,
711 cwd: config.cwd,
712 versionNegotiation: config.versionNegotiation,
713 spawnPerCall: config.spawnPerCall,
714 appServer: config.appServer,
715 } satisfies McpStdioIntegrationConfig);
716 }
717
718 // Credential placements render OVER the integration's static headers /
719 // query params — a same-named static entry is overwritten.
720 const headers: Record<string, string> = { ...(config.headers ?? {}) };
721 const queryParams: Record<string, string> = { ...(config.queryParams ?? {}) };
722 let authProvider: OAuthClientProvider | undefined;
723
724 const auth = selectAuthMethod(config, templateSlug);
725 if (auth?.kind === "apikey") {
726 const rendered = renderAuthPlacements(auth.placements, values);
727 Object.assign(headers, rendered.headers);
728 Object.assign(queryParams, rendered.queryParams);
729 } else if (auth?.kind === "oauth2") {
730 const token = values[TOKEN_VARIABLE];
731 if (token != null) authProvider = makeOAuthProvider(token);
732 }
733
734 return Effect.succeed({

Callers 1

plugin.tsFile · 0.85

Calls 3

renderAuthPlacementsFunction · 0.90
selectAuthMethodFunction · 0.85
makeOAuthProviderFunction · 0.85

Tested by

no test coverage detected