mcptools icon indicating copy to clipboard operation
mcptools copied to clipboard

can mcp tools (and other commands) capture err/std out logs?

Open maxandersen opened this issue 1 year ago • 8 comments

when calling a command that might fail you get something like:

mcp tools jbang fileserver@mcp-java
error: init response failed: error reading from stdout: EOF

in this case the issue is very clear if I could somehow see the logged stdout/err content.

Could the client capture and show that in case of error?

maxandersen avatar Apr 07 '25 14:04 maxandersen

Yes they can capture. Actually all the logs are stored in ~/.mcpt/ you can trace.

f avatar Apr 07 '25 15:04 f

~/.mcpt is empty for me no matter what errors I make.

maxandersen avatar Apr 08 '25 18:04 maxandersen

same problem and ~/.mcpt is also empty

ehlxr avatar Apr 11 '25 01:04 ehlxr

I believe ~/.mcpt/ captures logs for proxy and mock servers.

@maxandersen, If I understand correctly you would like to see the logs from the server that is being called, in your case it is jbang fileserver@mcp-java, is that right?

One way of seeing them is to run export MCP_DEBUG=1 first. Although this will print bunch of other debug lines on the code as well as the logs from server. I believe ideally we should capture stderr from server in a seperate file imo.

export MCP_DEBUG=1
mcp tools npx --verbose @jbangdev/jbang fileserver@mcp-java

ayakutt avatar Apr 11 '25 20:04 ayakutt

Yes I was hoping something like --verbose would show the stdout/stdout happening when calling.

maxandersen avatar Apr 12 '25 12:04 maxandersen

--server-logs works brilliantly - thanks!

maxandersen avatar Apr 14 '25 07:04 maxandersen

this works for 'tools' but it doesn't work for 'calls' am i missing something?

vqndev avatar Apr 20 '25 20:04 vqndev

You are right, apparently I forgot to change this switch statment, adding something like the code below should work, I am not available to open a PR soon, @vqndev feel free to send a PR. (cc: @f in case he wants to do it)

case cmdArgs[i] == FlagServerLogs:
	ShowServerLogs = true
	i++

ayakutt avatar Apr 21 '25 01:04 ayakutt