Skip to content

Conversation

@vibegui
Copy link
Contributor

@vibegui vibegui commented Jan 6, 2026

CleanShot 2026-01-06 at 16 46 59

Replace hono/logger with custom colored logging middleware that:

  • Uses ANSI colors for methods, status codes, and MCP-specific info
  • Shows tool names and arguments for MCP calls
  • Highlights event bus operations (PUBLISH, SUBSCRIBE, UNSUBSCRIBE)
  • Shortens long connection IDs in paths
  • Uses directional arrows (◀/▶) for MCP calls vs regular arrows (←/→)
  • Skips noisy paths like /api/auth/get-session

This provides better visibility into MCP operations during development.

What is this contribution about?

Describe your changes and why they're needed.

Screenshots/Demonstration

Add screenshots or a Loom video if your changes affect the UI.

Review Checklist

  • PR title is clear and descriptive
  • Changes are tested and working
  • Documentation is updated (if needed)
  • No breaking changes

Summary by cubic

Replaced the default logger in development with a custom, colorized request logger to make MCP activity easier to see and debug. Production keeps hono/logger.

  • New Features

    • Color-coded methods and status codes, with request duration.
    • MCP-aware logs: tool names and key arg keys; special ◀/▶ arrows.
    • Highlights event bus actions (publish, subscribe, unsubscribe).
    • Shortens long MCP connection IDs in paths.
    • Skips noisy paths like /api/auth/get-session and favicon.
  • Refactors

    • Use custom logger only in non-production; fall back to hono/logger in production.
    • Sanitizes logged strings to prevent control character and escape sequence injection.

Written for commit f7e71bc. Summary will update on new commits.


Note

Introduces a custom, colorized dev logging middleware and wires it into the app for non-production environments.

  • New utils/dev-logger.ts middleware: ANSI-colored methods/status, request duration, MCP-aware parsing (tool names, arg keys), event bus highlights (PUBLISH/SUBSCRIBE/UNSUBSCRIBE), shortened MCP connection IDs, directional arrows, and sanitized log output; skips noisy paths like /api/auth/get-session and favicon
  • In api/app.ts, conditionally uses devLogger() in non-production and hono/logger in production
  • Retains existing 5xx response body logging

Written by Cursor Bugbot for commit f7e71bc. This will update automatically on new commits. Configure here.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

🧪 Benchmark

Should we run the MCP Gateway benchmark for this PR?

React with 👍 to run the benchmark.

Reaction Action
👍 Run quick benchmark (10 & 128 tools)

Benchmark will run on the next push after you react.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

Release Options

Should a new version be published when this PR is merged?

React with an emoji to vote on the release type:

Reaction Type Next Version
👍 Prerelease 1.2.1-alpha.1
🎉 Patch 1.2.1
❤️ Minor 1.3.0
🚀 Major 2.0.0

Current version: 1.2.0

Deployment

  • Deploy to production (triggers ArgoCD sync after Docker image is published)

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 1 file

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/mesh/src/api/app.ts">

<violation number="1" location="apps/mesh/src/api/app.ts:218">
P2: If downstream throws, the completion (status/duration) log won’t run. Wrap `await next()` in `try/finally` so the outgoing log is always emitted while still propagating errors.</violation>

<violation number="2" location="apps/mesh/src/api/app.ts:237">
P1: Untrusted MCP request fields (toolName/eventType/arg keys) are interpolated into console logs without sanitizing control characters. This enables log forging / terminal escape injection. Strip `\r`, `\n`, and ANSI `\x1b` (or escape/control-character filter) before building `mcpInfo` (and consider doing the same for `path`).</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

};
};
if (body.method === "tools/call" && body.params?.name) {
const toolName = body.params.name;
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 6, 2026

Choose a reason for hiding this comment

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

P1: Untrusted MCP request fields (toolName/eventType/arg keys) are interpolated into console logs without sanitizing control characters. This enables log forging / terminal escape injection. Strip \r, \n, and ANSI \x1b (or escape/control-character filter) before building mcpInfo (and consider doing the same for path).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/mesh/src/api/app.ts, line 237:

<comment>Untrusted MCP request fields (toolName/eventType/arg keys) are interpolated into console logs without sanitizing control characters. This enables log forging / terminal escape injection. Strip `\r`, `\n`, and ANSI `\x1b` (or escape/control-character filter) before building `mcpInfo` (and consider doing the same for `path`).</comment>

<file context>
@@ -176,8 +175,124 @@ export function createApp(options: CreateAppOptions = {}) {
+          };
+        };
+        if (body.method === &quot;tools/call&quot; &amp;&amp; body.params?.name) {
+          const toolName = body.params.name;
+          const args = body.params.arguments || {};
+
</file context>

✅ Addressed in 952a1ef


// Skip noisy paths
if (path === "/api/auth/get-session" || path.includes("favicon")) {
await next();
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 6, 2026

Choose a reason for hiding this comment

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

P2: If downstream throws, the completion (status/duration) log won’t run. Wrap await next() in try/finally so the outgoing log is always emitted while still propagating errors.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/mesh/src/api/app.ts, line 218:

<comment>If downstream throws, the completion (status/duration) log won’t run. Wrap `await next()` in `try/finally` so the outgoing log is always emitted while still propagating errors.</comment>

<file context>
@@ -176,8 +175,124 @@ export function createApp(options: CreateAppOptions = {}) {
+
+    // Skip noisy paths
+    if (path === &quot;/api/auth/get-session&quot; || path.includes(&quot;favicon&quot;)) {
+      await next();
+      return;
+    }
</file context>

✅ Addressed in 952a1ef

Replace hono/logger with custom colored logging middleware that:
- Uses ANSI colors for methods, status codes, and MCP-specific info
- Shows tool names and arguments for MCP calls
- Highlights event bus operations (PUBLISH, SUBSCRIBE, UNSUBSCRIBE)
- Shortens long connection IDs in paths
- Uses directional arrows (◀/▶) for MCP calls vs regular arrows (←/→)
- Skips noisy paths like /api/auth/get-session

This provides better visibility into MCP operations during development.
@vibegui vibegui force-pushed the feat/pretty-request-logging branch from 146724d to 076fa71 Compare January 6, 2026 19:26
vibegui and others added 3 commits January 6, 2026 16:32
- Skip body cloning in production for performance improvements.
- Maintain detailed parsing in the call stack for better visibility.
- Ensure error handling for body parsing failures without breaking requests.
@viktormarinho viktormarinho merged commit e021659 into main Jan 7, 2026
5 checks passed
@viktormarinho viktormarinho deleted the feat/pretty-request-logging branch January 7, 2026 15:03
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This is the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on February 22

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

mcpInfo = `${colors.tool}EVENT_SUBSCRIBE${colors.reset} ${colors.bold}${eventType}${colors.reset}`;
} else if (toolName === "EVENT_UNSUBSCRIBE" && args.eventType) {
const eventType = sanitizeForLog(String(args.eventType));
mcpInfo = `${colors.tool}EVENT_UNSUBSCRIBE${colors.reset} ${colors.dim}${eventType}${colors.reset}`;
Copy link

Choose a reason for hiding this comment

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

EVENT_UNSUBSCRIBE special log formatting never triggers

Low Severity

The condition args.eventType for EVENT_UNSUBSCRIBE will never be truthy because this tool's input schema uses subscriptionId, not eventType. The spec and implementation confirm that EVENT_UNSUBSCRIBE takes { subscriptionId: string }. As a result, the special "✕ eventType" formatting will never appear for unsubscribe operations - they will fall through to the default formatting instead.

Fix in Cursor Fix in Web

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.

3 participants