Handle large output: if the output has >= max_lines, save the full content to session
storage and return a string showing only the first or last max_lines lines with a pointer
to the saved file. Returns Ok(final_string) or Err(error_string) on failure.
Strip the MCP server prefix and any trailing “()” from a tool name.
Example: “stakpak__run_command” -> “run_command”
Example: “run_command” -> “run_command”
Example: “str_replace()” -> “str_replace”