From c9adfde9f3e6a29312b9530a854cf6eb6ff3485d Mon Sep 17 00:00:00 2001 From: Addison Waldow Date: Tue, 10 Feb 2026 20:18:32 -0700 Subject: [PATCH 1/5] chore: add shx to allow windows runs of the server for local testing --- src/generator/package-json.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/generator/package-json.ts b/src/generator/package-json.ts index ef97985..7766eec 100644 --- a/src/generator/package-json.ts +++ b/src/generator/package-json.ts @@ -23,7 +23,7 @@ export function generatePackageJson( files: ['build', 'src'], scripts: { start: 'node build/index.js', - build: 'tsc && chmod 755 build/index.js', + build: 'tsc && shx chmod 755 build/index.js', typecheck: 'tsc --noEmit', prestart: 'npm run build', }, @@ -40,6 +40,7 @@ export function generatePackageJson( devDependencies: { '@types/node': '^22.15.2', typescript: '^5.8.3', + "shx": "^0.4.0", }, }; From 92adaa2c6fac383c7e3838289c4f3d2a9b21924c Mon Sep 17 00:00:00 2001 From: Addison Waldow Date: Tue, 10 Feb 2026 20:24:58 -0700 Subject: [PATCH 2/5] fix: add configurable API base URL for MCP server --- src/generator/env-file.ts | 3 +++ src/generator/server-code.ts | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/generator/env-file.ts b/src/generator/env-file.ts index d1cc591..1b26c64 100644 --- a/src/generator/env-file.ts +++ b/src/generator/env-file.ts @@ -19,6 +19,9 @@ export function generateEnvExample( # Server configuration PORT=3000 LOG_LEVEL=info +# If you have a server outside the servers list from OpenAPI, define it here. +# Otherwise, omit this. +API_BASE_URL=your_api_base_url_here `; diff --git a/src/generator/server-code.ts b/src/generator/server-code.ts index 6b6a447..a4d8e7a 100644 --- a/src/generator/server-code.ts +++ b/src/generator/server-code.ts @@ -130,7 +130,8 @@ interface McpToolDefinition { */ export const SERVER_NAME = "${serverName}"; export const SERVER_VERSION = "${serverVersion}"; -export const API_BASE_URL = "${determinedBaseUrl || ''}"; +// Base URL for the API, can be set via environment variable or determined from OpenAPI spec +export const API_BASE_URL = process.env.API_BASE_URL || "${determinedBaseUrl || ''}"; /** * MCP Server instance From aaea8c9ef9f7c9f766bc91e44fc7b120e7274d08 Mon Sep 17 00:00:00 2001 From: Addison Waldow Date: Tue, 10 Feb 2026 20:42:17 -0700 Subject: [PATCH 3/5] fix: update API_BASE_URL to use template literals and log the value --- src/generator/server-code.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/generator/server-code.ts b/src/generator/server-code.ts index a4d8e7a..f5209ce 100644 --- a/src/generator/server-code.ts +++ b/src/generator/server-code.ts @@ -131,7 +131,8 @@ interface McpToolDefinition { export const SERVER_NAME = "${serverName}"; export const SERVER_VERSION = "${serverVersion}"; // Base URL for the API, can be set via environment variable or determined from OpenAPI spec -export const API_BASE_URL = process.env.API_BASE_URL || "${determinedBaseUrl || ''}"; +export const API_BASE_URL = \`\$\{process.env.API_BASE_URL\}\` || "${determinedBaseUrl || ''}"; +console.error("API_BASE_URL is set to:", API_BASE_URL); /** * MCP Server instance From 959afa4dda5a8ec0debd71cc5a1c17c8297ea75f Mon Sep 17 00:00:00 2001 From: Addison Waldow Date: Tue, 10 Feb 2026 20:47:16 -0700 Subject: [PATCH 4/5] fix: update API_BASE_URL to remove template literals and log the value --- src/generator/server-code.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generator/server-code.ts b/src/generator/server-code.ts index f5209ce..a4a39fe 100644 --- a/src/generator/server-code.ts +++ b/src/generator/server-code.ts @@ -131,7 +131,7 @@ interface McpToolDefinition { export const SERVER_NAME = "${serverName}"; export const SERVER_VERSION = "${serverVersion}"; // Base URL for the API, can be set via environment variable or determined from OpenAPI spec -export const API_BASE_URL = \`\$\{process.env.API_BASE_URL\}\` || "${determinedBaseUrl || ''}"; +export const API_BASE_URL = process.env.API_BASE_URL || "${determinedBaseUrl || ''}"; console.error("API_BASE_URL is set to:", API_BASE_URL); /** From 10e8e8deaabf86dfa46c48c7aaa4735f93ce1d1f Mon Sep 17 00:00:00 2001 From: Addison Waldow Date: Wed, 11 Feb 2026 18:52:58 -0700 Subject: [PATCH 5/5] fix: standardize shx dependency format in package.json --- .github/PULL_REQUEST_TEMPLATE/mcpcat.md | 11 ++++++++++- src/generator/package-json.ts | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE/mcpcat.md b/.github/PULL_REQUEST_TEMPLATE/mcpcat.md index d3c1a4f..8c76063 100644 --- a/.github/PULL_REQUEST_TEMPLATE/mcpcat.md +++ b/.github/PULL_REQUEST_TEMPLATE/mcpcat.md @@ -3,22 +3,28 @@ > **TL;DR**: This PR adds an **opt-in** flag to scaffold privacy-safe analytics wiring for MCPcat in projects generated by `openapi-mcp-generator`. ## Summary + This PR introduces a `--with-mcpcat` CLI flag that scaffolds: + - A tiny analytics shim to emit initialize/tool-call events. - A default **local redaction** helper to scrub sensitive data before export. - Minimal config via environment variables. -No behavior changes unless the flag and env vars are set. + No behavior changes unless the flag and env vars are set. ## Motivation + - Make freshly generated MCP servers **observable in minutes**. - Encourage **privacy-by-default** analytics patterns. - Reduce copy/paste wiring; standardize event shape (operationId, path, duration, status). ## Changes + ### CLI + - `generate` accepts `--with-mcpcat` (default: off). ### Template files (added conditionally) + - `src/analytics/mcpcat.ts` – lazy import + safe no-op if SDK absent. - `src/analytics/redact.ts` – OpenAPI-aware heuristics (e.g., `*token*`, `password`, `apiKey`, `authorization`, `email`). - `src/analytics/config.ts` – reads env: @@ -28,6 +34,7 @@ No behavior changes unless the flag and env vars are set. - `MCPCAT_SAMPLE_RATE=1.0` (0–1) ### Server wiring + - Hooks server `.initialize` and each tool invocation to record: - `operationId`, HTTP `method`, `path` - redacted `args` @@ -35,9 +42,11 @@ No behavior changes unless the flag and env vars are set. - `duration_ms` ### Docs + - Adds a “Enable analytics (MCPcat)” section to generated README with privacy notes and quickstart. ## Implementation Notes + - **Compile-time optional**: no imports unless flag is used. - **Runtime safe**: try/catch around SDK import → graceful no-op if not installed. - **Transport-agnostic**: compatible with stdio, SSE/web, and StreamableHTTP templates. diff --git a/src/generator/package-json.ts b/src/generator/package-json.ts index 7766eec..20443a1 100644 --- a/src/generator/package-json.ts +++ b/src/generator/package-json.ts @@ -40,7 +40,7 @@ export function generatePackageJson( devDependencies: { '@types/node': '^22.15.2', typescript: '^5.8.3', - "shx": "^0.4.0", + shx: '^0.4.0', }, };