(input: McpServerInput)
| 465 | * boundary (a value in `env` becomes something the user is asked to type), |
| 466 | * and asserting it through the whole add flow would not show it. */ |
| 467 | export const toIntegrationConfig = (input: McpServerInput): McpIntegrationConfigType => { |
| 468 | if (input.transport === "stdio") { |
| 469 | // The config only DECLARES the secret env vars by NAME (a `stdio_env` |
| 470 | // method); their values are credentials and live on the connection, never |
| 471 | // in this blob. Names come from the explicit `envVars` declaration and/or |
| 472 | // the keys of any one-shot `env` values. |
| 473 | const vars = stdioEnvVarNames(input); |
| 474 | const staticEnv = input.staticEnv; |
| 475 | return { |
| 476 | transport: "stdio", |
| 477 | family: input.family?.trim() || undefined, |
| 478 | command: input.command, |
| 479 | args: input.args ? [...input.args] : undefined, |
| 480 | env: staticEnv !== undefined && Object.keys(staticEnv).length > 0 ? staticEnv : undefined, |
| 481 | cwd: input.cwd, |
| 482 | versionNegotiation: input.versionNegotiation, |
| 483 | spawnPerCall: input.spawnPerCall, |
| 484 | appServer: input.appServer, |
| 485 | authenticationTemplate: |
| 486 | vars.length > 0 |
| 487 | ? [{ slug: STDIO_ENV_TEMPLATE, kind: "stdio_env", vars }] |
| 488 | : [{ slug: "none", kind: "none" }], |
| 489 | }; |
| 490 | } |
| 491 | return { |
| 492 | transport: "remote", |
| 493 | family: input.family?.trim() || undefined, |
| 494 | endpoint: input.endpoint, |
| 495 | remoteTransport: input.remoteTransport ?? "auto", |
| 496 | queryParams: input.queryParams, |
| 497 | headers: input.headers, |
| 498 | authenticationTemplate: input.authenticationTemplate |
| 499 | ? normalizeMcpAuthMethods(input.authenticationTemplate) |
| 500 | : [mcpAuthMethodFromShorthand(input.auth ?? { kind: "none" })], |
| 501 | versionNegotiation: input.versionNegotiation, |
| 502 | }; |
| 503 | }; |
| 504 | |
| 505 | type JsonSchemaObject = Record<string, unknown> & { |
| 506 | readonly properties?: Record<string, unknown>; |
no test coverage detected