Skip to content

kaizen: remove unused deprecated type aliases#171

Open
gabrypavanello wants to merge 6 commits intomainfrom
kaizen/2026-02-16
Open

kaizen: remove unused deprecated type aliases#171
gabrypavanello wants to merge 6 commits intomainfrom
kaizen/2026-02-16

Conversation

@gabrypavanello
Copy link
Contributor

Removes FileBasedGlobalConfig and IconConfig deprecated type aliases from @mcp-apps-kit/codegen.

What: These were deprecated aliases (FileBasedGlobalConfig → GlobalConfig, IconConfig → Icon) with zero consumers across the codebase.

Why: Eliminates 1 eslint-disable @typescript-eslint/no-deprecated suppression and 2 dead type exports.

Risk: None — no consumers found in any package.

Sirius added 6 commits February 10, 2026 09:03
…SK-037-02)

Replace all raw console.log/warn/error calls across 17 inspector/src
files with scoped logger instances using createLogger(). Each module
gets a descriptive source name for log filtering.

- 17 files migrated to structured logger
- Stale eslint-disable no-console comments removed
- Tests updated to match new console.info output format
- bin/mcp-inspector.ts and widget-server-templates.ts untouched
- proxy-resources.ts skipped (console call is in client-side template)
…d IconConfig

These deprecated aliases (FileBasedGlobalConfig → GlobalConfig, IconConfig → Icon)
had zero consumers across the codebase. Removing them eliminates 1 eslint-disable
suppression and 2 deprecated type exports.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 16, 2026

📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced centralized structured logging with timestamps and log-level configuration via environment variables
    • Exported new logger utilities for advanced debugging capabilities
  • Breaking Changes

    • Removed deprecated type aliases from public API
  • Tests

    • Added comprehensive test suite for logging functionality with environment variable handling

Walkthrough

This PR removes deprecated type aliases from the codegen package and introduces a centralized, structured logger throughout the inspector, testing, and UI packages. The logger supports level-based filtering (DEBUG, INFO, WARN, ERROR), timestamps, and respects the MCP_APPS_LOG_LEVEL environment variable. All console.log/warn/error calls are replaced with corresponding logger method calls.

Changes

Cohort / File(s) Summary
Codegen Deprecation
packages/codegen/src/index.ts, packages/codegen/src/types.ts
Removed deprecated type aliases FileBasedGlobalConfig and IconConfig from public exports.
Logger Module Implementation
packages/inspector/src/debug/logger.ts, packages/inspector/src/index.ts
Added new structured logger module with LogLevel type, Logger interface, createLogger factory, defaultLogger instance, and level-gated message filtering based on MCP_APPS_LOG_LEVEL environment variable. Exported logger utilities from inspector index.
Logging Refactor - Connection & Streaming
packages/codegen/src/watcher.ts, packages/inspector/src/connection.ts, packages/inspector/src/dashboard/cdp-streamer.ts, packages/inspector/src/dual-server.ts
Replaced console-based logging with structured logger for connection management, widget server lifecycle, OAuth events, and CDP frame handling.
Logging Refactor - Hosts & OAuth
packages/inspector/src/hosts/mcp-host.ts, packages/inspector/src/hosts/openai-host.ts, packages/inspector/src/oauth/preset-config.ts, packages/inspector/src/oauth/provider.ts, packages/inspector/src/oauth/wellknown-proxy.ts
Replaced console logging with structured logger across MCP/OpenAI host emulators and OAuth provider discovery/configuration modules.
Logging Refactor - Tools & Widgets
packages/inspector/src/proxy-tools.ts, packages/inspector/src/tools/call-tool.ts, packages/inspector/src/tools/widget-control.ts, packages/inspector/src/widget-server.ts, packages/inspector/src/widget-session-manager.ts
Replaced console logging with structured logger for widget session management, tool execution, and widget server operations.
Logging Refactor - Sessions & Server
packages/inspector/src/session/session-renderer.ts, packages/inspector/src/session/session-store.ts, packages/inspector/src/standalone-server.ts
Replaced console logging with structured logger for session lifecycle management and standalone server operations.
Testing & UI Packages
packages/inspector/tests/logger.test.ts, packages/inspector/tests/widget-session-manager.test.ts, packages/testing/src/eval/mcp/evaluator.ts, packages/ui-react/src/hooks.ts
Added comprehensive logger unit tests validating level-gated filtering, timestamp formatting, and environment-driven configuration. Updated widget-session-manager tests for new logging mechanism. Implemented lightweight loggers in testing and UI packages.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 68.42% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title 'kaizen: remove unused deprecated type aliases' is specific and directly related to the main change: removing FileBasedGlobalConfig and IconConfig deprecated type aliases.
Description check ✅ Passed The description is directly related to the changeset, explaining what was removed (deprecated type aliases), why (zero consumers and dead exports), and the risk assessment (none).
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch kaizen/2026-02-16

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude
Copy link
Contributor

