Skip to content

feat(mcp): add debug logging mode for tool calls and errors#180

Open
annextuckner wants to merge 1 commit into
tuckner/mcp-toolsfrom
tuckner/mcp-debug-logging
Open

feat(mcp): add debug logging mode for tool calls and errors#180
annextuckner wants to merge 1 commit into
tuckner/mcp-toolsfrom
tuckner/mcp-debug-logging

Conversation

@annextuckner
Copy link
Copy Markdown

What

Adds a debug logging mode that surfaces tool calls and error responses live in the terminal.

pnpm run server-http:debug     # HTTP mode + debug logging
pnpm run server-stdio:debug    # stdio mode + debug logging
# or set MCP_DEBUG=true / LOG_LEVEL=debug on the existing server-* scripts
  • lib/logger.ts — log level is now env-driven (MCP_DEBUG / LOG_LEVEL). Adds a pino-pretty stderr target. Errors surface to the terminal in normal runs; the full request/response stream shows when debug is on. The tmp log files still capture everything. stderr is safe in both modes — it is never the MCP protocol channel.
  • lib/tool-logging.ts (new) — withToolLogging() wraps registerTool once so every tool logs uniformly: args and successful responses at debug level, error responses and thrown errors always. The access token rides on extra.authInfo and is never logged.
  • lib/depscore-tool.ts — apply the wrapper in createConfiguredServer, the shared factory for both transports.
  • package.jsonserver-http:debug / server-stdio:debug scripts.

Stacked

Based on #179 (the MCP tools PR) since both edit createConfiguredServer. Retarget to main once #179 merges.

Test

  • pnpm run test:node-test — 77 tests pass
  • oxlint clean on the changed files; tsgo clean on lib/
  • Verified both modes by hand: debug mode prints tool call / tool result; normal mode prints only error responses to stderr

MCP_DEBUG=true raises the log level to debug and streams pretty logs to
stderr, surfacing each tool call's args and any error response live in
the terminal. A central registerTool wrapper logs every tool uniformly;
error responses also surface to stderr in normal runs. New server-http:debug
and server-stdio:debug scripts set the flag.
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