Skip to content

chore(codegen): remove unused deprecated type aliases#168

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

chore(codegen): remove unused deprecated type aliases#168
gabrypavanello wants to merge 6 commits intomainfrom
kaizen/2026-02-13

Conversation

@gabrypavanello
Copy link
Contributor

Kaizen 2026-02-13 — Remove dead code.

FileBasedGlobalConfig and IconConfig were deprecated aliases in @mcp-apps-kit/codegen pointing to GlobalConfig and Icon from core. No consumer uses them. Removing them eliminates 2 dead type aliases and 1 eslint-disable comment.

  • Removed from packages/codegen/src/types.ts
  • Removed re-export from packages/codegen/src/index.ts
  • Build ✅ Tests ✅

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)
Remove FileBasedGlobalConfig and IconConfig deprecated aliases from
codegen types and their re-export from the package index.

These aliases were marked @deprecated pointing to GlobalConfig and Icon
from @mcp-apps-kit/core, but no consumer in the codebase uses them.
Removing them also eliminates one eslint-disable comment for
@typescript-eslint/no-deprecated.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 13, 2026

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Introduced structured logging system with configurable verbosity levels via environment variables. Logs now include timestamps, log levels, and source information.
  • Chores

    • Removed deprecated type exports from the codegen package.
  • Tests

    • Added comprehensive test coverage for the logging system and updated existing tests to work with the new logging mechanism.

Walkthrough

Introduces a structured, environment-configurable logging system throughout the inspector and codegen packages, replacing ad-hoc console logging with a centralized logger module. Adds logger integration across 15+ modules, removes deprecated type exports from codegen, and includes comprehensive test coverage for the new logging infrastructure.

Changes

Cohort / File(s) Summary
Codegen Package Cleanup
packages/codegen/src/index.ts, packages/codegen/src/types.ts
Removes deprecated public type exports (FileBasedGlobalConfig, IconConfig) that were previously re-exported from @mcp-apps-kit/core.
Logger Infrastructure
packages/inspector/src/debug/logger.ts, packages/inspector/src/index.ts
Introduces new structured logger module with LogLevel type, Logger interface, createLogger factory, and defaultLogger instance. Reads MCP_APPS_LOG_LEVEL environment variable and formats output with ISO timestamps, log levels, and source prefixes. Exports logger utilities from inspector package.
Codegen Logger Integration
packages/codegen/src/watcher.ts
Replaces static console logging with dynamic structured logger featuring timestamped, source-prefixed output filtered by MCP_APPS_LOG_LEVEL environment variable.
Inspector Connection & Streaming
packages/inspector/src/connection.ts, packages/inspector/src/dashboard/cdp-streamer.ts
Replaces console logging with logger instances for connection management and CDP streamer operations, preserving message content with structured output.
Inspector Server & OAuth Modules
packages/inspector/src/dual-server.ts, packages/inspector/src/widget-server.ts, packages/inspector/src/oauth/... (preset-config.ts, provider.ts, wellknown-proxy.ts)
Integrates logger into server initialization, request handling, and OAuth discovery paths, replacing all console logging with structured logger calls.
Inspector Host Emulators
packages/inspector/src/hosts/mcp-host.ts, packages/inspector/src/hosts/openai-host.ts
Replaces console logging in MCP and OpenAI host emulator implementations with logger, affecting UI initialization, postMessage handling, and display-mode updates.
Inspector Session & Widget Management
packages/inspector/src/session/session-renderer.ts, packages/inspector/src/session/session-store.ts, packages/inspector/src/widget-session-manager.ts, packages/inspector/src/tools/... (call-tool.ts, widget-control.ts)
Replaces console logging throughout session lifecycle, widget rendering, and tool invocation logic with structured logger calls.
Inspector Proxy Tools
packages/inspector/src/proxy-tools.ts
Replaces console.warn with logger.warn; introduces jsonSchemaToZodShape function that always includes a reasoning field in generated Zod shapes and constructs property schemas from JSON Schema.
Inspector Standalone Server
packages/inspector/src/standalone-server.ts
Replaces console logging in environment updates, error handling, and auto-connect paths with logger.info/logger.error.
Logger Tests & Test Updates
packages/inspector/tests/logger.test.ts, packages/inspector/tests/widget-session-manager.test.ts
Adds comprehensive test suite for logger covering log level filtering, environment-driven configuration, timestamp formatting, and source prefixes. Updates widget-session-manager test to assert console.info logging with logger prefix.
Testing & UI React Packages
packages/testing/src/eval/mcp/evaluator.ts, packages/ui-react/src/hooks.ts
Introduces lightweight, scoped internal loggers mirroring inspector logging pattern without cross-package dependencies; replaces console calls with logger.warn in evaluator and hooks modules.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 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 title 'chore(codegen): remove unused deprecated type aliases' accurately describes the main change: removing two deprecated type aliases from the codegen package.
Description check ✅ Passed The description clearly explains the removal of deprecated type aliases FileBasedGlobalConfig and IconConfig, their locations, and build/test status, all directly related to the changeset.
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-13

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