claude bot commented Feb 16, 2026

Code Review: PR #171 - Kaizen: Remove Unused Deprecated Type Aliases

Summary

This PR successfully removes two deprecated type aliases (FileBasedGlobalConfig and IconConfig) from @mcp-apps-kit/codegen while introducing a comprehensive structured logging system across the inspector package.

Strengths

1. Clean Deprecated Code Removal

  • Safe removal of FileBasedGlobalConfig and IconConfig with zero consumers
  • Eliminates unnecessary eslint-disable directives
  • Maintains backwards compatibility

2. Well-Designed Logger Module

  • Clean, type-safe implementation with proper TypeScript strict mode compliance
  • Environment-based log level control via MCP_APPS_LOG_LEVEL
  • Consistent format with timestamp, level, and source
  • Excellent test coverage (logger.test.ts)

3. Consistent Migration Pattern

  • All 17 inspector modules migrated to use createLogger(source)
  • Scoped logger instances with descriptive source names
  • Stale eslint-disable no-console comments properly removed

Issues & Concerns

1. Code Duplication (Medium Priority)
The logger implementation is duplicated across packages:

  • packages/inspector/src/debug/logger.ts (98 lines)
  • packages/codegen/src/watcher.ts (22 lines, inline)
  • packages/testing/src/eval/mcp/evaluator.ts (16 lines)
  • packages/ui-react/src/hooks.ts (20 lines)

Recommendation: Extract the logger into a shared package to avoid drift.

2. Browser Compatibility (Low-Medium)
In packages/ui-react/src/hooks.ts, the logger checks process.env at runtime, which won't exist in browsers. Logger will always use default info level.

3. Missing Documentation (Low)
The MCP_APPS_LOG_LEVEL environment variable is not documented in README or CONTRIBUTING.md.

Security & Performance

  • No security concerns identified
  • Negligible performance impact

Recommendations

Must Fix: None - safe to merge as-is

Should Fix (Follow-Up):

  1. Extract logger to shared package to eliminate duplication
  2. Document MCP_APPS_LOG_LEVEL environment variable
  3. Complete migration if structured logging is the new standard

Alignment with Repository Standards

  • Follows AGENTS.md guidelines
  • Strict TypeScript with no any
  • Proper export contract
  • Tests added under owning package

Final Verdict

APPROVE with recommendations for follow-up improvements.

Risk Assessment: 🟢 Low Risk

  • Deprecated type removal: Zero consumers, safe
  • Logging changes: Backward compatible, well-tested
  • No breaking changes to public APIs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/inspector/src/widget-session-manager.ts (1)

401-445: ⚠️ Potential issue | 🟠 Major

Don’t use the Node logger inside page.evaluate (browser context).

logger is undefined in the page, so these evaluate calls can throw and break globals sync/event delivery. Use console in the page or inject a logger explicitly.

🛠️ Suggested fix
-            logger.info("[MCP Host] Sent ui/notifications/host-context-changed", ctx);
+            console.info("[MCP Host] Sent ui/notifications/host-context-changed", ctx);
-          logger.info("[OpenAI Host] Sent globals sync:", message.data);
+          console.info("[OpenAI Host] Sent globals sync:", message.data);
-          logger.info("[MCP Host] Stored hostContext update for ui/initialize:", p);
+          console.info("[MCP Host] Stored hostContext update for ui/initialize:", p);
-          logger.info("[MCP Host] Sent synced event:", m, p);
+          console.info("[MCP Host] Sent synced event:", m, p);
-        logger.info("[OpenAI Host] Sent synced event:", message.syncType, message.data);
+        console.info("[OpenAI Host] Sent synced event:", message.syncType, message.data);

