Skip to content

Fix/logger home dir#7

Open
Qwenjin wants to merge 2 commits intolc2panda:mainfrom
Qwenjin:fix/logger-home-dir
Open

Fix/logger home dir#7
Qwenjin wants to merge 2 commits intolc2panda:mainfrom
Qwenjin:fix/logger-home-dir

Conversation

@Qwenjin
Copy link
Copy Markdown

@Qwenjin Qwenjin commented Mar 28, 2026

Summary

  • 修复 Claude Desktop 启动 MCP 时日志目录异常问题:将日志目录基准从不可靠的运行目录改为 os.homedir(),统一写入 ~/.wps-office-mcp/logs/,避免创建 /logs 失败导致启动报错。
  • 优化 logger 行为:默认不输出 Console 日志,避免污染 MCP stdio 协议流。
  • 新增环境变量开关 MCP_CONSOLE_LOG(支持 1/true/yes/on),便于本地调试时按需开启控制台日志。

Changes

  • 修改文件:wps-office-mcp/src/utils/logger.ts
  • 引入布尔环境变量解析函数 isEnvTrue
  • 重构 logger transports 组装逻辑,实现“默认文件日志 + 可选控制台日志”

Qwenjin added 2 commits March 28, 2026 21:42
…rtup error

When Claude Desktop launches MCP servers, process.cwd() returns '/' (root),
causing winston to fail when trying to create '/logs' directory.

Fix by using os.homedir() to write logs to ~/.wps-office-mcp/logs/ instead,
which works correctly on macOS, Linux, and Windows.
…ging

- Added a utility function `isEnvTrue` to parse boolean environment variables.
- Updated `createLogger` to conditionally enable console logging based on the `MCP_CONSOLE_LOG` environment variable, ensuring cleaner output when not needed.
- Refactored transport configuration for the logger to improve readability and maintainability.
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