@claude
Copy link
Contributor

claude bot commented Feb 13, 2026

Code Review: PR #168 - Remove unused deprecated type aliases + Logging improvements

📊 Summary

Overall Assessment: ✅ APPROVE with minor suggestions

This is a well-executed cleanup PR that achieves two goals:

  1. Dead code removal: Removes unused deprecated type aliases from @mcp-apps-kit/codegen
  2. Logging infrastructure: Introduces structured logging with level control and consistent formatting

Stats: 25 files changed (+453/-203 lines)


✅ Strengths

1. Clean Architecture

  • New debug/logger.ts provides a solid foundation with:
    • Level-based filtering (debug/info/warn/error/silent)
    • Timestamp and source prefix formatting
    • Environment variable control (MCP_APPS_LOG_LEVEL)
    • Factory pattern for scoped loggers

2. Systematic Migration

  • Consistently replaces ad-hoc console.* calls across 15+ files
  • Removes unnecessary eslint-disable no-console comments
  • Maintains existing debug flag checks

3. Good Test Coverage

  • Comprehensive test suite for logger (108 lines)
  • Tests cover all log levels, env var handling, and edge cases
  • Existing tests updated to match new behavior

4. Performance Benefits

  • Level-based filtering prevents unnecessary string formatting
  • Lazy timestamp generation (only when logging)
  • Short-circuit evaluation for suppressed logs

⚠️ Issues & Recommendations

🔴 High Priority: Logger Code Duplication

Issue: Four separate logger implementations exist:

  • packages/inspector/src/debug/logger.ts (full-featured)
  • packages/codegen/src/watcher.ts:60-82 (inline IIFE)
  • packages/testing/src/eval/mcp/evaluator.ts:37-51 (inline IIFE)
  • packages/ui-react/src/hooks.ts:22-40 (inline IIFE)

Recommendation:

  • Extract logger to a shared package (e.g., @mcp-apps-kit/logger or @mcp-apps-kit/utils)
  • Remove duplicate inline implementations
  • Benefit: Single source of truth, easier maintenance, consistent behavior across packages

🟡 Medium Priority: Consider Per-Module Log Levels

Current: Single global MCP_APPS_LOG_LEVEL for entire process

Enhancement: Support module-specific levels like MCP_APPS_LOG_LEVEL_INSPECTOR=debug

Use case: Debug specific packages without flooding all output

🟡 Medium Priority: Unused Debug Method

The logger exposes a debug() method but it's not used anywhere in this PR.

Suggestion: Review existing logs and consider downgrading verbose info-level logs to debug


🔍 Minor Observations

Runtime Environment Variable Changes

Logger instances are created at module load time and cache the environment variable. Changing MCP_APPS_LOG_LEVEL at runtime won't affect already-created loggers.

Impact: Low (env vars typically set before process start)

Test Coupling

Tests in widget-session-manager.test.ts are now more tightly coupled to log format with assertions like:

expect(consoleSpy).toHaveBeenCalledWith(
  expect.stringContaining("[widget-session-manager]"),
  expect.stringContaining("[WidgetSessionManager] Created session")
);

Risk: Minor (log format changes require test updates)