Also applies to: 733-766, 792-799

packages/inspector/src/session/session-renderer.ts (1)

206-218: ⚠️ Potential issue | 🔴 Critical

Fix: logger usage inside page.evaluate will throw ReferenceError in browser context.

page.evaluate executes code in the browser, where logger is undefined. The calls at lines 216, 255, 285, 290, 295, and 303 will reject the evaluate promise, breaking globals sync and tool response delivery. Replace logger.info() with console.info() inside evaluate blocks and update the ESLint disable comment to include no-console.

Proposed fixes
-  /* eslint-disable no-undef */
+  /* eslint-disable no-undef, no-console */
   await page.evaluate((ctx: typeof hostContext) => {
     const iframe = document.getElementById("widget-frame") as HTMLIFrameElement | null;
     if (iframe?.contentWindow) {
       const message = {
         jsonrpc: "2.0",
         method: "ui/notifications/host-context-changed",
         params: { hostContext: ctx },
       };
       iframe.contentWindow.postMessage(message, "*");
-      logger.info("[MCP Host] Sent ui/notifications/host-context-changed", ctx);
+      console.info("[MCP Host] Sent ui/notifications/host-context-changed", ctx);
     }
   }, hostContext);
-  /* eslint-enable no-undef */
+  /* eslint-enable no-undef, no-console */
-  /* eslint-disable no-undef */
+  /* eslint-disable no-undef, no-console */
   await page.evaluate((message: typeof syncMessage) => {
     const iframe = document.getElementById("widget-frame") as HTMLIFrameElement | null;
     if (iframe?.contentWindow) {
       iframe.contentWindow.postMessage(message, "*");
-      logger.info("[OpenAI Host] Sent globals sync:", message.data);
+      console.info("[OpenAI Host] Sent globals sync:", message.data);
     }
   }, syncMessage);
-  /* eslint-enable no-undef */
+  /* eslint-enable no-undef, no-console */
-  /* eslint-disable no-undef */
+  /* eslint-disable no-undef, no-console */
   await page.evaluate((responseData: unknown) => {
     // Validate responseData is a non-null object before accessing properties
     if (typeof responseData !== "object" || responseData === null) {
-      logger.info("[MCP Host] Tool response is not a valid object:", responseData);
+      console.info("[MCP Host] Tool response is not a valid object:", responseData);
       return;
     }

     const d = responseData as Record<string, unknown>;
     const nameValue = d.name;
     const toolNameValue = d.toolName;

     // Validate that name or toolName exists and is a string
     const toolName =
       typeof nameValue === "string" && nameValue
         ? nameValue
         : typeof toolNameValue === "string" && toolNameValue
           ? toolNameValue
           : null;

     if (!toolName) {
-      logger.info("[MCP Host] Tool response missing valid name/toolName string:", responseData);
+      console.info("[MCP Host] Tool response missing valid name/toolName string:", responseData);
       return;
     }

     type PendingCall = { messageId: number | string; args: unknown; timestamp: number };
     const w = window as Window & { __pendingToolCalls?: Record<string, PendingCall[]> };
     const pending = w.__pendingToolCalls?.[toolName];

     if (!pending || pending.length === 0) {
-      logger.info("[MCP Host] No pending calls for tool:", toolName);
+      console.info("[MCP Host] No pending calls for tool:", toolName);
       return;
     }

     // Get the oldest pending call (FIFO)
     const call = pending.shift();
     if (!call) return;

     // Send response to widget iframe
     const iframe = document.getElementById("widget-frame") as HTMLIFrameElement | null;
     if (iframe?.contentWindow) {
       iframe.contentWindow.postMessage(
         {
           jsonrpc: "2.0",
           id: call.messageId,
           result: d.result ?? { content: [{ type: "text", text: JSON.stringify(d) }] },
         },
         "*"
       );
-      logger.info("[MCP Host] Delivered synced tool response:", toolName, call.messageId);
+      console.info("[MCP Host] Delivered synced tool response:", toolName, call.messageId);
     }
   }, data);
