Skip to content

Commit c54c9db

Browse files
committed
fix(server.py): improve error handling by adding stdout and refining stderr checks to enhance output clarity
1 parent 4c40528 commit c54c9db

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/mcp_shell_server/server.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ async def run_tool(self, arguments: dict) -> Sequence[TextContent]:
9494
if result.get("error"):
9595
raise ValueError(result["error"])
9696

97-
# Filter out bash process control messages
97+
# Add stdout if present
9898
if result.get("stdout"):
9999
content.append(TextContent(type="text", text=result["stdout"]))
100100

101-
stderr = result.get("stderr", "")
102-
if stderr and not stderr.startswith(
103-
"bash: cannot set terminal process group"
104-
):
101+
# Add stderr if present and not a process group message
102+
stderr = result.get("stderr")
103+
if stderr and not stderr.startswith("bash: cannot set terminal process group"):
105104
content.append(TextContent(type="text", text=stderr))
106105

106+
107107
except asyncio.TimeoutError as e:
108108
raise ValueError(f"Command timed out after {timeout} seconds") from e
109109

0 commit comments

Comments
 (0)