Skip to main content
Glama
aws-powertools

Powertools MCP Search Server

logger.ts1.36 kB
import { Console } from 'node:console'; import { getStringFromEnv } from '@aws-lambda-powertools/commons/utils/env'; import { LogFormatter, Logger, LogItem } from '@aws-lambda-powertools/logger'; import type { LogAttributes, LogLevel, UnformattedAttributes, } from '@aws-lambda-powertools/logger/types'; const logLevel = getStringFromEnv({ key: 'LOG_LEVEL', defaultValue: 'INFO', }) as LogLevel; class CustomLogFormatter extends LogFormatter { formatAttributes( attributes: UnformattedAttributes, additionalLogAttributes: LogAttributes ): LogItem { return new LogItem({ attributes: { timestamp: attributes.timestamp, level: attributes.level, message: attributes.message, }, }).addAttributes(additionalLogAttributes); } } const logger = new Logger({ logLevel, logFormatter: new CustomLogFormatter(), }); /** * Since this MCP server uses the stdio protocol, we always * need to emit logs to `stderr` to avoid interfering with MCP's * communication over `stdout`. * * See https://modelcontextprotocol.io/docs/develop/build-server#logging-in-mcp-servers */ /* v8 ignore next -- @preserve */ if (process.env.NODE_ENV !== 'test') { // @ts-expect-error (logger as unknown).console = new Console({ stdout: process.stderr, stderr: process.stderr, }); } export { logger };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aws-powertools/powertools-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server