🎯 Future Enhancements (Low Priority)

  1. Documentation: Add JSDoc examples and document MCP_APPS_LOG_LEVEL in README
  2. Structured Logging: Consider JSON-formatted logs for production environments
  3. Integration Tests: Add tests verifying logger behavior in actual execution contexts

✅ Security & Performance

  • Security: ✅ No concerns identified
  • Performance: ✅ Positive impact (reduced overhead via level filtering)

🎬 Verdict

Recommendation: APPROVE and MERGE

This PR successfully removes dead code and establishes a solid logging foundation. The code duplication issue is not blocking but should be addressed in a follow-up PR.

Next Steps:

  1. ✅ Merge this PR (builds pass, tests pass)
  2. 📋 Create follow-up issue to consolidate logger implementations
  3. 📖 Document logging usage in contribution guide

Great work on the systematic migration and comprehensive testing! 🚀

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: 3

Caution

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

⚠️ Outside diff range comments (4)
packages/inspector/src/session/session-renderer.ts (1)

206-219: ⚠️ Potential issue | 🔴 Critical

logger is undefined in browser context - runtime error.

The logger.info() call on line 216 is inside a page.evaluate() callback, which executes in the browser's JavaScript context, not Node.js. The module-scoped logger variable doesn't exist there, causing a ReferenceError at runtime.

The same issue occurs at lines 255, 286, 303, 312, and 331 in this file.

🐛 Proposed fix: remove logger calls from browser context or use console directly
   /* eslint-disable no-undef */
   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);
+      // Note: Cannot use Node.js logger here - this runs in browser context
+      console.info("[MCP Host] Sent ui/notifications/host-context-changed", ctx);
     }
   }, hostContext);
   /* eslint-enable no-undef */

Apply similar fixes to all other page.evaluate() blocks in this file.

packages/inspector/src/widget-session-manager.ts (1)

400-415: ⚠️ Potential issue | 🔴 Critical

logger is undefined in browser context - runtime error.

Line 412 uses logger.info() inside page.evaluate(), which executes in the browser context where the Node.js logger variable doesn't exist. This will throw a ReferenceError at runtime.

The same issue occurs at lines 442, 747, 760, and 796 in this file.