-  /* eslint-enable no-undef */
+  /* eslint-enable no-undef, no-console */
🤖 Fix all issues with AI agents
In `@packages/inspector/src/hosts/mcp-host.ts`:
- Around line 222-223: The Playwright page-init script is calling logger (e.g.,
logger.info('[MCP Host Emulator] Received ui/initialize, responding...')), which
is undefined in the browser context and will throw; change those in-page logging
calls to use console (console.info/console.warn/console.error) or pass an
injected logger object into the page context and call that instead. Locate all
occurrences of logger.* used inside the Playwright init script (the in-page
handler that sends the MCP emulator responses) and either replace them with
console.* or wire a serialized logger via page.exposeFunction /
page.evaluateOnNewDocument and call that exposed function from the page code to
avoid runtime errors.

In `@packages/inspector/src/hosts/openai-host.ts`:
- Around line 248-249: The init script injected into the browser context uses an
undefined logger variable (logger.info(...)) which will throw inside the
Playwright page; replace that call with console (e.g., console.info('[OpenAI
Host] requestDisplayMode:', mode, 'sizing:', sizing)) or inject a page-scoped
logger before use. Locate the snippet in openai-host.ts where the init script
emits "requestDisplayMode" (the logger.info call) and change logger to console
or wire an injected logger object into the page context so the code no longer
references an undefined symbol.

Comment on lines +222 to 223
logger.info('[MCP Host Emulator] Received ui/initialize, responding...');
// Respond with initialization success
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Avoid logger calls inside the Playwright init script (browser context).

logger isn’t defined in the page, so these will throw and can break the script. Use console or inject a logger into the page context.

🛠️ Suggested fix
-                logger.info('[MCP Host Emulator] Received ui/initialize, responding...');
+                console.info('[MCP Host Emulator] Received ui/initialize, responding...');
-                logger.info('[MCP Host Emulator] Sent ui/initialize response');
+                console.info('[MCP Host Emulator] Sent ui/initialize response');
-                  logger.info('[MCP Host Emulator] Sending ui/notifications/tool-result...');
+                  console.info('[MCP Host Emulator] Sending ui/notifications/tool-result...');
-                  logger.info('[MCP Host Emulator] Display mode changed to:', requestedMode, 'sizing:', sizing);
+                  console.info('[MCP Host Emulator] Display mode changed to:', requestedMode, 'sizing:', sizing);

Also applies to: 247-252, 280-281

🤖 Prompt for AI Agents
In `@packages/inspector/src/hosts/mcp-host.ts` around lines 222 - 223, The
Playwright page-init script is calling logger (e.g., logger.info('[MCP Host
Emulator] Received ui/initialize, responding...')), which is undefined in the
browser context and will throw; change those in-page logging calls to use
console (console.info/console.warn/console.error) or pass an injected logger
object into the page context and call that instead. Locate all occurrences of
logger.* used inside the Playwright init script (the in-page handler that sends
the MCP emulator responses) and either replace them with console.* or wire a
serialized logger via page.exposeFunction / page.evaluateOnNewDocument and call
that exposed function from the page code to avoid runtime errors.

Comment on lines +248 to 249
logger.info('[OpenAI Host] requestDisplayMode:', mode, 'sizing:', sizing);
return { mode: mode };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Avoid logger calls inside the Playwright init script (browser context).

logger is not defined in the page context, so this will throw and can break the init script. Use console (or inject a logger into the page) instead.

🛠️ Suggested fix
-            logger.info('[OpenAI Host] requestDisplayMode:', mode, 'sizing:', sizing);
+            console.info('[OpenAI Host] requestDisplayMode:', mode, 'sizing:', sizing);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
logger.info('[OpenAI Host] requestDisplayMode:', mode, 'sizing:', sizing);
return { mode: mode };
console.info('[OpenAI Host] requestDisplayMode:', mode, 'sizing:', sizing);
return { mode: mode };
🤖 Prompt for AI Agents
In `@packages/inspector/src/hosts/openai-host.ts` around lines 248 - 249, The init
script injected into the browser context uses an undefined logger variable
(logger.info(...)) which will throw inside the Playwright page; replace that
call with console (e.g., console.info('[OpenAI Host] requestDisplayMode:', mode,
'sizing:', sizing)) or inject a page-scoped logger before use. Locate the
snippet in openai-host.ts where the init script emits "requestDisplayMode" (the
logger.info call) and change logger to console or wire an injected logger object
into the page context so the code no longer references an undefined symbol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant