diff --git a/README.md b/README.md index cadbb07..38558f7 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ openapi-mcp-generator --input path/to/openapi.json --output path/to/output/dir - | `--port` | `-p` | Port for web-based transports | `3000` | | `--default-include` | | Default behavior for x-mcp filtering. Accepts `true` or `false` (case-insensitive). `true` = include by default, `false` = exclude by default. | `true` | | `--force` | | Overwrite existing files in the output directory without confirmation | `false` | -| `--insecure` | `-k` | Allow insecure HTTPS connections (self-signed certificates) | `false` | +| `--insecure` | `-k` | Allow insecure HTTPS connections (self-signed certificates) | `false` | ## 📦 Programmatic API diff --git a/src/generator/server-code.ts b/src/generator/server-code.ts index ebf4a1b..7118a32 100644 --- a/src/generator/server-code.ts +++ b/src/generator/server-code.ts @@ -35,7 +35,8 @@ export function generateMcpServerCode( // Generate code for API tool execution const executeApiToolFunctionCode = generateExecuteApiToolFunction( - api.components?.securitySchemes, options.insecure, + api.components?.securitySchemes, + options.insecure ); // Generate code for request handlers @@ -105,7 +106,7 @@ import { import { z, ZodError } from 'zod'; import { jsonSchemaToZod } from 'json-schema-to-zod'; import axios, { type AxiosRequestConfig, type AxiosError } from 'axios'; -import https from 'https'; +${options.insecure ? "import https from 'https';" : ''} /** * Type definition for JSON objects diff --git a/src/index.ts b/src/index.ts index 6c1d87f..44aa84f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -87,10 +87,8 @@ program true ) .option('--force', 'Overwrite existing files without prompting') - .option( - '-k, --insecure', - 'Allow insecure HTTPS connections (self-signed certificates)', - (val) => normalizeBoolean(val) + .option('-k, --insecure', 'Allow insecure HTTPS connections (self-signed certificates)', (val) => + normalizeBoolean(val) ) .version(pkg.version) // Match package.json version .action((options) => { diff --git a/src/utils/security.ts b/src/utils/security.ts index c9aecb6..63346eb 100644 --- a/src/utils/security.ts +++ b/src/utils/security.ts @@ -202,7 +202,8 @@ async function acquireOAuth2Token(schemeName: string, scheme: any): Promise