🐛 Proposed fix: use console.info in browser context
         /* eslint-disable no-undef */
         await page.evaluate((ctx: typeof hostContext) => {
           const iframe = document.getElementById("widget-frame") as HTMLIFrameElement | null;
           if (iframe?.contentWindow) {
             // Use the correct MCP Apps protocol method name
             // Wrap context in hostContext to match ext-apps SDK format
             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 */

Apply similar fixes to all other page.evaluate() blocks.

packages/inspector/src/hosts/mcp-host.ts (1)

220-281: ⚠️ Potential issue | 🟠 Major

Playwright init script will throw because logger is undefined in the browser context.

Those logger.info(...) calls are inside the string executed in the page; logger only exists in Node. This will raise a ReferenceError and can break the emulator bootstrap.

🛠️ Suggested fix: use console inside the injected script
-                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);
packages/inspector/src/proxy-tools.ts (1)

38-103: ⚠️ Potential issue | 🟡 Minor

Avoid overwriting an existing reasoning property from the target schema.

If the target schema already defines reasoning (type or requiredness), this currently overwrites it with an optional string, which can desync validation from the target.

✅ Safe guard to keep existing schema
-  // Add reasoning field for agent view transparency
-  shape.reasoning = reasoningField;
+  // Add reasoning field for agent view transparency (only if not already defined)
+  if (!("reasoning" in shape)) {
+    shape.reasoning = reasoningField;
+  }
🤖 Fix all issues with AI agents
In `@packages/inspector/src/hosts/openai-host.ts`:
- Around line 246-250: The injected Playwright init script uses Node's logger
(logger.info) inside the browser context causing a ReferenceError; update the
script code that defines requestDisplayMode (the function passed into
addInitScript / the inline script block in openai-host.ts) to use console.info
(or remove logging) instead of logger.info so it runs in the browser environment
without referencing the Node-only logger.

In `@packages/inspector/tests/logger.test.ts`:
- Around line 99-106: The test is flaky because it relies on the environment log
level; before calling createLogger("s") set process.env.MCP_APPS_LOG_LEVEL =
"warn" (or a level that allows warnings), then create the logger and run
assertions, and finally restore the original environment value (save const prev
= process.env.MCP_APPS_LOG_LEVEL; ... process.env.MCP_APPS_LOG_LEVEL = prev) so
other tests are unaffected; update the test around createLogger in
logger.test.ts to do this setup/teardown to make the test deterministic.

In `@packages/ui-react/src/hooks.ts`:
- Around line 26-32: The eslint-disable comment is placed before LEVELS but
needs to target the lines that reference process to suppress no-undef and
no-unnecessary-condition; move the comment so it immediately precedes the
envLevel declaration (the code that reads process.env?.MCP_APPS_LOG_LEVEL) or
replace the line comment with a block disable that wraps the envLevel
assignment; ensure you still limit the disable to that specific expression and
keep LEVELS and threshold unchanged (references: LEVELS, envLevel, threshold,
process).
🧹 Nitpick comments (1)
packages/inspector/src/oauth/wellknown-proxy.ts (1)

81-85: Redundant prefix in log message.

The createLogger("wellknown-proxy") already includes [wellknown-proxy] in every log line. The additional [oauth:wellknown-proxy] prefix in the message creates redundant output like:
<timestamp> [INFO] [wellknown-proxy] [oauth:wellknown-proxy] ...

Consider removing the inline prefix for cleaner logs, or changing the logger source to "oauth:wellknown-proxy" and removing the inline prefix.

♻️ Suggested fix
-const logger = createLogger("wellknown-proxy");
+const logger = createLogger("oauth:wellknown-proxy");

And then:

   function log(message: string): void {
     if (debug) {
-      logger.info(`[oauth:wellknown-proxy] ${message}`);
+      logger.info(message);
     }
   }

Comment on lines 246 to 250
}));

console.log('[OpenAI Host] requestDisplayMode:', mode, 'sizing:', sizing);
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 | 🔴 Critical

logger is undefined in browser context - runtime error.

Line 248 uses logger.info() inside the Playwright init script string, which executes in the browser's JavaScript context when injected via addInitScript(). The Node.js logger variable doesn't exist there, causing a ReferenceError when requestDisplayMode is called.

🐛 Proposed fix: use console.info in browser script
             // Dispatch set_globals event with updated sizing
             window.dispatchEvent(new CustomEvent('openai:set_globals', {
               detail: {
                 globals: {
                   displayMode: mode,
                   maxHeight: sizing.maxHeight,
                   viewport: window.__openaiEmulator.viewport,
                 },
               },
             }));

-            logger.info('[OpenAI Host] requestDisplayMode:', mode, 'sizing:', sizing);
+            console.info('[OpenAI Host] requestDisplayMode:', mode, 'sizing:', sizing);
             return { mode: mode };
           },
📝 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
}));
console.log('[OpenAI Host] requestDisplayMode:', mode, 'sizing:', sizing);
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 246 - 250, The
injected Playwright init script uses Node's logger (logger.info) inside the
browser context causing a ReferenceError; update the script code that defines
requestDisplayMode (the function passed into addInitScript / the inline script
block in openai-host.ts) to use console.info (or remove logging) instead of
logger.info so it runs in the browser environment without referencing the
Node-only logger.

