fix(SEC-API-28): Replace MCP console.error with NestJS Logger
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

Replace all console.error calls in MCP services with NestJS Logger
instances for consistent structured logging in production.

- mcp-hub.service.ts: Add Logger instance, replace console.error in
  onModuleDestroy cleanup
- stdio-transport.ts: Add Logger instance, replace console.error for
  stderr output (as warn) and JSON parse failures (as error)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jason Woltje
2026-02-06 15:11:41 -06:00
parent 2e11931ded
commit 08d077605a
2 changed files with 7 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
import { Injectable, OnModuleDestroy } from "@nestjs/common";
import { Injectable, Logger, OnModuleDestroy } from "@nestjs/common";
import { StdioTransport } from "./stdio-transport";
import { ToolRegistryService } from "./tool-registry.service";
import type { McpServer, McpServerConfig, McpRequest, McpResponse } from "./interfaces";
@@ -16,6 +16,7 @@ interface McpServerWithTransport extends McpServer {
*/
@Injectable()
export class McpHubService implements OnModuleDestroy {
private readonly logger = new Logger(McpHubService.name);
private servers = new Map<string, McpServerWithTransport>();
constructor(private readonly toolRegistry: ToolRegistryService) {}
@@ -161,7 +162,7 @@ export class McpHubService implements OnModuleDestroy {
async onModuleDestroy(): Promise<void> {
const stopPromises = Array.from(this.servers.keys()).map((serverId) =>
this.stopServer(serverId).catch((error: unknown) => {
console.error(`Failed to stop server ${serverId}:`, error);
this.logger.error(`Failed to stop server ${serverId}:`, error);
})
);