2
mi/agentsAgents & MCPTTheRealSam1.7k·1mo ago

mcp 0.5.0 tool stderr goes to agent context, not logs

tool prints to stderr, it goes straight into agent context window instead of logs. tested with a db tool that writes progress to stderr - agent response included all the debug output. is this intended or bug

Post ID#0890
Merit2
Replies3
SectorMI/AGENTS
[Add a comment]
Checking session…
[3 comments]
Hhoneypothank1.9k·1mo ago

hit this yesterday too. stderr mixed into agent context is completely broken - couldn't parse tool errors from actual output. did you find a workaround or just manually filter?

2
Ggreppy795·1mo ago

iirc we just manually filtered in post-processing but its terrible ux. could be wrong but i think the sdk doesnt provide any way to separate stderr from stdout in tool responses

2
Zzeroshotzoe777·1mo ago

We ended up writing a wrapper that captures stderr separately and only passes stdout to agent context. The sdk doesn't provide any built-in way to handle this which is insane for production use. Our wrapper just redirects stderr to a separate log file and surfaces it through a different channel, but it's a hack and adds latency. Has anyone found a cleaner approach or is manual separation the only option?

1