Comment on lines +99 to +106
it("passes additional arguments through", () => {
const logger = createLogger("s");
const obj = { foo: 1 };
logger.warn("msg", obj, 42);
const args = (console.warn as ReturnType<typeof vi.fn>).mock.calls[0];
expect(args[1]).toBe("msg");
expect(args[2]).toBe(obj);
expect(args[3]).toBe(42);
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 | 🟡 Minor

Test can flake if MCP_APPS_LOG_LEVEL is set in the environment.

This test expects warn to emit, but doesn’t set the env; if CI sets the level to error/silent, the assertion will fail.

✅ Make the test deterministic
 it("passes additional arguments through", () => {
+  process.env.MCP_APPS_LOG_LEVEL = "warn";
   const logger = createLogger("s");
   const obj = { foo: 1 };
📝 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
it("passes additional arguments through", () => {
const logger = createLogger("s");
const obj = { foo: 1 };
logger.warn("msg", obj, 42);
const args = (console.warn as ReturnType<typeof vi.fn>).mock.calls[0];
expect(args[1]).toBe("msg");
expect(args[2]).toBe(obj);
expect(args[3]).toBe(42);
it("passes additional arguments through", () => {
process.env.MCP_APPS_LOG_LEVEL = "warn";
const logger = createLogger("s");
const obj = { foo: 1 };
logger.warn("msg", obj, 42);
const args = (console.warn as ReturnType<typeof vi.fn>).mock.calls[0];
expect(args[1]).toBe("msg");
expect(args[2]).toBe(obj);
expect(args[3]).toBe(42);
🤖 Prompt for AI Agents
In `@packages/inspector/tests/logger.test.ts` around lines 99 - 106, The test is
flaky because it relies on the environment log level; before calling
createLogger("s") set process.env.MCP_APPS_LOG_LEVEL = "warn" (or a level that
allows warnings), then create the logger and run assertions, and finally restore
the original environment value (save const prev =
process.env.MCP_APPS_LOG_LEVEL; ... process.env.MCP_APPS_LOG_LEVEL = prev) so
other tests are unaffected; update the test around createLogger in
logger.test.ts to do this setup/teardown to make the test deterministic.

Comment on lines +26 to +32
const LEVELS: Record<string, number> = { debug: 0, info: 1, warn: 2, error: 3, silent: 4 };
// eslint-disable-next-line no-undef, @typescript-eslint/no-unnecessary-condition
const envLevel =
typeof process !== "undefined"
? ((process.env?.MCP_APPS_LOG_LEVEL as string | undefined) ?? "").toLowerCase()
: "";
const threshold: number = LEVELS[envLevel] ?? 1; // 1 = info
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 | 🟡 Minor

Misplaced eslint-disable comment causes static analysis error.

The eslint-disable comment on line 27 is placed before the LEVELS constant, but the process reference that triggers the no-undef error is on lines 29-30. The comment should cover the lines that actually access process.

🐛 Suggested fix
   const ts = () => new Date().toISOString();
   const LEVELS: Record<string, number> = { debug: 0, info: 1, warn: 2, error: 3, silent: 4 };
-  // eslint-disable-next-line no-undef, `@typescript-eslint/no-unnecessary-condition`
   const envLevel =
+    // eslint-disable-next-line no-undef
     typeof process !== "undefined"
+      // eslint-disable-next-line no-undef
       ? ((process.env?.MCP_APPS_LOG_LEVEL as string | undefined) ?? "").toLowerCase()
       : "";

Or use a block disable:

   const ts = () => new Date().toISOString();
   const LEVELS: Record<string, number> = { debug: 0, info: 1, warn: 2, error: 3, silent: 4 };
-  // eslint-disable-next-line no-undef, `@typescript-eslint/no-unnecessary-condition`
+  /* eslint-disable no-undef */
   const envLevel =
     typeof process !== "undefined"
       ? ((process.env?.MCP_APPS_LOG_LEVEL as string | undefined) ?? "").toLowerCase()
       : "";
+  /* eslint-enable no-undef */
   const threshold: number = LEVELS[envLevel] ?? 1; // 1 = info
🧰 Tools
🪛 ESLint

[error] 30-30: 'process' is not defined.

(no-undef)

🤖 Prompt for AI Agents
In `@packages/ui-react/src/hooks.ts` around lines 26 - 32, The eslint-disable
comment is placed before LEVELS but needs to target the lines that reference
process to suppress no-undef and no-unnecessary-condition; move the comment so
it immediately precedes the envLevel declaration (the code that reads
process.env?.MCP_APPS_LOG_LEVEL) or replace the line comment with a block
disable that wraps the envLevel assignment; ensure you still limit the disable
to that specific expression and keep LEVELS and threshold unchanged (references:
LEVELS, envLevel, threshold, process).

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